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

⚠ Bring in testing framework #714

Closed
wants to merge 214 commits into from
Closed

⚠ Bring in testing framework #714

wants to merge 214 commits into from

Conversation

hoegaarden
Copy link
Contributor

@hoegaarden hoegaarden commented Dec 6, 2019

This brings in https://github.com/kubernetes-sigs/testing_frameworks/tree/master/integration (and all it's history) as discussed in #676.

The important commits are:

/assign @DirectXMan12 @mengqiy

totherme and others added 30 commits November 29, 2017 12:08
We use [ginkgo](http://onsi.github.io/ginkgo/) and
[gomega](http://onsi.github.io/gomega/) for testing. We generate some
boilerplate with:
```
mkdir integration
cd integration
ginkgo bootstrap
ginkgo generate integration
```

We use
[gexec](http://onsi.github.io/gomega/#gexec-testing-external-processes)
to compile and run the CLI under test, and to inspect its output.

We use `dep ensure` to ensure that all our dependencies are properly
vendored. From now on, this will be our workflow with every commit.
As a separate commit, to make review easier.
We use [ginkgo](http://onsi.github.io/ginkgo/) and
[gomega](http://onsi.github.io/gomega/) for testing. We generate some
boilerplate with:
```
mkdir integration
cd integration
ginkgo bootstrap
ginkgo generate integration
```

We use
[gexec](http://onsi.github.io/gomega/#gexec-testing-external-processes)
to compile and run the CLI under test, and to inspect its output.

We use `dep ensure` to ensure that all our dependencies are properly
vendored. From now on, this will be our workflow with every commit.
As a separate commit, to make review easier.
To start an apiserver:

```
apiServer := APIServer{Path: "/path/to/my/apiserver/binary"}
session, err := apiServer.Start("tcp://whereever.is.my.etcd:port")
Expect(err).NotTo(HaveOccurred())
```

When you're done testing against that apiserver:

```
session.Terminate().Wait()
```

...or if you prefer:

```
gexec.Terminate()
```

...which will terminate not only this apiserver, but also all other
command sessions you started in this test.
This can be started and stopped the same way as the apiserver.
Create a new set of test fixtures by doing:

```
f := test.NewFixtures("/path/to/etcd", "/path/to/apiserver")
```

Before running your integration tests, start all your fixtures:

```
err := f.Start()
Expect(err).NotTo(HaveOccurred())
```

Now that you have started your etcd and apiserver, you'll find the
apiserver listening locally on the default port. When you're done with
your testing, stop and clean up:

```
err := f.Stop()
Expect(err).NotTo(HaveOccurred())
```
We're using concourse because we happen to have a concourse deployment
available. You can look at it here:

https://wings.concourse.ci/teams/k8s-c10s/
We're not exercising the test framework yet, but it's in place.

Our democli expects its test assets to be in `./assets/bin`. We have a
script `./scripts/download-binaries.sh` which will populate that directory
from a google storage bucket.

Once those assets are in place, you can run tests with
`./scripts/run-tests.sh`.
os.tempDir() gives the path to the temporary directory, it does not
create a random temporary directory.
Using tcp:// does not work.
Testing the lifecycle of our fixtures with the real binaries. Test if we
can start the fixtures, the porcesses actually listen on the ports and
if we tear down all the parts successfully again.
- Store stdout,stderr in private buffers
- Configure the etcURL on construction instead of at start time
- Handle the creation of the temporary directory (for the data
  directory) internally
- Store stdout,stderr in private buffers
- Configure the etcURL on construction instead of at start time
Instead of the separate {Etcd,APIServer}StartStopper use the unified
interface FixtureProcess
We are now returning an error instead of using an Expectation inline.
- Start() should only return when the process is actually up and
  listening
- It may take some time to tear down a process, so we increased the
  timeout for Stop() (to some random number)
- We make sure Std{Out,Err} is properly initialized, we should not rely
  on Ginkgo/Gomega to do that for us
... as they have been unified into the FixtureProcess interface and thus
they are not needed anymore.
We use the standard go client for kubernetes `client-go`. To vendor it
and all its denpendecies we use
```
dep ensure -add k8s.io/client-go@5.0.0
```

We create a new cobra command with
```
cobra add listPods
```
Note: The new command in cmd/listPods.go uses [the "magic" function
init()](https://golang.org/ref/spec#Package_initialization) to register
itself.
As a separate commit, to make review easier.
Performance tests are now skipped by default, but run in CI.
While doing that we found that we needed to refactor the fakes to handle
command line arguments which are not known up front; we do this by using
regular expresseions.
@hoegaarden
Copy link
Contributor Author

hoegaarden commented Dec 7, 2019

See #714 (comment) - not sure why it thinks those commit messages are invalid and added the hold label.

Because the commits' messages say "Closes" and there was a plugin enabled globally (all k8s orgs) more or less recently which does not allow that. Those commits seem to have made it into the original repo, before that plugin was enabled.

And then the CLA bot separately

Yeah, no idea why that is 🤷‍♂️

@DirectXMan12 DirectXMan12 added this to the breaking-next milestone Dec 9, 2019
@DirectXMan12
Copy link
Contributor

CLA problem is on 8c458a4 -- it's missing a GitHub user, according to the CLA bot.

@DirectXMan12
Copy link
Contributor

(GitHub isn't sure what to do with one "Josh Hill" either, so it looks like that's genuinely a problem)

@DirectXMan12
Copy link
Contributor

DirectXMan12 commented Dec 9, 2019

@DirectXMan12
Copy link
Contributor

DirectXMan12 commented Dec 9, 2019

checking with contribex, looks like we'll have to file at ticket with the linuxfoundation. Will keep y'all posted

@hoegaarden
Copy link
Contributor Author

Ok ... So Josh changed companies somewhen after that commit and therefore also changed his email address. I guess the CLA bot is now not able to connect that email address to a github or a linuxfoundation.org user. However it seems he had signed the CLA at some point, the original PR has the cncf-cla: yes label. I would guess that the fact that he changed jobs / emails does not void the accordance of this commit with the CLA. Or does this change when a commit is moved to a different repo?

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: hoegaarden
To complete the pull request process, please assign directxman12
You can assign the PR to them by writing /assign @directxman12 in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@DirectXMan12
Copy link
Contributor

DirectXMan12 commented Dec 10, 2019

It shouldn't void the CLA I think, but CNCF got back to me and (nicely) said "sorry, sucks to be you", so I think we'll need to replace the commit or 👻 force-merge 👻 . Let's get the rest of the issues out of the way (like the commit messages with "Fixes" / "Closes" in them) first.

@hoegaarden
Copy link
Contributor Author

I can do that (rewording the offending commit messages).

However, my approach with using git subtree and other similar methods (mainly with the goal to preserve history) causes other issues, e.g.: After all things have been merged in and integrated, if I do a simple git rebase upstream/master I run into all sorts of merge conflicts. Resolvable, but annoying & to some extend surprising.

I wonder if this will cause more pain in future than necessary and if we should just squash the commits and bring the thing in in one big swoosh commit. That would def. resolve the offending commit messages, might help with the CLA bot (because I'd put all the people of all commits on a Co-authored-by: trailer instead of having them as authors/committers). Obviously, we'd loose the history. Not sure how much we care?

@hoegaarden hoegaarden closed this Jan 6, 2020
@k8s-ci-robot
Copy link
Contributor

Keywords which can automatically close issues and at(@) mentions are not allowed in commit messages.

The list of commits with invalid commit messages:

  • e00770a Add security contacts
  • f9f97cb Better UX for using additional arguments

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jan 6, 2020
@k8s-ci-robot
Copy link
Contributor

@hoegaarden: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-controller-runtime-test d6eb1ac link /test pull-controller-runtime-test

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

DirectXMan12 pushed a commit that referenced this pull request Jan 31, 2020
Fix kustomize go link in quickstart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants