-
Notifications
You must be signed in to change notification settings - Fork 101
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 integration tests #96
Conversation
c663b12
to
4a2b945
Compare
4a2b945
to
f0d87d0
Compare
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.
We have to install core Crossplane CRD's for the stack managers to be able to run. However, it is likely undesirable to have them actually exist in this repo as I do here. I would support adding the ability to specify remote locations in the CRD paths passed to athodyd.
Would anything discussed in crossplane/crossplane#1085 help with this at all? I agree supporting remote locations (I assume you mean for example HTTP) is preferable to duplicating them in each stack, though we'd still need to play the game of keeping the referenced CRD files aligned with the code level definitions we imported.
How often do we want these to be run initially? I would support once daily using a Jenkins pipeline to start out.
That seems reasonable. It would be nice to allow maintainers to trigger integration tests via Tiller-style commands, but we could add that later. I'd still like to see us running these tests (or a subset thereof) against fake cloud provider APIs for every PR, eventually.
Can we move all examples for each stack to their respective repos? That we we could actually run integration tests using the examples by creating resources from the raw yaml.
I think we should just do this. We'll need to check for and figure out a solution to references to examples from the documentation, though.
limitations under the License. | ||
*/ | ||
|
||
package integration |
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.
Is there an advantage to having a distinct integration test package? Could we instead keep the integration tests closer to the controllers they're testing, and perhaps gate them behind a build tag?
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.
I like this idea! However, I do think we will likely have many of our integration tests span multiple controllers, so we may want a general location as well. For instance, if we wanted to test deploying Wordpress on GCP or something on the more complex side like that (not intending to do so in initial implementation) it would be useful to have something like an e2e
directory.
@negz while sorting out the dependencies for this implementation, I began to think that it may be useful to just include what is currently encompassed and will be implemented in the future in |
I think it makes sense to include athodyd in crossplane-runtime, perhaps under I don't think it's a sure thing that claims will move into crossplane-runtime. They fit better there than in crossplane core, but I'm not yet convinced they don't belong in a separate API package. |
@negz sounds good! I'll open a PR to add current work in athodyd to |
f0d87d0
to
192d246
Compare
cc6a748
to
df1e7ec
Compare
bd46ff0
to
a805f08
Compare
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
a805f08
to
b5ec4b4
Compare
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.
@negz @jbw976 I think this is ready. For the time being, we are utilizing a long-running cluster and the tests are only run ad-hoc via user invocation on Jenkins. While it is desirable to spin up net new clusters for integration tests in the future (probably using Crossplane), we can continue to build out the tests in the actual repos while that system is being designed, then switch over when ready without having to rewrite.
cfg, err := clientcmd.BuildConfigFromFlags("", "../../kubeconfig.yaml") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if err := os.Setenv("GOOGLE_APPLICATION_CREDENTIALS", "../../sa.json"); err != nil { |
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.
Note: we look for these specific files that Jenkins drops into the project directory. Falling back on local kubeconfig
was discussed but given that these test could eventually spin up new infrastructure, I actually like that a specific file path is hard coded.
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.
@hasheddan I'm not sure how I feel about these integration tests being defined so separately from the code they're testing. That said, I'm conscious that this PR has been open a long time so I'd feel comfortable merging it and then assessing whether we should refactor it a little later.
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ |
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.
Should we use a build tag to ensure these tests are not run by folks attempting to run unit tests?
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.
Yes, great point! I will add that. Another safe-guard here is the way that the k8s client is configured: you have to literally drop a kubeconfig.yaml
into the project dir, it will not just use your local configuration automatically.
"CreateProvider": { | ||
reason: "A GCP Provider should be created without error.", | ||
test: func(c client.Client) error { | ||
dat, err := ioutil.ReadFile("../../examples/gcp-provider.yaml") |
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.
I like that we're testing our examples, but I'm a little worried that it might not be obvious to folks that these examples are tied to the integration tests. Is there something we could do to bring them closer together? How will we know which examples are used by integration tests and which are just examples?
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.
Ideally we would always validate all examples in our integration tests. Therefore, if someone makes a change to examples/
then integration tests should also be updated. If we need to enforce this in the PR process that could be an option to make sure we do not get out of sync.
return c.Create(context.Background(), p) | ||
}, | ||
}, | ||
"CreateBucketClass": { |
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.
What is the thinking around having one integration test that creates all extant resource class kinds, vs having an integration test alongside each of the existing unit tests? Would it be better if we tested code closer to where it was defined, like Go unit tests do?
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.
This create_classes_test.go
is a bit of a one-off. I think that most tests will not necessarily make sense to be next to a specific piece of code like unit tests. For example, I have a local test that creates a Provider
, GKECluster
, CloudSQLInstance
, KubernetesCluster
claim, MySQLInstance
claim, and a KubernetesApplication
. I don't think there is a specific set of code that it should be associated with.
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
@negz updated with build tags, I want to manually execute Jenkins pipeline again before merge though |
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
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.
@negz integration testing pipeline executed successfully: https://jenkinsci.upbound.io/blue/organizations/jenkins/crossplaneio%2Fstack-gcp-pipelines%2Fstack-gcp-integration/detail/PR-96/18/pipeline
limitations under the License. | ||
*/ | ||
|
||
package integration |
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.
Adding this doc.go
was required for the generate
target to run successfully.
Hi @hasheddan, |
Description of your changes
Initial implementation of basic integration tests that simply install CRDs, start the stack controller, and create instances of the classes defined in
examples/
Checklist
I have:
make reviewable
to ensure this PR is ready for review.app.yaml
to include any new role permissions.