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

End-to-end Tests #50

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

End-to-end Tests #50

wants to merge 16 commits into from

Conversation

jdharmon
Copy link
Contributor

@jdharmon jdharmon commented Mar 8, 2020

I refactored the project structure, and enabled NewReaper() to take a filename for kubeconfig. I then created an e2e test that will

  1. bring up a KinD cluster,
  2. run pod-reaper for 1s, and
  3. destroy the KinD cluster

I also updated k8s.io dependencies to v0.17.0 and Go version 1.13 (needed for KinD).

To run, you'll need Go v1.13. Then run

GO111MODULE="on" go get sigs.k8s.io/kind@v0.7.0
make test-e2e

From here it should be relatively easy to add additional e2e tests. For #43, the kubeconfig file location could be read from an environment variable or the command line, which would enable you to run and debug against a local cluster.

@brianberzins
Copy link
Collaborator

I'm going to have to check this one out in a lot of detail based on how my local development environment didn't like this.

First thing I noticed is that reaper "package" (which I was probably using incorrectly) looks like it was removed? I'm guessing that this was separated out in your environment?

@jdharmon
Copy link
Contributor Author

jdharmon commented Mar 9, 2020

I did move things around based on Standard Go Project Layout.

  • main moved from /reaper to /cmd/pod-reaper
  • rules moved from /rules to /internal/pkg/rules

I initially planned to factor out the Clientset dependency into a client package so that I could inject it into Reaper from the test. I realized after the fact that it wasn't necessary for e2e tests. It would make unit testing Reaper possible, but that wasn't the goal of this PR.

@jdharmon
Copy link
Contributor Author

jdharmon commented Mar 9, 2020

I just looked, and realized /cmd didn't get committed. Sorry. Will fix it tonight.

@jdharmon
Copy link
Contributor Author

You could run without make.

./test/create-cluster.sh e2e
./test/run-e2e-tests.sh

@brianberzins
Copy link
Collaborator

got a little time to look at this, and things are working MUCH better in my local environment now. Honestly, I was expecting there to be something deep wrong with my outside-docker setup, but right now I've got an end-to-end feedback loop going.

@jdharmon
Copy link
Contributor Author

I added tests for chaos, unready, and duration rules. I chose to implement them outside of a container as it provides more control and gives the option of debugging. There might be a better way to verify the chaos rule, but using CHAOS_CHANCE=1 was the only way I could get repeatable results.

There probably should be at least one test that runs pod-reaper in a container to test the in-cluster config.

@brianberzins
Copy link
Collaborator

currently trying to figure out why this isn't working in my local environment - docker build . fails with:

...
 ---> Running in 2300071fdad4
vendor/github.com/Azure/go-autorest/autorest/adal/token.go:39:2: cannot find package "github.com/form3tech-oss/jwt-go" in any of:
	/go/src/github.com/target/pod-reaper/vendor/github.com/form3tech-oss/jwt-go (vendor tree)
	/usr/local/go/src/github.com/form3tech-oss/jwt-go (from $GOROOT)
	/go/src/github.com/form3tech-oss/jwt-go (from $GOPATH)
The command '/bin/sh -c go test $(glide nv | grep -v /test/)' returned a non-zero code: 1

which strikes me as got for a couple reasons. troubleshooting now

@jdharmon
Copy link
Contributor Author

I didn't see that the Dockerfile was changed in master. I will update and push a fix.

@jdharmon
Copy link
Contributor Author

@brianberzins Make sure you pull the latest from STIHLDev:e2e. It looks like you're still using glide for dependencies.

@brianberzins
Copy link
Collaborator

uhg... that's almost certainly my bad...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants