-
Notifications
You must be signed in to change notification settings - Fork 40
e2e test framework #77
Conversation
This won't compile in this directory right now because we have old go get k8s.io/client-go/...
go get -u k8s.io/apimachinery/...
go run main.go |
@kadel @containscafeine initial feedback on this is welcome! |
a841c04
to
755e674
Compare
|
Now since it is using golang test suite so the way to test is to goto e2e folder and run:
|
Very cool @surajssd . Thanks for taking this up proactively. |
Great work @surajssd, just that let's make sure this goes in small incremental PRs which are easier to review. I know this is blocked on updating client-go (:sob:), but yeah, this is for whenever that gets sorted. |
0c34c2d
to
d1e96c9
Compare
66a6ebe
to
7cde2a9
Compare
@cdrage TBH in my workflow I never use I just use: make install and then run kedge commands from wherever possible. Now how do we make sure that people should have binary using |
@surajssd the wordpress ns was failing for me and @surajnarwade the other day, was that fixed? |
@containscafeine I might need to sit with you and get that resolved, because it works for the minikube I have, will have to figure why it fails. |
@surajssd In a lot of projects, there is no
|
@surajssd works after the changes you suggested -
|
done changes! @containscafeine also done changes as you have shown in the diff! |
Works for me :) $ make test-e2e
go test github.com/kedgeproject/kedge/tests/e2e
ok github.com/kedgeproject/kedge/tests/e2e 191.008s |
So obviously not an error, but is there any way to add a time-out to these tests? For example, I ran the tests against a "dirty" minikube instance that had the previous namespaces and it took over 100seconds: github.com/kedgeproject/kedge pr_77 ✔ 12d
▶ make test-e2e
go test github.com/kedgeproject/kedge/tests/e2e
--- FAIL: Test_Integration (0.04s)
--- FAIL: Test_Integration/Normal_Wordpress_test (0.02s)
e2e_test.go:344: error creating namespace: namespaces "wordpress" already exists
--- FAIL: Test_Integration/Testing_extraResources (0.02s)
e2e_test.go:344: error creating namespace: namespaces "extraresources" already exists
--- FAIL: Test_Integration/Testing_health (0.01s)
e2e_test.go:344: error creating namespace: namespaces "health" already exists
--- FAIL: Test_Integration/Testing_customVol (0.00s)
e2e_test.go:344: error creating namespace: namespaces "customvol" already exists
FAIL
FAIL github.com/kedgeproject/kedge/tests/e2e 105.803s
Makefile:60: recipe for target 'test-e2e' failed
make: *** [test-e2e] Error 1 |
Another thing as well, I have no indication on what is being created / made... Can you somehow add some debug messages / info messages? Literally all I get is this:
Which isn't okay to see what tests have passed or not 👎
Another thing too, is there any way to rate-limit how many go routines are being created / what containers are being created? This slows down my computer A LOT and I wouldn't be surprised if this fails on Semaphore / Fabric8. I believe we brought up the discussion in regards to adding a parameter to limit the amount of go routines (using go channels) with a passed in variable, for example: |
@cdrage thanks for the review
It took 100seconds because while some of the tests failed, some other tests were being run which passed. And golang test suite will show output only when tests are completed failed or passed. Since all the tests are run in parallel.
I have added bunch of log messages already, but the problem is with the golang test suite which will output only when all of tests have completed. So you won't see anything when it is in progress, but only after it has failed or passed.
I did not add verbosity to the tests because it is too much of output. Also when tests fail, the output is verbose anyway for the failed test. Like the following test: Simulating an errorsome situation $ kproject.sh wordpress
+ kubectl create ns wordpress
namespace "wordpress" created
+ kubectl config set-context minikube --namespace wordpress
Context "minikube" modified.
$ k get ns
NAME STATUS AGE
default Active 13d
kube-public Active 13d
kube-system Active 13d
wordpress Active 1m
$ make bin
go build -ldflags="-w -X github.com/kedgeproject/kedge/cmd.GITCOMMIT=0266683" -o kedge main.go
$ make test-e2e
go test github.com/kedgeproject/kedge/tests/e2e
--- FAIL: Test_Integration (0.04s)
--- FAIL: Test_Integration/Normal_Wordpress_test (0.01s)
e2e_test.go:344: error creating namespace: namespaces "wordpress" already exists
FAIL
FAIL github.com/kedgeproject/kedge/tests/e2e 117.438s
Makefile:60: recipe for target 'test-e2e' failed
make: *** [test-e2e] Error 1 Above you can see I see only output of failed test. But when you make it verbose for everything then it becomes hard to parse what failed and what passed due to amount of output that is thrown on the stdout. Like see following with verbosity added: $ make test-e2e
go test -v github.com/kedgeproject/kedge/tests/e2e
=== RUN Test_Integration
=== RUN Test_Integration/Testing_configMap
=== RUN Test_Integration/Testing_customVol
=== RUN Test_Integration/Testing_envFrom
=== RUN Test_Integration/Testing_extraResources
=== RUN Test_Integration/Testing_health
=== RUN Test_Integration/Testing_healthChecks
=== RUN Test_Integration/Testing_secret
=== RUN Test_Integration/Testing_single_file
=== RUN Test_Integration/Normal_Wordpress_test
--- FAIL: Test_Integration (0.03s)
--- PASS: Test_Integration/Testing_single_file (31.88s)
e2e_test.go:346: namespace "singlefile" created
e2e_test.go:354: service "database" created
deployment "database" created
[SNIP]
e2e_test.go:183: "wordpress:8080" is running!
e2e_test.go:370: Successfully pinged all endpoints!
e2e_test.go:201: successfully deleted namespace: "singlefile"
--- FAIL: Test_Integration/Normal_Wordpress_test (0.01s)
e2e_test.go:344: error creating namespace: namespaces "wordpress" already exists
--- PASS: Test_Integration/Testing_secret (32.17s)
[SNIP 300 lines]
e2e_test.go:370: Successfully pinged all endpoints!
e2e_test.go:201: successfully deleted namespace: "health"
FAIL
exit status 1
FAIL github.com/kedgeproject/kedge/tests/e2e 87.011s
Makefile:60: recipe for target 'test-e2e' failed
make: *** [test-e2e] Error 1
I have added a verbose flag to the test suite, anyway. So now you will see more output than is there.
Now you rate limit the number of go processes that run in parallel using the same: |
676ac66
to
5a852f5
Compare
@cdrage also added instructions in docs/development.md |
for _, test := range tests { | ||
test := test // capture range variable | ||
t.Run(test.TestName, func(t *testing.T) { | ||
t.Parallel() |
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.
See: https://golang.org/pkg/testing/ with t.Parallel() regardless of what you put as GOMAXPROCS it still runs everything at the same time. Deploying every test to Kubernetes.
Perhaps removing this would help...
Even with me setting the GOMAXPROCS to something lower, I still have every test being deploying at the same time to Kubernetes, which isn't helping.. There should be a limiter to how many tests are ran at a time.
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.
@cdrage I think I know what is confusing you, follow the following steps.
I get this when I run tests:
$ make test-e2e PARALLEL=2
go test -parallel=2 -v github.com/kedgeproject/kedge/tests/e2e
=== RUN Test_Integration
=== RUN Test_Integration/Testing_configMap
=== RUN Test_Integration/Testing_customVol
=== RUN Test_Integration/Testing_envFrom
=== RUN Test_Integration/Testing_extraResources
=== RUN Test_Integration/Testing_health
=== RUN Test_Integration/Testing_healthChecks
=== RUN Test_Integration/Testing_secret
=== RUN Test_Integration/Testing_single_file
=== RUN Test_Integration/Normal_Wordpress_test
...
Above output shows that all of them are running, but
In another window, while above is happening I could see:
$ kubectl get ns -w
NAME STATUS AGE
default Active 14d
kube-public Active 14d
kube-system Active 14d
configmap Active 0s
singlefile Active 0s
configmap Terminating 16s
wordpress Active 0s
configmap Terminating 38s
configmap Terminating 38s
wordpress Terminating 33s
health Active 0s
...
In above output you can see, configmap
and singlefile
were created; then configmap
was done and wordpress
was started and so on. So at anytime only two tests at maximum are running.
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.
Also from docs and help:
$ go test -h
test [build/test flags] [packages] [build/test flags & test binary flags]
In addition to the build flags, the flags handled by 'go test' itself are:
-args
...
-parallel n
Allow parallel execution of test functions that call t.Parallel.
The value of this flag is the maximum number of tests to run
simultaneously; by default, it is set to the value of GOMAXPROCS.
Note that -parallel only applies within a single test binary.
The 'go test' command may run tests for different packages
in parallel as well, according to the setting of the -p flag
(see 'go help build').
...
See my above comment, I don't think we should be running this much in parallel... Even on a beefy machine it slows everything down deploying at the same time. GOMAXPROCS does nothing (i've gone ahead and tested it). |
@cdrage you can have all tests run serially by running |
@surajssd Yup, that'd do it. PARALLEL works. Thanks! I'll do another test. |
AWESOME WORK! LGTM!! Works from my end especially with PARALLEL. Now let's get this up on Semaphore / Fabric8. I'll volunteer (since I've done the stuff on Semaphore previously). |
@surajssd Merge whenever! |
Run e2e tests using: ``` make test-e2e ``` The tests run in parallel so you might want to rate limit on number of tests that run in parallel, you can do that by running following: ``` make test-e2e PARALLEL=2 ``` Above will run only two tests in parallel.
Basic work for e2e test framework
Fixes #59