Skip to content

Commit

Permalink
Add all-features flag to add ability to enable all supported featur…
Browse files Browse the repository at this point in the history
…e conformance tests.

Signed-off-by: Huang Xin <[email protected]>
  • Loading branch information
gyohuangxin committed Jan 11, 2023
1 parent d950009 commit f0f9146
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 21 deletions.
11 changes: 6 additions & 5 deletions conformance/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ func TestConformance(t *testing.T) {
}

cSuite := suite.New(suite.Options{
Client: client,
GatewayClassName: *flags.GatewayClassName,
Debug: *flags.ShowDebug,
CleanupBaseResources: *flags.CleanupBaseResources,
SupportedFeatures: supportedFeatures,
Client: client,
GatewayClassName: *flags.GatewayClassName,
Debug: *flags.ShowDebug,
CleanupBaseResources: *flags.CleanupBaseResources,
SupportedFeatures: supportedFeatures,
EnableAllSupportedFeatures: *flags.EnableAllSupportedFeatures,
})
cSuite.Setup(t)
cSuite.Run(t, tests.ConformanceTests)
Expand Down
11 changes: 6 additions & 5 deletions conformance/utils/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ import (
)

var (
GatewayClassName = flag.String("gateway-class", "gateway-conformance", "Name of GatewayClass to use for tests")
ShowDebug = flag.Bool("debug", false, "Whether to print debug logs")
CleanupBaseResources = flag.Bool("cleanup-base-resources", true, "Whether to cleanup base test resources after the run")
SupportedFeatures = flag.String("supported-features", "", "Supported features included in conformance tests suites")
ExemptFeatures = flag.String("exempt-features", "", "Exempt Features excluded from conformance tests suites")
GatewayClassName = flag.String("gateway-class", "gateway-conformance", "Name of GatewayClass to use for tests")
ShowDebug = flag.Bool("debug", false, "Whether to print debug logs")
CleanupBaseResources = flag.Bool("cleanup-base-resources", true, "Whether to cleanup base test resources after the run")
SupportedFeatures = flag.String("supported-features", "", "Supported features included in conformance tests suites")
ExemptFeatures = flag.String("exempt-features", "", "Exempt Features excluded from conformance tests suites")
EnableAllSupportedFeatures = flag.Bool("all-features", false, "Whether to enable all supported feature conformance tests")
)
42 changes: 31 additions & 11 deletions conformance/utils/suite/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,23 @@ var StandardCoreFeatures = map[SupportedFeature]bool{
SupportReferenceGrant: true,
}

// AllFeatures contains all the supported features and can be used to run all
// conformance tests with `all-features` flag.
var AllFeatures = map[SupportedFeature]bool{
SupportReferenceGrant: true,
SupportTLSRoute: true,
SupportHTTPRouteQueryParamMatching: true,
SupportHTTPRouteMethodMatching: true,
SupportHTTPResponseHeaderModification: true,
SupportRouteDestinationPortMatching: true,
SupportGatewayClassObservedGenerationBump: true,
SupportHTTPRoutePortRedirect: true,
SupportHTTPRouteSchemeRedirect: true,
SupportHTTPRoutePathRedirect: true,
SupportHTTPRouteHostRewrite: true,
SupportHTTPRoutePathRewrite: true,
}

// ConformanceTestSuite defines the test suite used to run Gateway API
// conformance tests.
type ConformanceTestSuite struct {
Expand All @@ -94,25 +111,26 @@ type ConformanceTestSuite struct {

// Options can be used to initialize a ConformanceTestSuite.
type Options struct {
Client client.Client
GatewayClassName string
Debug bool
RoundTripper roundtripper.RoundTripper
BaseManifests string
NamespaceLabels map[string]string
Client client.Client
GatewayClassName string
Debug bool
RoundTripper roundtripper.RoundTripper
BaseManifests string
NamespaceLabels map[string]string
// ValidUniqueListenerPorts maps each listener port of each Gateway in the
// manifests to a valid, unique port. There must be as many
// ValidUniqueListenerPorts as there are listeners in the set of manifests.
// For example, given two Gateways, each with 2 listeners, there should be
// four ValidUniqueListenerPorts.
// If empty or nil, ports are not modified.
ValidUniqueListenerPorts []v1beta1.PortNumber
ValidUniqueListenerPorts []v1beta1.PortNumber

// CleanupBaseResources indicates whether or not the base test
// resources such as Gateways should be cleaned up after the run.
CleanupBaseResources bool
SupportedFeatures map[SupportedFeature]bool
TimeoutConfig config.TimeoutConfig
CleanupBaseResources bool
SupportedFeatures map[SupportedFeature]bool
EnableAllSupportedFeatures bool
TimeoutConfig config.TimeoutConfig
}

// New returns a new ConformanceTestSuite.
Expand All @@ -124,7 +142,9 @@ func New(s Options) *ConformanceTestSuite {
roundTripper = &roundtripper.DefaultRoundTripper{Debug: s.Debug, TimeoutConfig: s.TimeoutConfig}
}

if s.SupportedFeatures == nil {
if s.EnableAllSupportedFeatures == true {
s.SupportedFeatures = AllFeatures
} else if s.SupportedFeatures == nil {
s.SupportedFeatures = StandardCoreFeatures
} else {
for feature, val := range StandardCoreFeatures {
Expand Down

0 comments on commit f0f9146

Please sign in to comment.