Oleg
Oleg

Reputation: 453

Testcontainer junit test skipped in azure build pipeline after moving to ubuntu 20

I have junit test with testcontainer in my project.

@Testcontainers(disabledWithoutDocker = true)
public class AutoHedgeDaoTest {

    @Container
    GenericContainer<?> mongoContainer = new GenericContainer<>("mongo:3.6.9").withExposedPorts(27017);

    MongoTemplate mongoTemplate;

...
}

I use azure devops pipeline to build my project

- task: Maven@3
          displayName: maven build
          inputs:
            mavenPomFile: 'fixByPassWeb/pom.xml'
            goals: 'clean install'
            options: ' -DbuildNumber=$(Build.BuildNumber)'
            publishJUnitResults: true
            testResultsFiles: '**/surefire-reports/TEST-*.xml'
            javaHomeOption: 'JDKVersion'
            jdkVersionOption: 1.11
            mavenVersionOption: 'Default'
            mavenAuthenticateFeed: false
            effectivePomSkip: false
            sonarQubeRunAnalysis: false

On November azure devops uses ubuntu 18 and all was good. This is part of log

14:58:14.857 [main] DEBUG org.testcontainers.utility.TestcontainersConfiguration - Testcontainers configuration overrides will be loaded from file:/home/vsts/.testcontainers.properties
14:58:15.309 [ducttape-0] DEBUG org.testcontainers.dockerclient.DockerClientProviderStrategy - Pinging docker daemon...
14:58:15.332 [ducttape-0] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd:
14:58:15.433 [main] INFO org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy - Found docker client settings from environment
14:58:15.434 [main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Found Docker environment with Environment variables, system properties and defaults. Resolved dockerHost=unix:///var/run/docker.sock
14:58:15.434 [main] DEBUG org.testcontainers.dockerclient.DockerClientProviderStrategy - Checking Docker OS type for Environment variables, system properties and defaults. Resolved dockerHost=unix:///var/run/docker.sock
14:58:15.436 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd:
14:58:15.623 [main] INFO org.testcontainers.DockerClientFactory - Docker host IP address is localhost
14:58:15.624 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd:
14:58:15.643 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd:
14:58:15.662 [main] INFO org.testcontainers.DockerClientFactory - Connected to docker:
Server Version: 19.03.13+azure
API Version: 1.40
Operating System: Ubuntu 18.04.5 LTS
Total Memory: 6927 MB

14:58:15.662 [main] DEBUG org.testcontainers.DockerClientFactory - Ryuk is enabled
14:58:15.670 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ListImagesCmdImpl[imageNameFilter=testcontainersofficial/ryuk:0.3.0,showAll=false,filters=com.github.dockerjava.core.util.FiltersBuilder@0]
14:58:15.726 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - Looking up auth config for image: testcontainersofficial/ryuk:0.3.0 at registry: index.docker.io
14:58:15.728 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - RegistryAuthLocator has configFile: /home/vsts/.docker/config.json (exists) and commandPathPrefix:
14:58:15.737 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - registryName [index.docker.io] for dockerImageName [testcontainersofficial/ryuk:0.3.0]
14:58:15.748 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - found existing auth config [AuthConfig{username=githubactions, password=hidden non-blank value, auth=hidden non-blank value, email=null, registryAddress=https://index.docker.io/v1/, registryToken=blank}]
14:58:15.750 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - Cached auth found: [AuthConfig{username=githubactions, password=hidden non-blank value, auth=hidden non-blank value, email=null, registryAddress=https://index.docker.io/v1/, registryToken=blank}]
14:58:15.751 [main] DEBUG org.testcontainers.dockerclient.auth.AuthDelegatingDockerClientConfig - Effective auth config [AuthConfig{username=githubactions, password=hidden non-blank value, auth=hidden non-blank value, email=null, registryAddress=https://index.docker.io/v1/, registryToken=blank}] 14:58:16.929 [tc-okhttp-stream-559050604] INFO org.testcontainers.DockerClientFactory - Starting to pull image
14:58:16.942 [tc-okhttp-stream-559050604] DEBUG com.github.dockerjava.core.command.PullImageResultCallback - ResponseItem(stream=null, status=Pulling from testcontainersofficial/ryuk, progressDetail=null, progress=null, id=0.3.0, from=null, time=null, errorDetail=null, error=null, aux=null)
14:58:16.950 [tc-okhttp-stream-559050604] INFO org.testcontainers.DockerClientFactory - Pulling image layers: 0 pending, 0 downloaded, 0 extracted, (0 bytes/0 bytes)
…………….
[INFO] Running com.AutoHedgeDaoTest
………………
14:58:32.725 [main] INFO com.rencap.fo.fixbypass.web.AutoHedgeDaoTest - Connecting to mongodb://localhost:32769
……………………..
14:58:33.592 [main] DEBUG org.testcontainers.utility.ResourceReaper - Removed container and associated volume(s): mongo:3.6.9
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 15.047 s - in com.AutoHedgeDaoTest

But now azure devops uses ubuntu 20. And currently test skipped.

18:16:28.143 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd:
18:16:28.295 [main] INFO org.testcontainers.DockerClientFactory - Docker host IP address is localhost
18:16:28.297 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd:
18:16:28.315 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd:
18:16:28.333 [main] INFO org.testcontainers.DockerClientFactory - Connected to docker:
Server Version: 20.10.2+azure
API Version: 1.41
Operating System: Ubuntu 20.04.2 LTS
Total Memory: 6954 MB

18:16:28.334 [main] DEBUG org.testcontainers.DockerClientFactory - Ryuk is enabled
18:16:28.338 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ListImagesCmdImpl[imageNameFilter=testcontainersofficial/ryuk:0.3.0,showAll=false,filters=com.github.dockerjava.core.util.FiltersBuilder@0]
18:16:28.374 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - Looking up auth config for image: testcontainersofficial/ryuk:0.3.0 at registry: index.docker.io
18:16:28.376 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - RegistryAuthLocator has configFile: /home/vsts/.docker/config.json (exists) and commandPathPrefix:
18:16:28.381 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - registryName [index.docker.io] for dockerImageName [testcontainersofficial/ryuk:0.3.0]
18:16:28.392 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - found existing auth config [AuthConfig{username=githubactions, password=hidden non-blank value, auth=hidden non-blank value, email=null, registryAddress=https://index.docker.io/v1/, registryToken=blank}]
18:16:28.392 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - Cached auth found: [AuthConfig{username=githubactions, password=hidden non-blank value, auth=hidden non-blank value, email=null, registryAddress=https://index.docker.io/v1/, registryToken=blank}]
18:16:28.392 [main] DEBUG org.testcontainers.dockerclient.auth.AuthDelegatingDockerClientConfig - Effective auth config [AuthConfig{username=githubactions, password=hidden non-blank value, auth=hidden non-blank value, email=null, registryAddress=https://index.docker.io/v1/, registryToken=blank}]
18:16:28.419 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd:
com.github.dockerjava.core.command.CreateContainerCmdImpl@70925b45[name=testcontainers-ryuk-0dd3967c-ded1-45bb-9174-5710ca968be4,hostName=,domainName=,user=,attachStdin=,attachStdout=,attachStderr=,portSpecs=,tty=,stdinOpen=,stdInOnce=,env=,cmd=,healthcheck=,argsEscaped=,entrypoint=,image=testcontainersofficial/ryuk:0.3.0,volumes=com.github.dockerjava.api.model.Volumes@4263b080,workingDir=,macAddress=,onBuild=,networkDisabled=,exposedPorts=com.github.dockerjava.api.model.ExposedPorts@2af616d3,stopSignal=,stopTimeout=,hostConfig=HostConfig(binds=[//var/run/docker.sock:/var/run/docker.sock:rw], blkioWeight=null, blkioWeightDevice=null, blkioDeviceReadBps=null, blkioDeviceWriteBps=null, blkioDeviceReadIOps=null, blkioDeviceWriteIOps=null, memorySwappiness=null, nanoCPUs=null, capAdd=null, capDrop=null, containerIDFile=null, cpuPeriod=null, cpuRealtimePeriod=null, cpuRealtimeRuntime=null, cpuShares=null, cpuQuota=null, cpusetCpus=null, cpusetMems=null, devices=null, deviceCgroupRules=null, deviceRequests=null, diskQuota=null, dns=null, dnsOptions=null, dnsSearch=null, extraHosts=null, groupAdd=null, ipcMode=null, cgroup=null, links=[], logConfig=com.github.dockerjava.api.model.LogConfig@5910de75, lxcConf=null, memory=null, memorySwap=null, memoryReservation=null, kernelMemory=null, networkMode=null, oomKillDisable=null, init=null, autoRemove=true, oomScoreAdj=null, portBindings=null, privileged=false, publishAllPorts=true, readonlyRootfs=null, restartPolicy=null, ulimits=null, cpuCount=null, cpuPercent=null, ioMaximumIOps=null, ioMaximumBandwidth=null, volumesFrom=null, mounts=null, pidMode=null, isolation=null, securityOpts=null, storageOpt=null, cgroupParent=null, volumeDriver=null, shmSize=null, pidsLimit=null, runtime=null, tmpFs=null, utSMode=null, usernsMode=null, sysctls=null, consoleSize=null),labels={org.testcontainers=true},shell=,networkingConfig=,ipv4Address=,ipv6Address=,aliases=,authConfig=AuthConfig(username=githubactions, password=3d6472b9-3d49-4d17-9fc9-90d24258043b, email=null, registryAddress=https://index.docker.io/v1/, auth=Z2l0aHViYWN0aW9uczozZDY0NzJiOS0zZDQ5LTRkMTctOWZjOS05MGQyNDI1ODA0M2I=, registrytoken=null, identitytoken=null, stackOrchestrator=null)]
[INFO] Running com.AutoHedgeDaoTest [WARNING] Tests run: 1, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.006 s - in com.AutoHedgeDaoTest

Upvotes: 1

Views: 1240

Answers (1)

Levi Lu-MSFT
Levi Lu-MSFT

Reputation: 30343

From above error log, an old version of testcontainers was in use.

Upgrading the testcontainers dependency to the latest version 1.15.2 fixed above issue.

Upvotes: 1

Related Questions