Custom script for image integration tests
What does this MR do?
-
Make it possible to define a custom Shell script during image integration tests. -
Port job integration tests for GEMNASIUM_DB_REF_NAME
. See go-modules@advisory-db-scan-time-sync-FREEZE branch and its CI config. -
Port job integration tests for offline environments. See original tests/js-npm@offline-FREEZE branch and its CI config.It's not possible to runiptables
because of insufficient privileges, so we have to take a different approach.
For the record, it currently takes about 80 seconds to run all the specs we have in spec/image_spec.rb (130 examples). See image test job.
DockerRunner
Changes to DockerRunner
:
-
run_with_cache
passes all keyword arguments toinitialize
without repeating the default values. -
run_with_cache
uses all arguments and keyword arguments to create a cache without naming them. -
initialize
accepts an optionalcommand
(to overrideCMD [ARG...]
) and an optionalscript
. - If specified, the
script
is saved in the target directory, and executed. In that case thecommand
is simply ignored.
Saving the script
in the target directory is a cheap way to make it accessible in the container.
- Pro: It's really simple, compared to copying the script (docker create, docker cp, docker start, docker rm).
- Con: This is not really clean, and there's a leftover. That said, this leftover make it easy to re-run the contaner manually.
Another option would be to copy the script to a temp directory, and mount it.
command
and script
are mutually exclusive, but this is not explicit. Another approach would be to raise an exception when both are set.
Spec for GEMNASIUM_DB_REF_NAME
The new specs for GEMNASIUM_DB_REF_NAME
are really close to the job integration tests implemented in https://gitlab.com/gitlab-org/security-products/tests/go-modules/-/blob/advisory-db-scan-time-sync-FREEZE. The Shell script that sets up the "local remote" and the expected have been copied with very few modifications.
What are the relevant issue numbers?
gitlab-org/gitlab#333829 (closed)
Does this MR meet the acceptance criteria?
Changelog entry added-
Documentation created/updated for GitLab EE, if necessary -
Documentation created/updated for this project, if necessary -
Documentation reviewed by technical writer or follow-up review issue created -
Tests added for this feature/bug -
Job definition updated, if necessary -
Conforms to the code review guidelines -
Conforms to the Go guidelines -
Security reports checked/validated by reviewer