Fix race condition in test.sh
While working on Support overriding java version using asdf, I came across a failure in the test-custom-ca job:
$ run_test() { # collapsed multi-line command
$ if [ "$RUN_CMD" -eq 1 ]; then run_test run; else echo skipping run; fi
2020/06/05 11:52:00 Get https://ssl-test/: x509: certificate signed by unknown authority
When I ran test.sh
locally, the same failure occurred, however, when I ran the commands individually, the test passed. It turns out this is caused by a race condition because the ssl-test
check relies on the /analyzer
command writing the cacert file to disk. If the ssl-test
command is run before the /analyzer
has a chance to finish writing the file to disk, then the ssl-test
check will fail.
- Failing test (before change): https://gitlab.com/gitlab-org/security-products/tests/custom-ca/-/jobs/583065873
- Successful test (after change): https://gitlab.com/gitlab-org/security-products/tests/custom-ca/-/jobs/583522806
Edited by Adam Cohen