Skip to content

Commit ac583d5

Browse files
Merge pull request #15794 from rabbitmq/capture-mock-auth-backend-http-failure
(selenium) Capture why mock-auth-backend-http fails to start in some jobs in CI
2 parents ec52d40 + 97d60fa commit ac583d5

5 files changed

Lines changed: 29 additions & 2 deletions

File tree

selenium/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,15 @@ following command:
220220
MOCHA_DOCKER_FILE=\location\of\my\Dockerfile ./run-suites.sh
221221
```
222222

223+
When you run the tests locally, you need to run them with the environment variable
224+
`MOCHA_DOCKER_FILE=Dockerfile.local` so that the scripts that build the docker image
225+
`mocha-test` which internally downloads npm packages. To download these packages,
226+
you need to be in VPN via a gateway and have .npmrc file in the selenium folder
227+
with a api key downloaded from Artifactory. There is an internal confluence page
228+
that explains how do it.
229+
230+
Without this docker file and .npmrc file, it is impossible to build mocha-test image.
231+
223232
## Issues deploying UAA
224233

225234
If you are not able to successfully run any test case that depends on UAA

selenium/bin/components/fakeportal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ init_fakeportal() {
3838
start_fakeportal() {
3939
begin "Starting fakeportal ..."
4040

41+
build_mocha_image yes
4142
init_fakeportal
4243
kill_container_if_exist fakeportal
4344
mocha_test_tag=($(md5sum $SELENIUM_ROOT_FOLDER/package.json))

selenium/bin/components/fakeproxy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ init_fakeproxy() {
3434
start_fakeproxy() {
3535
begin "Starting fakeproxy ..."
3636

37+
build_mocha_image yes
3738
init_fakeproxy
3839
kill_container_if_exist fakeproxy
3940
mocha_test_tag=($(md5sum $SELENIUM_ROOT_FOLDER/package.json))

selenium/bin/components/mock-auth-backend-http

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,22 @@ start_mock-auth-backend-http() {
2323
init_mock-auth-backend-http
2424
kill_container_if_exist mock-auth-backend-http
2525

26+
local logfile="${MOCK_AUTH_BACKEND_HTTP_LOG:-$LOGS/mock-auth-backend-http.log}"
27+
print "> mock-auth-backend-http docker run log: ${logfile}"
28+
2629
docker run \
2730
--detach \
2831
--name mock-auth-backend-http \
2932
--net ${DOCKER_NETWORK} \
3033
--publish 8888:1080 \
3134
--env MOCKSERVER_INITIALIZATION_JSON_PATH="/config/defaultExpectations.json" \
3235
-v ${AUTH_BACKEND_HTTP_DIR}:/config \
33-
${MOCKSERVER_DOCKER_IMAGE}
36+
${MOCKSERVER_DOCKER_IMAGE} 2>&1 | tee -a "${logfile}"
37+
38+
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
39+
print "docker run failed; see ${logfile}"
40+
return 1
41+
fi
3442

3543
wait_for_url $AUTH_BACKEND_HTTP_BASEURL/ready
3644
end "mock-auth-backend-http is ready"

selenium/bin/suite_template

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,20 @@ init_suite() {
139139
mkdir -p ${SCREENS}
140140
}
141141

142+
# The mocha-test image is only used when tests run in a container (_test / docker run).
143+
# Local commands (start-rabbitmq, start-others, stop-others, test via npm, etc.) skip the build.
142144
build_mocha_image() {
145+
local need_mocha_docker_image="${1:-yes}"
143146
DOCKER_BUILD_ARGS=""
144147
if [[ -n "$MOCHA_DOCKER_FILE" ]]; then
145148
DOCKER_BUILD_ARGS="-f $MOCHA_DOCKER_FILE "
146149
fi
147150
begin "Ensuring mocha-test image ($DOCKER_BUILD_ARGS) ..."
151+
if [[ "$need_mocha_docker_image" != "yes" ]]; then
152+
print "Skipped. Not required"
153+
end "mocha-test image skipped"
154+
return 0
155+
fi
148156
tag=($(md5sum $SELENIUM_ROOT_FOLDER/package.json))
149157
print "> tag : $tag"
150158
if [[ $(docker images -q mocha-test:$tag 2> /dev/null) == "" ]]; then
@@ -570,7 +578,7 @@ run_local_with() {
570578
init_suite
571579
ensure_docker_network
572580
generate_env_file
573-
build_mocha_image
581+
build_mocha_image no
574582

575583
if [[ "$PROFILES_FOR_OTHER" != "" ]]
576584
then

0 commit comments

Comments
 (0)