迁移到 ubuntu 20 后,在 azure 构建管道中跳过了 Testcontainer junit 测试

如何解决迁移到 ubuntu 20 后,在 azure 构建管道中跳过了 Testcontainer junit 测试

我的项目中有使用 testcontainer 的 junit 测试。

@Testcontainers(disabledWithoutDocker = true)
public class AutoHedgeDaoTest {

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

    MongoTemplate mongoTemplate;

...
}

我使用 azure devops 管道来构建我的项目

- 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

11 月 azure devops 使用 ubuntu 18,一切都很好。 这是日志的一部分

14:58:14.857 [main] DEBUG org.testcontainers.utility.TestcontainersConfiguration - Testcontainers 配置覆盖将从文件加载:/home/vsts/.testcontainers.properties
14:58:15.309 [ducttape-0] 调试 org.testcontainers.dockerclient.DockerClientProviderStrategy - Ping docker 守护进程...
14:58:15.332 [ducttape-0] 调试 com.github.dockerjava.core.command.AbstrDockerCmd - Cmd:
14:58:15.433 [main] INFO org.testcontainers.dockerclient.EnvironmentAndSystemPropertyClientProviderStrategy - 从环境中找到 docker 客户端设置
14:58:15.434 [main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - 找到带有环境变量、系统属性和默认值的 Docker 环境。已解决 dockerHost=unix:///var/run/docker.sock
14:58:15.434 [main] DEBUG org.testcontainers.dockerclient.DockerClientProviderStrategy - 检查 Docker 操作系统类型的环境变量、系统属性和默认值。已解决 dockerHost=unix:///var/run/docker.sock
14:58:15.436 [main] 调试 com.github.dockerjava.core.command.AbstrDockerCmd - Cmd:
14:58:15.623 [main] INFO org.testcontainers.DockerClientFactory - Docker 主机 IP 地址是 localhost
14:58:15.624 [main] 调试 com.github.dockerjava.core.command.AbstrDockerCmd - Cmd:
14:58:15.643 [main] 调试 com.github.dockerjava.core.command.AbstrDockerCmd - Cmd:
14:58:15.662 [main] 信息 org.testcontainers.DockerClientFactory - 连接到 docker:
服务器版本:19.03.13+azure
API版本:1.40
操作系统:Ubuntu 18.04.5 LTS
总内存:6927 MB

14:58:15.662 [main] DEBUG org.testcontainers.DockerClientFactory - Ryuk 已启用
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 - 查找图像的身份验证配置:testcontainersofficial/ryuk:0.3.0 at registry: index.docker.io
14:58:15.728 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - RegistryAuthLocator 有 configFile:/home/vsts/.docker/config.json(存在)和 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 - 找到现有的认证配置 [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 - 找到缓存的身份验证:[AuthConfig{username=githubactions,registryToken=blank}]
14:58:15.751 [main] DEBUG org.testcontainers.dockerclient.auth.AuthDelegatingDockerClientConfig - 有效的身份验证配置 [AuthConfig{username=githubactions,registryAddress =https://index.docker.io/v1/,registryToken=blank}] 14:58:16.929 [tc-okhttp-stream-559050604] INFO org.testcontainers.DockerClientFactory - 开始拉取镜像
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 - 拉取镜像层:0 待处理,0 下载,0 提取,(0 字节/0 字节)
…………….
[信息] 运行 com.AutoHedgeDaoTest
………………
14:58:32.725 [main] INFO com.rencap.fo.fixbypass.web.AutoHedgeDaoTest - 连接到 mongodb://localhost:32769
…………………………..
14:58:33.592 [main] DEBUG org.testcontainers.utility.ResourceReaper - 删除了容器和相关卷:mongo:3.6.9
[INFO] 测试运行:1,失败:0,错误:0,跳过:0, 已用时间:15.047 秒 - 在 com.AutoHedgeDaoTest 中

但现在 azure devops 使用 ubuntu 20。目前测试已跳过。

18:16:28.143 [main] 调试 com.github.dockerjava.core.command.AbstrDockerCmd - Cmd:
18:16:28.295 [main] INFO org.testcontainers.DockerClientFactory - Docker 主机 IP 地址是 localhost
18:16:28.297 [main] 调试 com.github.dockerjava.core.command.AbstrDockerCmd - Cmd:
18:16:28.315 [main] 调试 com.github.dockerjava.core.command.AbstrDockerCmd - Cmd:
18:16:28.333 [main] 信息 org.testcontainers.DockerClientFactory - 连接到 docker:
服务器版本:20.10.2+azure
API 版本:1.41
操作系统:Ubuntu 20.04.2 LTS
总内存:6954 MB

18:16:28.334 [main] DEBUG org.testcontainers.DockerClientFactory - Ryuk 已启用
18:16:28.338 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ListImagesCmdImpl[imageNameFilter=testcontainersofficial/ryuk:0.3.0,filters=com.github.dockerjava.core.util .FiltersBuilder@0]
18:16:28.374 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - 查找镜像的认证配置:testcontainersofficial/ryuk:0.3.0 at registry: index.docker.io
18:16:28.376 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - RegistryAuthLocator 有 configFile:/home/vsts/.docker/config.json(存在)和 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 - 找到现有的认证配置 [AuthConfig{username=githubactions,registryToken=blank}]
18:16:28.392 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - 找到缓存的身份验证:[AuthConfig{username=githubactions,registryToken=blank}]
18:16:28.392 [main] DEBUG org.testcontainers.dockerclient.auth.AuthDelegatingDockerClientConfig - 有效的身份验证配置 [AuthConfig{username=githubactions,registryToken=blank}]
18:16:28.419 [main] 调试 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=,SpecportStdr,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、隔离=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=,registrytoken=null=,registrytoken=null [信息] 运行 com.AutoHedgeDaoTest [警告] 测试运行:1,失败:0,错误:0,跳过:1,经过的时间:0.006 秒 - 在 com.AutoHedgeDaoTest 中

解决方法

从上面的错误日志来看,正在使用旧版本的测试容器。

将 testcontainers 依赖项升级到最新版本 1.15.2 已修复上述问题。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-