-
Notifications
You must be signed in to change notification settings - Fork 223
Bug 2080379: Group all e2e tests as parallel or serial #756
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
Changes from all commits
a777e53
a22322b
7dd007f
a72396a
b703018
42880c4
cc23d9b
a449e49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # This script verifies that all the e2e tests defined in package | ||
| # test/e2e have a corresponding invocation in the TestAll function | ||
| # defined in test/e2e/all_test.go. | ||
| # | ||
| # The TestAll function provides ordering of all e2e tests. Tests that | ||
| # can be run in parallel are invoked first and will run to completion | ||
| # before starting those that must run serially. | ||
| # | ||
| # The CI job runs `make verify` before starting the e2e tests and the | ||
| # verify target will run this script. If this script detects any Go | ||
| # Test function by name that is not invoked by the TestAll function | ||
| # then it will list the omission and exit with an error, preventing | ||
| # the e2e tests from starting. | ||
|
|
||
| # This script has been tested on Linux and macOS. | ||
|
|
||
| set -u | ||
| set -o pipefail | ||
|
|
||
| thisdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" | ||
| e2e_test_dir="$thisdir/../test/e2e" | ||
| e2e_test_file="$e2e_test_dir/all_test.go" | ||
|
|
||
| if ! [[ -f ${e2e_test_file} ]]; then | ||
| echo "error: $e2e_test_file is missing." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # "go test -list" must run in the directory where the test files are. | ||
| pushd "$e2e_test_dir" >/dev/null || { | ||
| echo "error: pushd $e2e_test_dir failed" >&2; | ||
| exit 2 # ENOENT | ||
| } | ||
|
|
||
| go_test_list_output=$(E2E_TEST_MAIN_SKIP_SETUP=1 go test -list . -tags e2e) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to add a "list-e2e-tests" target? Doing so would have two advantages:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More than the following? .PHONY: test-e2e-list
test-e2e-list:
@(cd ./test/e2e; E2E_TEST_MAIN_SKIP_SETUP=1 $(GO) test -list . -tags e2e | grep ^Test)$ /bin/bash -c 'time make test-e2e-list'
TestAll
TestCanaryRoute
TestCreateIngressControllerThenSecret
TestCreateSecretThenIngressController
TestHealthCheckIntervalIngressController
TestClientTLS
TestConfigurableRouteRBAC
TestConfigurableRouteNoSecretNoRBAC
TestConfigurableRouteNoConsumingUserNoRBAC
TestIngressStatus
TestForwardedHeaderPolicyAppend
TestForwardedHeaderPolicyReplace
TestForwardedHeaderPolicyNever
TestForwardedHeaderPolicyIfNone
TestHAProxyTimeouts
TestHAProxyTimeoutsRejection
TestRouteHardStopAfterEnableOnIngressConfig
TestRouteHardStopAfterEnableOnIngressController
TestRouteHardStopAfterEnableOnIngressControllerHasPriorityOverIngressConfig
TestRouteHardStopAfterTestInvalidDuration
TestRouteHardStopAfterTestZeroLengthDuration
TestRouteHardStopAfterTestOneDayDuration
TestHstsPolicyWorks
TestRouteHTTP2EnableAndDisableIngressController
TestRouteHTTP2EnableAndDisableIngressConfig
TestHTTPHeaderBufferSize
TestHeaderNameCaseAdjustment
TestTunableMaxConnectionsValidValues
TestTunableMaxConnectionsInvalidValues
TestRouteNbthreadIngressController
TestOperatorSteadyConditions
TestClusterOperatorStatusRelatedObjects
TestDefaultIngressControllerSteadyConditions
TestDefaultIngressClass
TestCustomIngressClass
TestUserDefinedIngressController
TestUniqueDomainRejection
TestProxyProtocolOnAWS
TestProxyProtocolAPI
TestUpdateDefaultIngressController
TestIngressControllerScale
TestDefaultIngressCertificate
TestPodDisruptionBudgetExists
TestHostNetworkEndpointPublishingStrategy
TestHostNetworkPortBinding
TestInternalLoadBalancer
TestInternalLoadBalancerGlobalAccessGCP
TestScopeChange
TestNodePortServiceEndpointPublishingStrategy
TestTLSSecurityProfile
TestRouteAdmissionPolicy
TestSyslogLogging
TestContainerLogging
TestIngressControllerCustomEndpoints
TestHTTPHeaderCapture
TestHTTPCookieCapture
TestNetworkLoadBalancer
TestUniqueIdHeader
TestLoadBalancingAlgorithmUnsupportedConfigOverride
TestDynamicConfigManagerUnsupportedConfigOverride
TestLocalWithFallbackOverrideForLoadBalancerService
TestLocalWithFallbackOverrideForNodePortService
TestReloadIntervalUnsupportedConfigOverride
TestCustomErrorpages
TestTunableRouterKubeletProbesForCustomIngressController
TestIngressControllerServiceNameCollision
TestRouterCompressionParsing
TestRouterCompressionOperation
real 0m1.594s
user 0m2.014s
sys 0m0.731s
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in 5e93c23.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The point was that you could use |
||
| go_test_list_status=$? | ||
|
|
||
| if [[ $go_test_list_status -ne 0 ]]; then | ||
| echo "error: go test -list failed" >&2 | ||
| echo "$go_test_list_output" >&2 | ||
| exit $go_test_list_status | ||
| fi | ||
|
|
||
| popd >/dev/null || { | ||
| echo "error: popd failed" >&2; | ||
| exit 1 | ||
| } | ||
|
|
||
| errors=0 | ||
|
|
||
| for i in $go_test_list_output; do | ||
| if ! [[ $i =~ ^Test ]] || [[ $i == "TestAll" ]]; then | ||
| continue | ||
| fi | ||
| pattern="^ \+t\.Run(\"$i\", $i)$" # ^multiple<TAB>s. | ||
| if ! grep -q -e "$pattern" -- "$e2e_test_file"; then | ||
| echo "error: test function '$i' not called by 'TestAll' in $e2e_test_file" >&2 | ||
| errors=1 | ||
| fi | ||
| done | ||
|
|
||
| exit $errors | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| //go:build e2e | ||
| // +build e2e | ||
|
|
||
| package e2e | ||
|
|
||
| import "testing" | ||
|
|
||
| // TestAll is the entrypoint for `make test-e2e` unless you override | ||
| // with: make TEST=Test<foo> test-e2e. | ||
| // | ||
| // The overriding goal of this test is to run as many tests in | ||
| // parallel as possible before running those tests that must run serially. There | ||
| // are two goals: 1) cut down on test execution time and 2) provide | ||
| // explicit ordering for tests that do not expect a rolling update of | ||
| // ingresscontroller pods because a previous test modified the | ||
| // ingressconfig object and the defer logic for cleanup is still | ||
| // runnng when the new test starts. | ||
| func TestAll(t *testing.T) { | ||
| // This call to Run() will not return until all of its | ||
| // parallel subtests complete. Each "parallel" test must | ||
| // invoke t.Parallel(). | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nothing verifies this, right? As a follow-up, we could add some logic in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, not verified. I did start on doing this but that effort is incomplete. I aborted the effort when I ran into #756 (comment). |
||
| t.Run("parallel", func(t *testing.T) { | ||
| t.Run("TestAWSELBConnectionIdleTimeout", TestAWSELBConnectionIdleTimeout) | ||
| t.Run("TestClientTLS", TestClientTLS) | ||
| t.Run("TestContainerLogging", TestContainerLogging) | ||
| t.Run("TestCreateIngressControllerThenSecret", TestCreateIngressControllerThenSecret) | ||
| t.Run("TestCreateSecretThenIngressController", TestCreateSecretThenIngressController) | ||
| t.Run("TestCustomErrorpages", TestCustomErrorpages) | ||
| t.Run("TestCustomIngressClass", TestCustomIngressClass) | ||
| t.Run("TestDynamicConfigManagerUnsupportedConfigOverride", TestDynamicConfigManagerUnsupportedConfigOverride) | ||
| t.Run("TestForwardedHeaderPolicyAppend", TestForwardedHeaderPolicyAppend) | ||
| t.Run("TestForwardedHeaderPolicyIfNone", TestForwardedHeaderPolicyIfNone) | ||
| t.Run("TestForwardedHeaderPolicyNever", TestForwardedHeaderPolicyNever) | ||
| t.Run("TestForwardedHeaderPolicyReplace", TestForwardedHeaderPolicyReplace) | ||
| t.Run("TestHAProxyTimeouts", TestHAProxyTimeouts) | ||
| t.Run("TestHAProxyTimeoutsRejection", TestHAProxyTimeoutsRejection) | ||
| t.Run("TestHTTPCookieCapture", TestHTTPCookieCapture) | ||
| t.Run("TestHTTPHeaderBufferSize", TestHTTPHeaderBufferSize) | ||
| t.Run("TestHTTPHeaderCapture", TestHTTPHeaderCapture) | ||
| t.Run("TestHeaderNameCaseAdjustment", TestHeaderNameCaseAdjustment) | ||
| t.Run("TestHealthCheckIntervalIngressController", TestHealthCheckIntervalIngressController) | ||
| t.Run("TestHostNetworkEndpointPublishingStrategy", TestHostNetworkEndpointPublishingStrategy) | ||
| t.Run("TestIngressControllerScale", TestIngressControllerScale) | ||
| t.Run("TestIngressControllerServiceNameCollision", TestIngressControllerServiceNameCollision) | ||
| t.Run("TestInternalLoadBalancer", TestInternalLoadBalancer) | ||
| t.Run("TestInternalLoadBalancerGlobalAccessGCP", TestInternalLoadBalancerGlobalAccessGCP) | ||
| t.Run("TestLoadBalancingAlgorithmUnsupportedConfigOverride", TestLoadBalancingAlgorithmUnsupportedConfigOverride) | ||
| t.Run("TestLocalWithFallbackOverrideForNodePortService", TestLocalWithFallbackOverrideForNodePortService) | ||
| t.Run("TestNetworkLoadBalancer", TestNetworkLoadBalancer) | ||
| t.Run("TestNodePortServiceEndpointPublishingStrategy", TestNodePortServiceEndpointPublishingStrategy) | ||
| t.Run("TestProxyProtocolAPI", TestProxyProtocolAPI) | ||
| t.Run("TestReloadIntervalUnsupportedConfigOverride", TestReloadIntervalUnsupportedConfigOverride) | ||
| t.Run("TestRouteAdmissionPolicy", TestRouteAdmissionPolicy) | ||
| t.Run("TestRouterCompressionParsing", TestRouterCompressionParsing) | ||
| t.Run("TestScopeChange", TestScopeChange) | ||
| t.Run("TestSyslogLogging", TestSyslogLogging) | ||
| t.Run("TestTLSSecurityProfile", TestTLSSecurityProfile) | ||
| t.Run("TestTunableMaxConnectionsInvalidValues", TestTunableMaxConnectionsInvalidValues) | ||
| t.Run("TestTunableMaxConnectionsValidValues", TestTunableMaxConnectionsValidValues) | ||
| t.Run("TestTunableRouterKubeletProbesForCustomIngressController", TestTunableRouterKubeletProbesForCustomIngressController) | ||
| t.Run("TestUniqueDomainRejection", TestUniqueDomainRejection) | ||
| t.Run("TestUniqueIdHeader", TestUniqueIdHeader) | ||
| t.Run("TestUserDefinedIngressController", TestUserDefinedIngressController) | ||
| }) | ||
|
|
||
| t.Run("serial", func(t *testing.T) { | ||
| t.Run("TestDefaultIngressControllerSteadyConditions", TestDefaultIngressControllerSteadyConditions) | ||
| t.Run("TestClusterOperatorStatusRelatedObjects", TestClusterOperatorStatusRelatedObjects) | ||
| t.Run("TestConfigurableRouteNoConsumingUserNoRBAC", TestConfigurableRouteNoConsumingUserNoRBAC) | ||
| t.Run("TestConfigurableRouteNoSecretNoRBAC", TestConfigurableRouteNoSecretNoRBAC) | ||
| t.Run("TestConfigurableRouteRBAC", TestConfigurableRouteRBAC) | ||
| t.Run("TestDefaultIngressCertificate", TestDefaultIngressCertificate) | ||
| t.Run("TestDefaultIngressClass", TestDefaultIngressClass) | ||
| t.Run("TestHstsPolicyWorks", TestHstsPolicyWorks) | ||
| t.Run("TestIngressControllerCustomEndpoints", TestIngressControllerCustomEndpoints) | ||
| t.Run("TestIngressStatus", TestIngressStatus) | ||
| t.Run("TestLocalWithFallbackOverrideForLoadBalancerService", TestLocalWithFallbackOverrideForLoadBalancerService) | ||
| t.Run("TestOperatorSteadyConditions", TestOperatorSteadyConditions) | ||
| t.Run("TestPodDisruptionBudgetExists", TestPodDisruptionBudgetExists) | ||
| t.Run("TestProxyProtocolOnAWS", TestProxyProtocolOnAWS) | ||
| t.Run("TestRouteHTTP2EnableAndDisableIngressController", TestRouteHTTP2EnableAndDisableIngressController) | ||
| t.Run("TestRouteHardStopAfterEnableOnIngressController", TestRouteHardStopAfterEnableOnIngressController) | ||
| t.Run("TestRouteHardStopAfterTestInvalidDuration", TestRouteHardStopAfterTestInvalidDuration) | ||
| t.Run("TestRouteHardStopAfterTestOneDayDuration", TestRouteHardStopAfterTestOneDayDuration) | ||
| t.Run("TestRouteHardStopAfterTestZeroLengthDuration", TestRouteHardStopAfterTestZeroLengthDuration) | ||
| t.Run("TestRouteNbthreadIngressController", TestRouteNbthreadIngressController) | ||
| t.Run("TestRouterCompressionOperation", TestRouterCompressionOperation) | ||
| t.Run("TestUpdateDefaultIngressController", TestUpdateDefaultIngressController) | ||
| t.Run("TestCanaryRoute", TestCanaryRoute) | ||
| t.Run("TestRouteHTTP2EnableAndDisableIngressConfig", TestRouteHTTP2EnableAndDisableIngressConfig) | ||
| t.Run("TestRouteHardStopAfterEnableOnIngressConfig", TestRouteHardStopAfterEnableOnIngressConfig) | ||
| t.Run("TestRouteHardStopAfterEnableOnIngressControllerHasPriorityOverIngressConfig", TestRouteHardStopAfterEnableOnIngressControllerHasPriorityOverIngressConfig) | ||
| t.Run("TestHostNetworkPortBinding", TestHostNetworkPortBinding) | ||
| }) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,7 +52,7 @@ func testRouteHeaders(t *testing.T, image string, route *routev1.Route, address | |
| extraCurlArgs = append(extraCurlArgs, "-H", header) | ||
| } | ||
| testPodCount++ | ||
| name := fmt.Sprintf("forwardedheader%d", testPodCount) | ||
| name := fmt.Sprintf("%s%d", route.Name, testPodCount) | ||
| clientPod := buildCurlPod(name, route.Namespace, image, route.Spec.Host, address, extraCurlArgs...) | ||
| if err := kclient.Create(context.TODO(), clientPod); err != nil { | ||
| t.Fatalf("failed to create pod %s/%s: %v", clientPod.Namespace, clientPod.Name, err) | ||
|
|
@@ -121,7 +121,8 @@ func testRouteHeaders(t *testing.T, image string, route *routev1.Route, address | |
| // client specifies 2 X-Forwarded-For headers, then the router should append a | ||
| // 3rd. | ||
| func TestForwardedHeaderPolicyAppend(t *testing.T) { | ||
| icName := types.NamespacedName{Namespace: operatorNamespace, Name: "forwardedheader"} | ||
| t.Parallel() | ||
| icName := types.NamespacedName{Namespace: operatorNamespace, Name: "forwardedheader-append"} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe diff --git a/test/e2e/forwarded_header_policy_test.go b/test/e2e/forwarded_header_policy_test.go
index a5d5ec9c..b1d5b562 100644
--- a/test/e2e/forwarded_header_policy_test.go
+++ b/test/e2e/forwarded_header_policy_test.go
@@ -52,7 +52,7 @@ func testRouteHeaders(t *testing.T, image string, route *routev1.Route, address
extraCurlArgs = append(extraCurlArgs, "-H", header)
}
testPodCount++
- name := fmt.Sprintf("forwardedheader%d", testPodCount)
+ name := fmt.Sprintf("%s%d", route.Name, testPodCount)
clientPod := buildCurlPod(name, route.Namespace, image, route.Spec.Host, address, extraCurlArgs...)
if err := kclient.Create(context.TODO(), clientPod); err != nil {
t.Fatalf("failed to create pod %s/%s: %v", clientPod.Namespace, clientPod.Name, err)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch! Thanks.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed here: 416d29f |
||
| domain := icName.Name + "." + dnsConfig.Spec.BaseDomain | ||
| ic := newPrivateController(icName, domain) | ||
| if err := kclient.Create(context.TODO(), ic); err != nil { | ||
|
|
@@ -215,7 +216,8 @@ func TestForwardedHeaderPolicyAppend(t *testing.T) { | |
| // expected behavior if its policy is "Replace". A forwarded client request | ||
| // should always have exactly 1 X-Forwarded-For header. | ||
| func TestForwardedHeaderPolicyReplace(t *testing.T) { | ||
| icName := types.NamespacedName{Namespace: operatorNamespace, Name: "forwardedheader"} | ||
| t.Parallel() | ||
| icName := types.NamespacedName{Namespace: operatorNamespace, Name: "forwardedheader-replace"} | ||
| domain := icName.Name + "." + dnsConfig.Spec.BaseDomain | ||
| ic := newPrivateController(icName, domain) | ||
| ic.Spec.HTTPHeaders = &operatorv1.IngressControllerHTTPHeaders{ | ||
|
|
@@ -284,7 +286,8 @@ func TestForwardedHeaderPolicyReplace(t *testing.T) { | |
| // should always have exactly as many X-Forwarded-For headers as the client | ||
| // specified. | ||
| func TestForwardedHeaderPolicyNever(t *testing.T) { | ||
| icName := types.NamespacedName{Namespace: operatorNamespace, Name: "forwardedheader"} | ||
| t.Parallel() | ||
| icName := types.NamespacedName{Namespace: operatorNamespace, Name: "forwardedheader-never"} | ||
| domain := icName.Name + "." + dnsConfig.Spec.BaseDomain | ||
| ic := newPrivateController(icName, domain) | ||
| ic.Spec.HTTPHeaders = &operatorv1.IngressControllerHTTPHeaders{ | ||
|
|
@@ -354,7 +357,8 @@ func TestForwardedHeaderPolicyNever(t *testing.T) { | |
| // specifies more than 1 X-Forwarded-For header, the forwarded request should | ||
| // include exactly as many X-Forwarded-For headers as the client specified. | ||
| func TestForwardedHeaderPolicyIfNone(t *testing.T) { | ||
| icName := types.NamespacedName{Namespace: operatorNamespace, Name: "forwardedheader"} | ||
| t.Parallel() | ||
| icName := types.NamespacedName{Namespace: operatorNamespace, Name: "forwardedheader-none"} | ||
| domain := icName.Name + "." + dnsConfig.Spec.BaseDomain | ||
| ic := newPrivateController(icName, domain) | ||
| ic.Spec.HTTPHeaders = &operatorv1.IngressControllerHTTPHeaders{ | ||
|
|
||
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.
The way the commits are ordered, this commit would cause tests to fail, which would break
git bisect, wouldn't it?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.
Likely. But there are many commits now...
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 moved this addition to the last commit: https://github.com/openshift/cluster-ingress-operator/pull/756/commits