在我最新的代码构建中,前端测试失败。在我控制这个应用程序之前,他们已经工作了很长时间。前端没有任何重大变化,我非常努力但找不到问题的根源。我已经设置了一个相同的本地代码构建来尝试看看我是否可以解决它。
该应用程序非常旧,并且使用 turbogears 2.2.2 但这不是重点。
这是构建规范的相关部分:
- docker build -f $CODEBUILD_SRC_DIR/dockerfiles/Dockerfile -t backend-container .
# Running backend container tests
- echo '#!/bin/bash' > /usr/local/bin/ok; echo 'if [[ "$CODEBUILD_BUILD_SUCCEEDING" == "0" ]]; then exit 1; else exit 0; fi' >> /usr/local/bin/ok; chmod +x /usr/local/bin/ok
# Running backend in ci mode for e2e tests backend
- ok && docker run --net="host" -d -p 8080:8080 -v /dev/shm:/dev/shm --name app-run-env backend-container /bin/bash -c "paster migrate upgrade --config ci.ini && paster serve ci.ini"
- ok && docker run --env DBUS_SESSION_BUS_ADDRESS=/dev/null --net="host" -d -p 4444:4444 -v /dev/shm:/dev/shm --name selenium-env selenium/standalone-chrome:3.141.59-neon
- ok && cd $CODEBUILD_SRC_DIR/app20/angular/app && npm install && npm update protractor && npm run test_ci
我更改了容器的名称以保持应用程序匿名。
我尝试使用较新的 chrome 图像、firefox 图像,我尝试添加 chrome 选项以减少内存消耗,我尝试删除 --net="host" 标签,我尝试更新量角器,并且我我还尝试更新量角器内的 webdriver-manager。
最让我烦恼的是它直到最近才起作用!我不知道发生了什么变化。
在aws的构建日志中,我在应用程序本身(localhost:8080)上得到了CONNECTION REFUSED,在我的本地代码构建中,我在selenium地址(localhost:4444)上得到了CONNECTION_REFUSED
36magent_1 |[0m [Container] 2022/02/19 10:01:54 Running command ok && docker run --net="host" -d -p 8080:8080 -v /dev/shm:/dev/shm --name app-run-env backend-container /bin/bash -c "paster migrate upgrade --config ci.ini && paster serve ci.ini"
[36magent_1 |[0m WARNING: Published ports are discarded when using host network mode
[36magent_1 |[0m 75db9ea656ea325af3fff481b87a271b9f5c7195ec3e1fabff499ffe6839ea84
[36magent_1 |[0m
[36magent_1 |[0m [Container] 2022/02/19 10:01:54 Running command ok && docker run --env DBUS_SESSION_BUS_ADDRESS=/dev/null --net="host" -d -p 4444:4444 -v /dev/shm:/dev/shm --name selenium-env selenium/standalone-chrome:3.141.59-neon /bin/bash -c "sudo -E -i seluser DBUS_SESSION_BUS_ADDRESS=/dev/null"
[36magent_1 |[0m WARNING: Published ports are discarded when using host network mode
[36magent_1 |[0m f88721f2ae945754b15e65499a63fedc5c145c402c434a5c8830136a5ad88889
[36magent_1 |[0m
[36magent_1 |[0m [Container] 2022/02/19 10:01:54 Running command ok && docker ps &&cd $CODEBUILD_SRC_DIR/ap/angular/app && npm install && npm update protractor && npm run test_ci
[36magent_1 |[0m CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[36magent_1 |[0m f88721f2ae94 selenium/standalone-chrome:3.141.59-neon "/bin/bash -c 'sudo ?" Less than a second ago Up Less than a second selenium-env
[36magent_1 |[0m 75db9ea656ea backend-container "/bin/bash -c 'paste?" Less than a second ago Up Less than a second app-run-env
[36magent_1 |[0m 6d327c01a75e codebuild-ubuntu-standard:5.0 "sh -c 'while [ ! -f?" 7 minutes ago Up 7 minutes agent-resources_build_1
[36magent_1 |[0m f476fc9bd890 amazon/aws-codebuild-local:latest "local_build.sh" 7 minutes ago Up 7 minutes 0.0.0.0:49188->3000/tcp, :::49188->3000/tcp agent-resources_agent_1
[36magent_1 |[0m 6c76d0e9ff0a public.ecr.aws/codebuild/local-builds:latest "local_build.sh" 7 minutes ago Up 7 minutes objective_bassi
[36magent_1 |[0m 457d19e58c1f mariadb:10.5 "docker-entrypoint.s?" 16 months ago Up 42 hours 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp mariadb-10.5
[36magent_1 |[0m npm WARN app20@2.0.0 No repository field.
[36magent_1 |[0m npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
[36magent_1 |[0m npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
[36magent_1 |[0m
[36magent_1 |[0m audited 652 packages in 3.694s
[36magent_1 |[0m found 112 vulnerabilities (15 low, 53 moderate, 37 high, 7 critical)
[36magent_1 |[0m run `npm audit fix` to fix them, or `npm audit` for details
[36magent_1 |[0m
[36magent_1 |[0m > app20@2.0.0 test_ci /codebuild/output/srcDownload/src/app20/angular/app
[36magent_1 |[0m > npm run test_ci:e2e
[36magent_1 |[0m
[36magent_1 |[0m
[36magent_1 |[0m > app20@2.0.0 test_ci:e2e /codebuild/output/srcDownload/src/app20/angular/app
[36magent_1 |[0m > ./node_modules/protractor/bin/protractor protractor.docker.conf.js
[36magent_1 |[0m
[36magent_1 |[0m [10:02:05] I/launcher - Running 1 instances of WebDriver
[36magent_1 |[0m [10:02:05] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[36magent_1 |[0m [10:02:05] E/launcher - Error code: 135
[36magent_1 |[0m [10:02:05] E/launcher - Error message: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444
[36magent_1 |[0m [10:02:05] E/launcher - Error: ECONNREFUSED connect ECONNREFUSED 127.0.0.1:4444
[36magent_1 |[0m at ClientRequest.<anonymous> (/codebuild/output/srcDownload/src/app20/angular/app/node_modules/selenium-webdriver/http/index.js:238:15)
[36magent_1 |[0m at ClientRequest.emit (events.js:375:28)
[36magent_1 |[0m at Socket.socketErrorListener (_http_client.js:475:9)
[36magent_1 |[0m at Socket.emit (events.js:375:28)
[36magent_1 |[0m at emitErrorNT (internal/streams/destroy.js:106:8)
[36magent_1 |[0m at emitErrorCloseNT (internal/streams/destroy.js:74:3)
[36magent_1 |[0m at processTicksAndRejections (internal/process/task_queues.js:82:21)
[36magent_1 |[0m From: Task: WebDriver.createSession()
[36magent_1 |[0m at Function.createSession (/codebuild/output/srcDownload/src/app20/angular/app/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
[36magent_1 |[0m at Function.createSession (/codebuild/output/srcDownload/src/app20/angular/app/node_modules/selenium-webdriver/chrome.js:761:15)
[36magent_1 |[0m at createDriver (/codebuild/output/srcDownload/src/app/angular/app/node_modules/selenium-webdriver/index.js:170:33)
[36magent_1 |[0m at Builder.build (/codebuild/output/srcDownload/src/app20/angular/app/node_modules/selenium-webdriver/index.js:626:16)
[36magent_1 |[0m at Hosted.getNewDriver (/codebuild/output/srcDownload/src/app20/angular/app/node_modules/protractor/built/driverProviders/driverProvider.js:53:33)
[36magent_1 |[0m at Runner.createBrowser (/codebuild/output/srcDownload/src/app20/angular/app/node_modules/protractor/built/runner.js:195:43)
[36magent_1 |[0m at /codebuild/output/srcDownload/src/app20/angular/app/node_modules/protractor/built/runner.js:339:29
[36magent_1 |[0m at _fulfilled (/codebuild/output/srcDownload/src/app20/angular/app/node_modules/q/q.js:834:54)
[36magent_1 |[0m at /codebuild/output/srcDownload/src/app20/angular/app/node_modules/q/q.js:863:30
[36magent_1 |[0m at Promise.promise.promiseDispatch (/codebuild/output/srcDownload/src/app20/angular/app/node_modules/q/q.js:796:13)
[36magent_1 |[0m [10:02:05] E/launcher - Process exited with error code 135
[36magent_1 |[0m npm ERR! code ELIFECYCLE
[36magent_1 |[0m npm ERR! errno 135
[36magent_1 |[0m npm ERR! app20@2.0.0 test_ci:e2e: `./node_modules/protractor/bin/protractor protractor.docker.conf.js`
[36magent_1 |[0m npm ERR! Exit status 135
[36magent_1 |[0m npm ERR!
[36magent_1 |[0m npm ERR! Failed at the app20@2.0.0 test_ci:e2e script.
[36magent_1 |[0m npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[36magent_1 |[0m
[36magent_1 |[0m npm ERR! A complete log of this run can be found in:
[36magent_1 |[0m npm ERR! /root/.npm/_logs/2022-02-19T10_02_05_180Z-debug.log
[36magent_1 |[0m npm ERR! code ELIFECYCLE
[36magent_1 |[0m npm ERR! errno 135
[36magent_1 |[0m npm ERR! app20@2.0.0 test_ci: `npm run test_ci:e2e`
[36magent_1 |[0m npm ERR! Exit status 135
[36magent_1 |[0m npm ERR!
[36magent_1 |[0m npm ERR! Failed at the app20@2.0.0 test_ci script.
[36magent_1 |[0m npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[36magent_1 |[0m
[36magent_1 |[0m npm ERR! A complete log of this run can be found in:
[36magent_1 |[0m npm ERR! /root/.npm/_logs/2022-02-19T10_02_05_198Z-debug.log
[36magent_1 |[0m
任何想法将不胜感激!