-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement ramenctl test
command
#33
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Current changes looks good.
ramenctl test run
using ramen/e2e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm, added minor comments.
Should be ready now, testing it... |
Example channel created by the test: % kubectl get channel -A --context hub
NAMESPACE NAME TYPE PATHNAME AGE
e2e-gitops https-github-com-ramendr-ocm-ramen-samples-git github https://github.com/RamenDR/ocm-ramen-samples.git 33s We need a different channel namespace for ramenctl, need to modify the config before we use it. |
Change to "test-gitops". |
Doing another round to make this more robust. |
This is a quick test for using ramen/e2e in ramenctl. We read the config using ramen/e2e/config package and use the configured test and clusters for the fake test. Signed-off-by: Nir Soffer <nsoffer@redhat.com>
For every ramenctl command we need: - A report directory (e.g. "rdr") - A logger logging to command log (e.g. "rdr/test-run.log") - A config loaded from the configuration file - An environment loaded from the config Add a command package providing command.New(), creating a command.Command, keeping everything for a single command. Notes: - We don't validate the config since validation depends on the command. For example the test command need to validate that the clusters in the Env match the configured DRPolicy. Signed-off-by: Nir Soffer <nsoffer@redhat.com>
The test.Commands embeds a command.Command, adapting it for testing. - Add NamespacePrefix that will be used by the test.Context to ensure that application namespaces starts with "test-". - Modify config.Channel.Namesapce to "test-gitops" instead of the default "e2e-gitops". - Keep mapping of pvcspec name to pvcspec, needed to create test from the config. Signed-off-by: Nir Soffer <nsoffer@redhat.com>
The test.Context implements ramen/e2e/test.Context. This is the way to bind all the details needed for a single test. We implement only the test.Context interface so we can use later e2e implementation, and keep the code simple as possible. The ramenctl specific parts will be implemented on top of the context. Unlike ramen/e2e/test.Context, we keep a Command instead of the env and config. This matches the actual model - all tests share the same config and env, which are read-only at the point we use them. Signed-off-by: Nir Soffer <nsoffer@redhat.com>
The test.Test type implement the basic operations for a DR test: - Deploy - Undeploy - Protect - Unprotect - Failover - Relocate We will use it to run a complete DR test flow. The operations log a progress message, call the e2e code implementing the operation, and log a completion message. When a test operation fails the test is failed and cannot continue. We log the error to the test log, and return an error to the caller to signal the failure. The caller must abort the test and report the error to the console. Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Create a test.Test instance from the first test in config.Tests, and run a complete flow similar to ramen/e2e/dr_test flow. Running all tests in parallel will be implemented later. Signed-off-by: Nir Soffer <nsoffer@redhat.com>
For now we add the channel, needed for subscription based tests. In the future we may do more work here as needed. Add setupEnvironment() and cleanEnvironemnt() functions. We don't clean the environment yet, it will be done in the test clean command, which is still a demo. Signed-off-by: Nir Soffer <nsoffer@redhat.com>
ramenctl test run
using ramen/e2eramenctl test
command
This is the same as the run command, but we run only the unprotect and undeploy steps, and clean the environment from test artifacts. This does not remove all test namespaces yet. This should be fixed in ramen/e2e. The clean command logs to `report/test-clean.log`. If we run both `test-run` and `test-clean` with the same output directory, we will get: % tree rdr rdr ├── test-clean.log └── test-run.log Signed-off-by: Nir Soffer <nsoffer@redhat.com>
Implement the actual ramenctl test command using the ramen/e2e module.
Example run:
Example report:
rdr.tar.gz
Example error - I stopped the hub cluster during protect:
Example error report:
error.tar.gz
We can see the error in the log:
Example clean:
Example report with clean log:
rdr.tar.gz
Future work:
Part of #8
Fixes #37
Fixes #23