Skip to content
This repository was archived by the owner on Nov 18, 2020. It is now read-only.

test,pkg: add e2e tests #30

Merged
merged 8 commits into from
Aug 27, 2018

Conversation

AlexNPavel
Copy link
Contributor

This is a port of the tests from github.com/coreos/vault-operator that uses the operator-sdk test framework. The original tests are meant to run from within a kubernetes cluster since they need to talk with the vault cluster. Older versions used a port forwarder, but as this is just an example project that will not be actively used/tested, we will not be porting all of that over as that would be require an excessive amount of work. These tests are a good example of how to use the global and namespaced manifests and the tests will correctly create and teardown the vault instances, which is what this example is intended to demonstrate.

Based on github.com/coreos/vault-operator e2e tests

Based on github.com/coreos/vault-operator e2e tests
@hasbro17
Copy link
Contributor

LGTM

@@ -19,4 +19,4 @@
name = "github.com/operator-framework/operator-sdk"
# The version rule is used for a specific release and the master branch for in between releases.
branch = "master"
# version ="v0.0.5"
# version ="v0.0.5"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line?

@@ -62,13 +62,13 @@ func deployEtcdCluster(v *api.VaultService) (*eopapi.EtcdCluster, error) {
}

// etcdNameForVault returns the etcd cluster's name for the given vault's name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

capitalize \\ etcdNameForVault?

@@ -0,0 +1,238 @@
// Copyright 2018 The vault-operator Authors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the point to include the backup_restore_test.go. We need to have S3 for this to work. I am hoping that the test example we have shown here can be run locally. I believe that's what user expect as well.

cc/ @hasbro17

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlexNPavel We can remove backup_restore_test.go. The other basic and scale tests are good enough for example purposes. This test is just getting into the specifics of the vault-operator's reliance on the etcd-operator.

@fanminshi
Copy link
Contributor

fanminshi commented Aug 24, 2018

The original tests are meant to run from within a kubernetes cluster since they need to talk with the vault cluster.
I don't recall why the test is meant to run within a kubernetes cluster. Can someone explain?

Also I am not sure if shaving all the tests from valut-operator e2e to here is a good idea. It is really hard to reason on what happened? Maybe we can just pick one test and port it to using operator-sdk test framework to illustrate how to properly write a production grade e2e test?

@AlexNPavel
Copy link
Contributor Author

@fanminshi The reason we have to run the test within a cluster is that we need the vault api to communicate with the vault pods. To do this outside of kubernetes, we need port forwarding. There used to be port forwarding, but it was really messy and was eventually changed. Now the vault-operator ci tests build an image that gets run from within the cluster to do the testing: https://github.com/coreos/vault-operator/blob/master/hack/ci/run_e2e

If we want to allow these tests to run locally, we could port the port-forwarding functions that used to exist in the vault-operator into this repo. It would be a very large amount of work, and it is a very specific use case for this operator, so it may not make sense to include all of that in a sample project.

In reference to your second comment, we would still need port-forwarding. I agree that removing the backup tests makes sense, but all the other tests are quite simple, standard tests that I think we should keep for example purposes. Maybe we could clean them up a bit, but they are good to keep as examples.

@fanminshi
Copy link
Contributor

@AlexNPavel Yeah, now i remember we use port forwarding to do unseal the vault pod. Just remove the backup and restore test then. Still I think the test example might be too much for reader to digest.

This test is quite complicated and also requires S3 storage. It's
quite specific as well. The other tests are better for example
purposes.
@@ -0,0 +1,56 @@
// Copyright 2018 The vault-operator Authors
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And probably remove this license carried over from the vault-operator.

@AlexNPavel
Copy link
Contributor Author

@fanminshi I agree that these tests are a bit much for an example, but I feel like that's mostly due to how complicated vault itself is. We have to worry about 2 operators, we need to create the cluster, set the up, unseal them, wait for them to become active after that, look at standby nodes, etc. I feel like it would be better to add a different operator as a sample that is in between the complexity of the memcached-operator and vault-operator that would allow us to show how to use the operator-sdk in more complicated scenarios than the memcached operator, but without being as complex and as large as the vault-operator. It looks like the Dex operator being added (#24) may help with this.

@fanminshi
Copy link
Contributor

feel like it would be better to add a different operator as a sample that is in between the complexity of the memcached-operator and vault-operator that would allow us to show how to use the operator-sdk in more complicated scenarios than the memcached operator

I agree with this.

@@ -106,6 +106,19 @@ For example:

`kubectl -n default get vault example ...` -> `kubectl -n default get vaultservice example ...`

## Tests
This repo contains some tests that use the operator-sdk's test framework. These tests are based directly on the original vault-operator
tests, and thus cannot fully complete when run on a local machine and must be run inside a kubernetes cluster instead. This is a very
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you bold this sentence thus cannot fully complete when run on a local machine and must be run inside a kubernetes cluster instead so that the user knows that i can't be run locally.

@fanminshi
Copy link
Contributor

lgtm after nits.

@AlexNPavel AlexNPavel merged commit 628b175 into operator-framework:master Aug 27, 2018
@AlexNPavel AlexNPavel deleted the vault-tests branch August 27, 2018 20:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants