Skip to content

Commit 51f59d7

Browse files
authored
Fix conformance test problems (#777)
Problems: * The conformance tests consistently fail during setup because NKG times out waiting for the nginx process to start. * The conformance test makefile command runs the incorrect set of tests and times out before running all tests. Solutions: * Increase the pid timeout (i.e. the time we wait for nginx to start) to 10s. This is sufficient in my local environment. * Update the list of supported features and exempt features and pass them to the conformance test suite, and increase the go test timeout to 25 minutes to allow the suite to complete. I also added the debug flag to increase the verbosity of the test output.
1 parent a710e0f commit 51f59d7

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

conformance/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
NKG_TAG = edge
22
NKG_PREFIX = nginx-kubernetes-gateway
33
GATEWAY_CLASS = nginx
4-
SUPPORTED_FEATURES = Gateway,HTTPRoute
4+
SUPPORTED_FEATURES = HTTPRoute,HTTPRouteQueryParamMatching,HTTPRouteMethodMatching,HTTPRoutePortRedirect,HTTPRouteSchemeRedirect
5+
EXEMPT_FEATURES = ReferenceGrant
56
KIND_KUBE_CONFIG_FOLDER = $${HOME}/.kube/kind
67
TAG = latest
78
PREFIX = conformance-test-runner
@@ -44,7 +45,7 @@ update-test-kind-config: ## Update kind config
4445
.PHONY: run-conformance-tests
4546
run-conformance-tests: update-test-kind-config ## Run conformance tests
4647
docker run --network=kind --rm -v $(KIND_KUBE_CONFIG_FOLDER):/root/.kube $(PREFIX):$(TAG) \
47-
go test -v . -tags conformance -args --gateway-class=$(GATEWAY_CLASS) --supported-features=$(SUPPORTED_FEATURES)
48+
go test -timeout 25m -v . -tags conformance -args --gateway-class=$(GATEWAY_CLASS) --debug --supported-features=$(SUPPORTED_FEATURES) --exempt-features=$(EXEMPT_FEATURES)
4849

4950
.PHONY: uninstall-nkg
5051
uninstall-nkg: ## Uninstall NKG on configured kind cluster

conformance/tests/conformance_test.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ limitations under the License.
1818
package tests
1919

2020
import (
21+
"strings"
2122
"testing"
2223

2324
. "github.com/onsi/gomega"
25+
"k8s.io/apimachinery/pkg/util/sets"
2426
"sigs.k8s.io/controller-runtime/pkg/client"
2527
"sigs.k8s.io/controller-runtime/pkg/client/config"
2628
"sigs.k8s.io/gateway-api/apis/v1alpha2"
@@ -41,6 +43,9 @@ func TestConformance(t *testing.T) {
4143
g.Expect(v1alpha2.AddToScheme(client.Scheme())).To(Succeed())
4244
g.Expect(v1beta1.AddToScheme(client.Scheme())).To(Succeed())
4345

46+
supportedFeatures := parseSupportedFeatures(*flags.SupportedFeatures)
47+
exemptFeatures := parseSupportedFeatures(*flags.ExemptFeatures)
48+
4449
t.Logf(`Running conformance tests with %s GatewayClass\n cleanup: %t\n`+
4550
`debug: %t\n enable all features: %t \n supported features: [%v]\n exempt features: [%v]`,
4651
*flags.GatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug,
@@ -51,9 +56,26 @@ func TestConformance(t *testing.T) {
5156
GatewayClassName: *flags.GatewayClassName,
5257
Debug: *flags.ShowDebug,
5358
CleanupBaseResources: *flags.CleanupBaseResources,
54-
SupportedFeatures: nil,
59+
SupportedFeatures: supportedFeatures,
60+
ExemptFeatures: exemptFeatures,
5561
EnableAllSupportedFeatures: *flags.EnableAllSupportedFeatures,
5662
})
5763
cSuite.Setup(t)
5864
cSuite.Run(t, tests.ConformanceTests)
5965
}
66+
67+
// parseSupportedFeatures parses flag arguments and converts the string to
68+
// sets.Set[suite.SupportedFeature]
69+
// FIXME(kate-osborn): Use exported ParseSupportedFeatures function
70+
// https://github.com/kubernetes-sigs/gateway-api/blob/63e423cf1b837991d2747742199d90863a98b0c3/conformance/utils/suite/suite.go#L235
71+
// once it's released. https://github.com/nginxinc/nginx-kubernetes-gateway/issues/779
72+
func parseSupportedFeatures(f string) sets.Set[suite.SupportedFeature] {
73+
if f == "" {
74+
return nil
75+
}
76+
res := sets.Set[suite.SupportedFeature]{}
77+
for _, value := range strings.Split(f, ",") {
78+
res.Insert(suite.SupportedFeature(value))
79+
}
80+
return res
81+
}

internal/nginx/runtime/manager.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616

1717
const (
1818
pidFile = "/etc/nginx/nginx.pid"
19-
pidFileTimeout = 5 * time.Second
19+
pidFileTimeout = 10 * time.Second
2020
)
2121

2222
type (
@@ -81,7 +81,7 @@ func findMainProcess(
8181

8282
err := wait.PollUntilContextCancel(
8383
ctx,
84-
1*time.Second,
84+
500*time.Millisecond,
8585
true, /* poll immediately */
8686
func(ctx context.Context) (bool, error) {
8787
_, err := checkFile(pidFile)

0 commit comments

Comments
 (0)