-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Refactor test stages into functions. #2164
Conversation
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.
@josephburnett: 2 warnings.
In response to this:
Proposed Changes
- Refactor autoscale E2E into stages in preparation for adding more tests.
E.g. the next test I will create will be something like:
ctx := setup(t) defer tearDown(ctx) stopChan := DiagnoseMeEvery(15*time.Second, ctx.clients, ctx.logger) defer close(stopChan) assertScaleDown(ctx) bounceController(ctx) assertScaleUp(ctx)
Release Note
NONE
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.
/lint |
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.
@josephburnett: 0 warnings.
In response to this:
/lint
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.
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.
Few comments 👼
logger.Infof("All %d requests succeeded.", totalRequests) | ||
return nil | ||
type testContext struct { | ||
t *testing.T |
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.
Not a huge fan of having testing.T
inside the testContext… Especially as it doesn't seem to be used in the assert
function (doing a logger.Fatal
instead)
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.
I should be doing ctx.t.Fatalf
instead to fail the test.
return nil | ||
} | ||
|
||
func TestAutoscaleUpDownUp(t *testing.T) { |
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.
ctx := setup(t)
stopChan := DiagnoseMeEvery(15*time.Second, ctx.clients, ctx.logger)
defer close(stopChan)
defer tearDown(t, ctx)
assertScaleUp(t, ctx)
assertScaleDown(t, ctx)
assertScaleUp(t, ctx)
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.
I put the defer tearDown
after the setup
in case the DiagnoseMeEvery
call panics.
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.
/approve
test/e2e/autoscale_test.go
Outdated
if err != nil { | ||
return fmt.Errorf("error creating spoofing client: %v", err) | ||
} | ||
// ctx.logger.Infof( /* DO NOT SUBMIT */ "sending request to %v", fmt.Sprintf("http://%s", ctx.domain)) |
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 dead code?
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.
Ack.
test/e2e/autoscale_test.go
Outdated
func setup(t *testing.T, logger *logging.BaseLogger) *test.Clients { | ||
func setup(t *testing.T) *testContext { | ||
//add test case specific name to its own logger | ||
logger := logging.GetContextLogger("TestAutoscaleUpDownUp") |
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.
I believe you meant to use t.Name()
here, instead of the hardcoded test name.
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.
Done.
You have a conflict that needs to be resolved, so my |
Build errors :(
|
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: adrcunha, josephburnett, vdemeester 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 |
Proposed Changes
E.g. the next test I will create will be something like:
Release Note