如何解决在 AWS CodeBuild 上运行带有类路径的独立 jar 已通过,但测试实际上并未运行
我正在使用 here 中描述的策略来运行独立的 karate.jar 和自定义 jar(实现 LogModifier):
java -cp karate.jar:seesaw-karate.jar:./tests/java com.intuit.karate.Main ./tests/api
这在我的本地机器上运行良好,但在 AWS CodeBuild 上运行时看到奇怪的行为:测试报告通过,但需要 0 秒并且没有显示输出,表明它们实际上没有运行。
CodeBuild 作业正在 /aws/codebuild/standard:3.0 映像上的 openjdk11 上运行。
java -version
报告:
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9,mixed mode)
为了比较我的本地环境:
java version "12.0.2" 2019-07-16
Java(TM) SE Runtime Environment (build 12.0.2+10)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.2+10,mixed mode,sharing)
注意:我们之前使用 java -jar karate.jar
运行并且在相同的 CodeBuild 环境中成功运行。我的理解是我们需要使用 classpath 方法来包含多个 jar 文件(我们需要这样做才能使用 LogModifier)。如果有更好的方法请指正!
以下是容器中的一些日志:
[Container] 2021/03/10 01:31:46 Running command java -Dkarate.config.dir=$RELOADED_DIR/exp/ss2_gql/tests/api/config -Dss2GqlUri=$RELOADED_HTTP_URL -DwsUri=$RELOADED_WS_URL -cp "${RELOADED_DIR}/exp/ss2_gql/karate.jar:${RELOADED_DIR}/exp/ss2_gql/seesaw-karate.jar:${RELOADED_DIR}/exp/ss2_gql/tests/java" com.intuit.karate.Main $RELOADED_DIR/exp/ss2_gql/tests/api --tags ~@ignore -o .karate-output
01:31:50.265 [main] INFO com.intuit.karate.Main - Karate version: 0.9.6
Warning: Nashorn engine is planned to be removed from a future JDK release
01:31:51.993 [main] INFO com.intuit.karate.Runner - waiting for parallel features to complete ...
01:31:52.741 [pool-1-thread-1] INFO com.intuit.karate.Runner - <<pass>> feature 1 of 25: 01/exp/ss2_gql/tests/api/conversation_test.feature
---------------------------------------------------------
feature: 01/exp/ss2_gql/tests/api/conversation_test.feature
report: .karate-output/surefire-reports/01.exp.ss2_gql.tests.api.conversation_test.json
scenarios: 9 | passed: 9 | Failed: 0 | time: 0.0000
---------------------------------------------------------
01:31:52.752 [pool-1-thread-1] INFO com.intuit.karate.Runner - <<pass>> feature 2 of 25: 01/exp/ss2_gql/tests/api/migrate_conversation_test.feature
---------------------------------------------------------
feature: 01/exp/ss2_gql/tests/api/migrate_conversation_test.feature
report: .karate-output/surefire-reports/01.exp.ss2_gql.tests.api.migrate_conversation_test.json
scenarios: 1 | passed: 1 | Failed: 0 | time: 0.0000
---------------------------------------------------------
01:31:52.761 [pool-1-thread-1] INFO com.intuit.karate.Runner - <<pass>> feature 3 of 25: 01/exp/ss2_gql/tests/api/conv_search.feature
---------------------------------------------------------
feature: 01/exp/ss2_gql/tests/api/conv_search.feature
report: .karate-output/surefire-reports/01.exp.ss2_gql.tests.api.conv_search.json
scenarios: 1 | passed: 1 | Failed: 0 | time: 0.0000
---------------------------------------------------------
01:31:52.788 [pool-1-thread-1] INFO com.intuit.karate.Runner - <<pass>> feature 5 of 25: 01/exp/ss2_gql/tests/apI/Org_test.feature
---------------------------------------------------------
feature: 01/exp/ss2_gql/tests/apI/Org_test.feature
report: .karate-output/surefire-reports/01.exp.ss2_gql.tests.api.org_test.json
scenarios: 4 | passed: 4 | Failed: 0 | time: 0.0000
---------------------------------------------------------
01:31:52.829 [pool-1-thread-1] INFO com.intuit.karate.Runner - <<pass>> feature 22 of 25: 01/exp/ss2_gql/tests/api/message_notifications_test.feature
---------------------------------------------------------
feature: 01/exp/ss2_gql/tests/api/message_notifications_test.feature
report: .karate-output/surefire-reports/01.exp.ss2_gql.tests.api.message_notifications_test.json
scenarios: 1 | passed: 1 | Failed: 0 | time: 0.0000
---------------------------------------------------------
01:31:52.846 [pool-1-thread-1] INFO com.intuit.karate.Runner - <<pass>> feature 23 of 25: 01/exp/ss2_gql/tests/api/auth_test.feature
---------------------------------------------------------
feature: 01/exp/ss2_gql/tests/api/auth_test.feature
report: .karate-output/surefire-reports/01.exp.ss2_gql.tests.api.auth_test.json
scenarios: 2 | passed: 2 | Failed: 0 | time: 0.0000
---------------------------------------------------------
01:31:52.858 [pool-1-thread-1] INFO com.intuit.karate.Runner - <<pass>> feature 24 of 25: 01/exp/ss2_gql/tests/api/update_conversation_read_status_test.feature
---------------------------------------------------------
feature: 01/exp/ss2_gql/tests/api/update_conversation_read_status_test.feature
report: .karate-output/surefire-reports/01.exp.ss2_gql.tests.api.update_conversation_read_status_test.json
scenarios: 2 | passed: 2 | Failed: 0 | time: 0.0000
---------------------------------------------------------
01:31:52.908 [pool-1-thread-1] INFO com.intuit.karate.Runner - <<pass>> feature 25 of 25: 01/exp/ss2_gql/tests/api/people_search.feature
---------------------------------------------------------
feature: 01/exp/ss2_gql/tests/api/people_search.feature
report: .karate-output/surefire-reports/01.exp.ss2_gql.tests.api.people_search.json
scenarios: 11 | passed: 11 | Failed: 0 | time: 0.0000
---------------------------------------------------------
HTML report: (paste into browser to view) | Karate version: 0.9.6
file:/codebuild/output/src992/src/s3/00/.karate-output/surefire-reports/karate-summary.html
===================================================================
Karate version: 0.9.6
======================================================
elapsed: 2.43 | threads: 1 | thread time: 0.00
features: 8 | ignored: 17 | efficiency: 0.00
scenarios: 31 | passed: 31 | Failed: 0
======================================================
解决方法
好的,您能否重试 1.0 RC 系列,因为这已接近最终版本,我们正在将开发工作集中于此:https://github.com/intuit/karate/wiki/1.0-upgrade-guide
因为我猜这是一个 JDK 兼容性问题,我们希望新版本能够修复它。您开始使用新版本进行测试也很重要,这样我们就有机会修复您可能发现的任何其他漏洞。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。