-
Notifications
You must be signed in to change notification settings - Fork 244
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
Clean e2e test example #1535
Clean e2e test example #1535
Conversation
ping @amitkrout @girishramnani |
@kadel Thanks for the pr in a quick time. Tomorrow will have a look |
great thinking of using the latest version of ginkgo 👍 |
|
||
// and returns the stdout, stderr and exitcode | ||
func cmdRunner(cmdS string) (string, string, int) { | ||
//TODO: this needs to be os independent |
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.
lets document this in an issue so that @amitkrout can work on making this os independent
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.
@girishramnani We have issue for it #1131
I am not seeing any helpers related to |
tests/e2e/cleantest_test.go
Outdated
helper.Chdir(originalDir) | ||
} | ||
if originalProject != "" { | ||
helper.OcSwitchProject(originalProject) |
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.
Could this not cause an overlap? if oc active project is depended on. What happens if one of the parallel runs gets here first and sets a different active project, while another is working with a different project (in a single cluster context)
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.
good point.
It looks like we could use SynchronizedBeforeSuite
and SynchronizedAfterSuite
https://onsi.github.io/ginkgo/#managing-singleton-external-processes-in-parallel-test-suites
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.
Fixed by removing those function all together, as I realized that there is a better way to do this
- package: github.com/onsi/ginkgo | ||
version: v1.4.0 | ||
version: v1.8.0 |
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.
+1
|
||
// CreateRandProject create new project with random name (10 letters) | ||
// without writing to the config file (without switching project) | ||
func OcCreateRandProject() string { |
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.
+1
@@ -44,11 +44,11 @@ func TestOdo(t *testing.T) { | |||
RunSpecs(t, "odo test suite") |
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.
Remove the suite function in a separate file to isolate it form the actual test
For example:
Create a file odo_suite_test.go
package e2e
import (
"testing"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
func TestOdo(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "odo test suite")
}
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 PR is intended to provide just a clean direction and template how we can structure our tests.
This should be part of a cleanup effort in a separate PR.
@girishramnani I think its just a templates for our reference to write the test. Those functions are in utils can be moved under helper package in the subsequent improvement of this pr template. |
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.
It make more sense if you rename file name as template_cleantest_test.go
.
Test went fine locally and the interesting part is that with four node parallel execution the total run time reduces to half compare to serial execution of the same template. Test structure looks good to me. |
/retest |
tests/e2e/cleantest_test.go
Outdated
Expect(err).NotTo(HaveOccurred()) | ||
|
||
originalProject = helper.OcCurrentProject() | ||
}) |
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.
If these will be ran for each and every test, would it make sense to try to put as much information as possible into the utility functions / helper files?
@kadel Rebase and fix the formatting issue
|
64cd127
to
a99ec11
Compare
ping @amitkrout @girishramnani |
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.
Test structure is quite impressive. Tested the template locally without any issue. @girishramnani We need to push this pr ASAP.
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: amitkrout The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
1 similar comment
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: amitkrout The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
This is an example of how to write e2e tests using ginkgo that perform automatic setup and teardown.
To run this do
-ginkgo.randomizeAllSpecs
runs all test in random order. This will make sure that we don't create dependencies between tests specs (It(
functions) even accidntaly, as the order of in which tests are run can't be prediceted.You can also run tests in parallel:
nodes
sets number of parallel executionsNote that you have to use
ginkgo
(go get github.com/onsi/ginkgo/ginkgo
than$GOPATH/bin/ginkgo
) to tests in parallelI had to updated Ginkgo as the version that we were using doesn't support
JustAfterEach