Skip to content

Commit

Permalink
XWIKI-22796: Office tests are using outdated images
Browse files Browse the repository at this point in the history
  * Ensure to use image hash instead of image tag for the tag of built
    office images
  • Loading branch information
surli committed Jan 20, 2025
1 parent a7ea4e6 commit 83a9cbf
Showing 1 changed file with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.xwiki.test.integration.maven.MavenResolver;
import org.xwiki.test.integration.maven.RepositoryResolver;

import com.github.dockerjava.api.command.InspectImageResponse;
import com.github.dockerjava.api.model.Image;

import static java.time.temporal.ChronoUnit.SECONDS;
Expand Down Expand Up @@ -349,18 +350,39 @@ private String getDockerImageTag(TestConfiguration testConfiguration)
return testConfiguration.getServletEngineTag() != null ? testConfiguration.getServletEngineTag() : LATEST;
}

private GenericContainer<?> createServletContainer() throws Exception
private String getDockerImageHash(TestConfiguration testConfiguration)
{
// Not using try-with-resources since the global docker client should never be closed (triggers an
// IllegalStateException)
InspectImageResponse inspectImageResponse =
DockerClientFactory.instance().client().inspectImageCmd(getBaseImageName(testConfiguration)).exec();
String imageId = inspectImageResponse.getId();
String prefix = "sha256:";
if (imageId.startsWith(prefix)) {
imageId = imageId.substring(prefix.length());
}
return imageId;
}

private String getBaseImageName(TestConfiguration testConfiguration)
{
String baseImageName = String.format("%s:%s",
return String.format("%s:%s",
this.testConfiguration.getServletEngine().getDockerImageName(), getDockerImageTag(this.testConfiguration));
}

private GenericContainer<?> createServletContainer() throws Exception
{
String baseImageName = getBaseImageName(testConfiguration);
LOGGER.info("Get base image name: {}", baseImageName);
GenericContainer<?> container;

if (this.testConfiguration.isOffice()) {
// We only build the image once for performance reason.
// So we compute a name for the image we will build, and we check that the image does not exist yet.
String imageName = String.format("xwiki-%s-office:%s",
String imageName = String.format("xwiki-%s-%s-office:%s",
this.testConfiguration.getServletEngine().name().toLowerCase(),
getDockerImageTag(this.testConfiguration));
getDockerImageTag(testConfiguration),
getDockerImageHash(this.testConfiguration));

// We rebuild every time the LibreOffice version changes
String officeVersion = this.mavenResolver.getPropertyFromCurrentPOM("libreoffice.version");
Expand Down

0 comments on commit 83a9cbf

Please sign in to comment.