Skip to content

Commit

Permalink
tests(conformance): use router flavor instead of separate flag for en…
Browse files Browse the repository at this point in the history
…abling expressions router
  • Loading branch information
pmalek committed Apr 11, 2024
1 parent 8e54ae9 commit f6c1300
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/_conformance_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ jobs:
matrix:
include:
- name: traditional-compatible-router
expression_routes: "false"
router-flavor: traditional_compatible
- name: expressions-router
expression_routes: "true"
router-flavor: expressions
steps:
- name: checkout repository
uses: actions/checkout@v4
Expand All @@ -56,7 +56,7 @@ jobs:
run: make test.conformance
env:
JUNIT_REPORT: conformance-tests.xml
KONG_TEST_EXPRESSION_ROUTES: ${{ matrix.expression_routes }}
TEST_KONG_ROUTER_FLAVOR: ${{ matrix.router-flavor }}
TEST_KONG_KIC_MANAGER_LOG_OUTPUT: ${{ inputs.log-output-file }}

# upload logs when test failed
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/conformance_tests_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- name: Run conformance tests
env:
TEST_KONG_HELM_CHART_VERSION: ${{ needs.dependencies-versions.outputs.helm-kong }}
KONG_TEST_EXPRESSION_ROUTES: "true"
TEST_KONG_ROUTER_FLAVOR: expressions
run: make test.conformance

# Generated report should be submitted to
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ test.conformance: _check.container.environment go-junit-report
TEST_KONG_HELM_CHART_VERSION="$(TEST_KONG_HELM_CHART_VERSION)" \
GOFLAGS="-tags=conformance_tests" \
go test \
-ldflags "$(LDFLAGS_METADATA)" \
-ldflags "$(LDFLAGS_COMMON) $(LDFLAGS_METADATA)" \
-v \
-race $(GOTESTFLAGS) \
-timeout $(INTEGRATION_TEST_TIMEOUT) \
Expand Down
21 changes: 14 additions & 7 deletions test/conformance/gateway_conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,26 @@ var expressionRoutesSupportedFeatures = []suite.SupportedFeature{
suite.SupportHTTPRouteMethodMatching,
suite.SupportHTTPRouteResponseHeaderModification,
suite.SupportHTTPRouteBackendTimeout,
suite.SupportHTTPRoutePathRewrite,
}

func TestGatewayConformance(t *testing.T) {
k8sClient, gatewayClassName := prepareEnvForGatewayConformanceTests(t)
// Conformance tests are run for both configs with and without
// KONG_TEST_EXPRESSION_ROUTES='true'.
var skippedTests []string
var supportedFeatures []suite.SupportedFeature
if testenv.ExpressionRoutesEnabled() {
supportedFeatures = expressionRoutesSupportedFeatures
} else {

// Conformance tests are run for both available router flavours:
// traditional_compatible and expressions.
var (
skippedTests []string
supportedFeatures []suite.SupportedFeature
)
switch rf := testenv.KongRouterFlavor(); rf {
case "traditional_compatible":
skippedTests = skippedTestsForTraditionalRoutes
supportedFeatures = traditionalRoutesSupportedFeatures
case "expressions":
supportedFeatures = expressionRoutesSupportedFeatures
default:
t.Fatalf("unsupported KongRouterFlavor: %s", rf)
}

cSuite, err := suite.NewExperimentalConformanceTestSuite(
Expand Down
2 changes: 1 addition & 1 deletion test/conformance/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestMain(m *testing.M) {
// In order to pass conformance tests, the expression router is required.
kongBuilder := kong.NewBuilder().WithControllerDisabled().WithProxyAdminServiceTypeLoadBalancer().
WithNamespace(consts.ControllerNamespace)
if testenv.ExpressionRoutesEnabled() {
if testenv.KongRouterFlavor() == "expressions" {
fmt.Println("INFO: expression routes enabled")
kongBuilder = kongBuilder.WithProxyEnvVar("router_flavor", "expressions")
}
Expand Down
7 changes: 0 additions & 7 deletions test/internal/testenv/testenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,6 @@ func ControllerFeatureGates() string {
return featureGates
}

// ExpressionRoutesEnabled indicates whether or not to enable expression routes
// for the Kong Gateway and the controller.
// If none specified, we fall back to default value - traditional_compatible.
func ExpressionRoutesEnabled() bool {
return os.Getenv("KONG_TEST_EXPRESSION_ROUTES") == "true"
}

// -----------------------------------------------------------------------------
// Environment variables related helpers
// -----------------------------------------------------------------------------
Expand Down

1 comment on commit f6c1300

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Go Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: f6c1300 Previous: c36e368 Ratio
BenchmarkListHTTPRoutes/100 8406 ns/op 2688 B/op 2 allocs/op 3410 ns/op 2688 B/op 2 allocs/op 2.47
BenchmarkListHTTPRoutes/100 - ns/op 8406 ns/op 3410 ns/op 2.47

This comment was automatically generated by workflow using github-action-benchmark.

CC: @Kong/k8s-maintainers

Please sign in to comment.