'protractor tests fail in docker build - worked before, connection refused

on my latest codebuild the frontend tests fail. they have worked for ages way before I took control of this app. Nothing major has changed in the frontend, and I tried very hard but cant find the root of the problem. I've setup a local codebuild that is the same to try and see if I can solve it.

the app is VERY old, and uses turbogears 2.2.2 but that's besides the point.

this is the relevant part of the buildspec:

   - 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

i've changed the name of the containers to keep the app anonymous.

I've tried using newer chrome images, a firefox image, i've tried adding chrome options to make it less memory consuming, ive tried removing the --net="host" tag, i've tried updating protractor, and i've also tried updating the webdriver-manager inside protractor.

the thing that bugs me the most is that it worked until recently! and I don't know what changed.

in the build logs on aws i got CONNECTION REFUSED on the app itself (localhost:8080), and on my local codebuild i got CONNECTION_REFUSED on the selenium address (localhost:4444)

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 [email protected] No repository field.
[36magent_1  |[0m npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
[36magent_1  |[0m npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: 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 > [email protected] 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 > [email protected] 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! [email protected] 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 [email protected] 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! [email protected] 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 [email protected] 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

any ideas would be greatly appreciated!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source