Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
183164582 Test mysql using containers (#717)
* Experiment running system-tests for mysql inside containers [#183164582] Signed-off-by: Fernando Naranjo <fnaranjo@vmware.com> * Build database-backup-restore and fix echo commands [#183164582] Also replace some additional commands performed on BOSH VM * Ensure we invoke `bash -c` for every `go.Command` [#183164582] Running os commands using goexec is not identical to running those commands in a shell such as bash. Some examples of known things to require a bash shell: - Pipes - Redirects Signed-off-by: Fernando Naranjo <fnaranjo@vmware.com> * Create workflow to run MySQL tests on PRs [#183164582] Signed-off-by: Fernando Naranjo <fnaranjo@vmware.com> * Generate TLS certificates and shared them across containers [#183164582] Mysql service is the one in charge of creating the certificates. To make these generated certificates available to the container running the tests we use a shared volume named `mysql-certs` which we mount in both containers. * Support testing several MYSQL versions using GHAction matrix [#183164582] For this we need to pass the MYSQL version we want to test as a Docker build arg * Remove from matrix failing unsupported versions of MYSQL [#183164582] There are chances that the versions removed could also work with our current release but they need some packages not included by default in the Dockerimage. Doing the extra effort to make the pass is irrelevant to the BOSH release itself, since the filesystem is not identical to what will be included in the VM. We might need to investigate how to reduce this filesystem mismatch if possible. Signed-off-by: Fernando Naranjo <fnaranjo@vmware.com> * WIP try to improve some docs-type things [#183164582] Signed-off-by: Gareth Smith <sgareth@vmware.com> * Remove unneded folder intialization steps [#183164582] They seem to have inconsistent behaviour on different operating systems * Restore folder initialization and add it to system-mysql Dockerfile too [#183164582] * Print database logs in case of test failures [#183164582] * Reorganize VOLUME declarations to overcome a possible bug in Docker [#183164582] docker/compose#3270 (comment) * Replace chmod with chown to better express the intent of the operation [#183164582] * Revert "Replace chmod with chown to better express the intent of the operation" This reverts commit e102885. It seems `chmod root:root` counteracts `chmod mysql:mysql` causing a race condition between the two containers. It seems we are better off using `chmod 777` here. * Improve debugging experience by mounting the whole repo instead of a subfolder [#183164582] By doing this any error message in the logs would point to the exact path where the problem occurred instead of a docker-mounted path in an arbitrary location. This change pursues reducing the knowledge burden introduced by the use of Docker by trying to make the Docker integration as thin and transparent as possible. Ideally, not requiring any Docker knowledge to be able to work with the codebase. * Improve unit-tests debug experience by mounting full repo instead of subfolder [#183164582] By doing this any error message in the logs would point to the exact path where the problem occurred instead of a docker-mounted path in an arbitrary location. This change pursues reducing the knowledge burden introduced by the use of Docker by trying to make the Docker integration as thin and transparent as possible. Ideally, not requiring any Docker knowledge to be able to work with the codebase. * Refactor system-db-tests to use a similar approach to unit-tests [#183164582] Some goals of this refactor were: - Don't have an explicit ENTRYPOINT in Dockerfile, specify it in docker-compose - Move most of the boilerplate required by the tests to the tests folder - Remove hardcoded paths in boilerplate environment variables required by tests - Make scripts/run-system-db-tests-mysqsl more self-container and self-documenting - Flatten the path to start adding tests for other databases such as Postgres - Flatten the path to add some tests for testing the version detection logic * Simplify TestRunner.Dockerfile and `backup`/`restore` invocations [#183164582] Original tests made use of two auxiliary scripts `backup`/`restore` to set the required environment variables every time they were used. Since these variables are static and never change we added these vars to the `run-system-db-tests-mysql.bash` script itself and invoke the `database-backup-restore` binary directly instead from the tests. * Reduce certs handling in `Dockerfile` and `docker-compose.yml` [#183164582] By aglutinating the three previous variables each one pointing to a different certificate into a single variable pointing to a folder we should contain the three files. These files are expected to always be named the same so there isn't a need to specify the full path for each of them individually. * Fix errors introduced in latest commit [#183164582] Some of the environment variables which previously we thought were not needed explicitly by the tests were in fact required for mysql to successfully establish a connection using TLS certificates. * Add MySQL5.7 binary as it is used to determine version of db [#183164582] By looking at the source-code we determined that mysql5.7 binary is used to connect with the mysql database and ask for its version. Only later, the corresponding binary will be choosed and used. Signed-off-by: Fernando Naranjo <fnaranjo@vmware.com> * Add tests for different versions of MariaDB [#183164582] In this case we didn't copy the binary from the mariadb Docker image because it had unsatisfied dependencies (such as libssl3) * Trigger PR workflows * Show database logs on error to facilitate debugging [#183164582] * Workaround permission issues when specifying Volume in Dockerfile [#183164582] * Try triggering tests again [#183164582] * Use chmod 777 both in TestsRunner and BackingDB Dockerfiles [#183164582] * Fix mysql5.7-debian tests and make mysql tests more precise [#183164582] Since bbr-sdk-release always uses 5.7 at least once (to query the db version) we always need to specify MYSQL_CLIENT_5_7_PATH. Since we are using GitHub matrixes to tests several MySQL versions using the same scripts, it seems difficult to use the MYSQL_VERSION variable to download only the required binaries since we will need some conditional logic to populate the right ENV variables. For that reason this commit simply downloads the latest MySQL 8.0 and MySQL 5.7 binaries and populates the corresponding ENV variables every time, without caring which specific MYSQL_VERSION we are currently testing. * Add Postgres system tests [#183164582] * Fix typo in Postgres system tests workflow [#183164582] * Test compilation against diff stemcells and improve system tests [#183164582] To test compilation against diff stemcells we use multistage Docker containers to download bosh-lite warden tarballs and using the rootfs included in the tarball to create a container FROM scratch. Inside that dockerized stemcell we run the release packaging scripts which allows testing compilation against different stemcell using GHActions matrix strategies. Now that we are able to compile the release directly in GHActions, we can improve system tests by leveraging the binaries built on-the-fly from the blobs. This approach has huge benefits compared to the previous one: - Tests are more true to reality - Bosh blobs are fully tested (instead of testing just the GO code) - Compilation is being tested against different stemcells * Use `backup` and `restore` scripts from the /var/vcap/jobs folder [#183164582] Also, compiled database-backup-restorer using its packaging script instead of manually running golang during the `run-system-db-tests` scripts and refactored tests to use the binary located in /var/vcap/packages * Reduce verbosity of the logs [#183164582] * Add ubuntu-xenial tests except for MySQL 8.0 which is unsupported [#183164582] * Run postgres_tls and postgres_mutual_tls test suites in containers [#183164582] Signed-off-by: Fernando Naranjo <fnaranjo@vmware.com> * Fix Postgres TLS and MUTUAL_TLS test suites [#183164582] * Ensure system-db-postgres-backing-db database gets cleaned up after each job [#183164582] * Fix ENABLE_TLS var not being passed to docker-compose run commands [#183164582] All tests were running the basic Postgres tests instead of TLS and MUTUAL * Run dockerize-release as a separate step from the tests [#183164582] This change will help us differentiate how much time is spent in the actual tests versus compiling the release itself. This should serve as a first step towards optimizing builds * Prevent running Postgres TLS and MTLS tests for 9.4-alpine [#183164582] postgres:9.4-alpine doesn't have openssl package installed by default which causes the database to error before start and prevents tests from running. Testing Postgres 9.4 without TLS/MTLS should be enough for now to ensure this version is supported. Patching postgres Dockerfile to add openssl is possible but might no be needed or desirable since Postgres 9.4 reached EOGS in February 2020 * Disable 9.4-alpine for Mutual TLS not normal tests [#183164582] * Move dockerfiles from .github/actions to ci/ [#183164582] Signed-off-by: Diego Lemos <dlemos@vmware.com> * Restore tests and guard new BOSH-less functionality under a flag [#183164582] * Redirect stderr to stdout when running with flag RUN_TESTS_WITHOUT_BOSH [#183164582] The tests expected error messages to be available in stdout. Probably because when running the commands by SSHing into a BOSH VM the errors are retreived from Stdout Signed-off-by: Fernando Naranjo <fnaranjo@vmware.com> Signed-off-by: Gareth Smith <sgareth@vmware.com> Signed-off-by: Diego Lemos <dlemos@vmware.com> Co-authored-by: Gareth Smith <sgareth@vmware.com> Co-authored-by: Diego Lemos <dlemos@vmware.com> Co-authored-by: Cryogenics CI Bot <mapbu-cryogenics@groups.vmware.com>
- Loading branch information