When a pull request is being committed / merged, we run several test suites to ensure nothing got broken due to the introduced changes. Since these are system level tests, we created an infrastructure which deploys lakeFS on a VM and executes the tests using different clients on various storage adapters.
The following guide explains how to set up and execute the system tests infrastructure in order to optimize the development process, and enable debugging of the tests in a local environment.
A couple of prerequisites before we start:
- Go over our contributing page and make sure you have a working lakeFS environment.
- Docker
- Curl
Before running the tests we need to run a lakeFS instance configured for local execution of system tests
Under esti/scripts you will find the following
- lakefs.yaml
- Contains the lakeFS configuration required for local test execution
- We use local storage type to run the tests
- The data will be stored under the filesystem's /tmp folder (can be configured to any folder with the required permissions)
- runner.sh
- Script to execute lakeFS and tests
- set_env_vars.sh
- Defines and sets all environment variables required for both tests and lakeFS execution
- Adding env vars or modifying existing variables should be done on this file
- Used as a reference for debug env as well (see next)
To run lakeFS for testing simply execute the following command in a shell console:
esti/scripts/runner.sh -r lakefs
The lakeFS server will run in the console and logs will be piped to both stdout and in a temporary file in the form of lakefs_.log
To run all the tests under the system tests folder, execute the following command in a new shell console:
esti/scripts/runner.sh -r test
The tests will run, with the output piped to both stdout and in a temporary file in the form of lakefs_tests_.log
The system test infrastructure allows additional flags and parameters to be passed for execution. For example to run a specific test (by regex) we can use:
esti/scripts/runner.sh -r test -test.run TestHooksSuccess
This command will execute all tests which match the given string regex (in this case it will run a single test by that name)
For a full list of arguments run:
esti/scripts/runner.sh -r test --help
Notes:
- By default, tests are performing lakeFS setup using predefined credentials. As consequence:
- Tests that validate creation of access key id and secret access key will not test this functionality
- This will require stopping and re-running the lakeFS server on each test execution
- To run tests on an already existing lakeFS instance (after initial setup has occurred):
- Modify the ESTI_SETUP_LAKEFS environment variable from 'true' to 'false'
- Use cautiously as some test preconditions will cause tests to fail on existing lakeFS environments
To debug the tests and server code we must create run configurations for both lakeFS and the system tests.
-
From the 'Run' menu select 'Edit Configurations...', then 'Add New Configuration' (the plus sign) and create a new 'go build' configuration
-
Copy the configuration from the following screenshot
- Add basic environment variables from the set_env_vars.sh script's lakeFS section
- Add additional / modify environment variables as needed
-
Create a before launch, external tool to load the postgres docker image
-
Press 'Apply', make sure the configuration is saved (it is not grayed out on the left side menu) and press 'OK'
-
Try to execute the target (either by run / debug) and verify lakeFS server is running
-
From the 'Run' menu select 'Edit Configurations...', and then 'Add New Configuration' (the plus sign) and create a new 'go test' configuration
-
Copy the configuration from the following screenshot
- Add basic environment variables from the set_env_vars.sh script's System tests section
- Add additional / modify environment variables as needed
- To filter tests, you can provide a regular expression in the 'Pattern' text box or alternatively provide the proper command line argument in the 'Prgram arguments' text box
-
Press 'Apply', make sure the configuration is saved (it is not grayed out on the left side menu) and press 'OK'
-
Try to execute the target (either by run / debug) and verify tests are running
Don't know where to start? Experiencing difficulties? Reach out on the #dev channel on our Slack, and we will help you get started.