Skip to content
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

Add integration tests for InstanceController #504

Merged
merged 6 commits into from
Jul 12, 2019
Merged

Add integration tests for InstanceController #504

merged 6 commits into from
Jul 12, 2019

Conversation

gkleiman
Copy link
Contributor

@gkleiman gkleiman commented Jul 4, 2019

What type of PR is this?

/kind enhancement

What this PR does / why we need it:
This patch adds integration tests for InstanceController, which will enable us to ensure that we don't change the existing behavior when cleaning it up and when working on #422.

Does this PR introduce a user-facing change?:

NONE

Copy link
Contributor

@oliviabarrick oliviabarrick left a comment

Choose a reason for hiding this comment

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

This looks great!

Some thoughts:

  • We should decide on how we want to document our tests. We could do either a README.md in each test case’s directory or comments in the file or something more structured. That is probably a decision for outside of this PR/a KEP, though.
  • I should update the harness to allow merge patching in the updates to make these more DRY.

@alenkacz alenkacz changed the title Add integration tests for InstanceController Add e2e tests for InstanceController Jul 4, 2019
Copy link
Contributor

@alenkacz alenkacz left a comment

Choose a reason for hiding this comment

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

Looks good!

Just one note - I think this should be e2e tests not integration tests. We already have integration tests for controllers and it's different level that this one - it's confusing then.

As much as I like the simplicity of the harness, there are things that worry me. In general I am just worried that all this is not code so it will be real pain to do any kind of refactoring in that :( Like lots of the strings are hardcoded... We'll see :) I am just not a big fan of maintaining a lot of YAML. Also to see what are the steps actually doing you have to read A LOT of yaml across several files. So to get some overview, it's also pretty hard.

@oliviabarrick
Copy link
Contributor

@alenkacz Im definitely all ears on suggestions on how we can improve it.

@oliviabarrick
Copy link
Contributor

Also these are integration tests: https://github.com/kudobuilder/kudo/blob/master/keps/0004-add-testing-infrastructure.md#integration-tests

We could change that on the KEP, but I think the tests you’re talking about are more likely to be unit tests - or just also integration tests.

Copy link
Contributor

@zen-dog zen-dog left a comment

Choose a reason for hiding this comment

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

Nice work. Just had one question about the TestStep

foo: "new value"
---
apiVersion: kudo.k8s.io/v1alpha1
kind: TestStep
Copy link
Contributor

Choose a reason for hiding this comment

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

What's a TestStep? A debug remnant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's Justin's definition of TestStep from the corresponding KEP:

When searching a test step file, if a TestStep object is found, it includes settings to apply to the step. This object is not required - if it is not specified then defaults are used. No more than one TestStep object should be defined in a given test step.

In this case I'm using the TestStep object to make the test harness delete the first deploy PlanExecution.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got ya!

@gkleiman gkleiman changed the title Add e2e tests for InstanceController Add integration tests for InstanceController Jul 5, 2019
@gkleiman
Copy link
Contributor Author

gkleiman commented Jul 5, 2019

Changing the name of the PR back to Add integration tests for InstanceController since the KEP describes integration tests and the tests are under test/integration =).

@zen-dog
Copy link
Contributor

zen-dog commented Jul 5, 2019

As much as I like the simplicity of the harness, there are things that worry me. In general I am just worried that all this is not code so it will be real pain to do any kind of refactoring in that :( Like lots of the strings are hardcoded...

I echo that but I guess we'll see how maintainable that will become. In the meantime, it is somewhat hard to identify/follow what behavior is supposed to be tested. I'm missing something like Scala's Given/When/Then/And:

Given("an an Intance with parameter 'foo' and no 'triggerPlan'")
...
When("the parameter foo is updatet")
...
Then("a default execution plan 'deploy' should be created")
...
And("...something else?")

So maybe we could put these as YAML comments for now? Wdyt @gkleiman , @alenkacz , @justinbarrick ?

@jbarrick-mesosphere
Copy link
Member

@zen-dog yeah, I think YAML comments are the way to go at the moment.

I'm not sure what you're hoping for with the Given/When/Then/And thing, just documentation? We do have these in practice when you define your steps and asserts, it's just a matter of how we want to structure and document them.

@zen-dog
Copy link
Contributor

zen-dog commented Jul 6, 2019

I'm not sure what you're hoping for with the Given/When/Then/And thing, just documentation?

That and better understanding of individual steps and asserts. E.g. here, we have 3 test cases (with custom planTrigger, default and without one) but the only place the intent of the test is visible is through Instance names. Which is better than nothing, but I bet in a few months this won't be so obvious to the reader.

@alenkacz
Copy link
Contributor

alenkacz commented Jul 8, 2019

@justinbarrick I was thinking about it over weekend. I was leaning towards having a 'root' yaml per test case, where you would define steps and maybe some comments. Then if people write that in a meaningful way it would be easier to get a high-level overview of what is that particular test case doing

@jbarrick-mesosphere
Copy link
Member

@alenkacz Agreed! I'll spec something out on the KEP.

@gkleiman
Copy link
Contributor Author

gkleiman commented Jul 9, 2019

@alenkacz , @jbarrick-mesosphere: in the meantime I added some comments to the first step of each test. Let me know whether you like them =).

@gkleiman
Copy link
Contributor Author

@jbarrick-mesosphere I split the upgrade and param change tests out into smaller tests. Please take another look =).

I think it would be nice if we could nest all the upgrade/param-change tests within parent directories to make it obvious that they're related.

@oliviabarrick
Copy link
Contributor

I like the nesting idea a lot, I’ll have to spec that one out too.

@gkleiman gkleiman merged commit e2230a1 into kudobuilder:master Jul 12, 2019
@gkleiman gkleiman deleted the gaston/integration-tests branch July 12, 2019 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants