Skip to content

Commit

Permalink
Add flags for SupportedFeature and ExemptFeature in conformance tests.
Browse files Browse the repository at this point in the history
Signed-off-by: Huang Xin <xin1.huang@intel.com>
  • Loading branch information
gyohuangxin committed Sep 20, 2022
1 parent 57cefb9 commit 92bec8a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
29 changes: 26 additions & 3 deletions conformance/conformance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
package conformance_test

import (
"strings"
"testing"

"sigs.k8s.io/gateway-api/apis/v1alpha2"
Expand Down Expand Up @@ -45,15 +46,37 @@ func TestConformance(t *testing.T) {

t.Logf("Running conformance tests with %s GatewayClass", *flags.GatewayClassName)

supportedFeatures := parseSupportedFeatures(*flags.SupportedFeatures)
exemptFeatures := parseExemptFeatures(*flags.ExemptFeatures)

cSuite := suite.New(suite.Options{
Client: client,
GatewayClassName: *flags.GatewayClassName,
Debug: *flags.ShowDebug,
CleanupBaseResources: *flags.CleanupBaseResources,
SupportedFeatures: []suite.SupportedFeature{
suite.SupportReferenceGrant,
},
SupportedFeatures: supportedFeatures,
ExemptFeatures: exemptFeatures,
})
cSuite.Setup(t)
cSuite.Run(t, tests.ConformanceTests)
}

// parseSupportedFeatures parses the arguments for supported-features flag,
// then converts the string to []suite.SupportedFeature
func parseSupportedFeatures(f string) []suite.SupportedFeature {
var res []suite.SupportedFeature
for _, value := range strings.Split(f, ",") {
res = append(res, suite.SupportedFeature(value))
}
return res
}

// parseExemptFeatures parses the arguments for exempt-features flag,
// then converts the string to []suite.ExemptFeature
func parseExemptFeatures(f string) []suite.ExemptFeature {
var res []suite.ExemptFeature
for _, value := range strings.Split(f, ",") {
res = append(res, suite.ExemptFeature(value))
}
return res
}
2 changes: 2 additions & 0 deletions conformance/utils/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ 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", "SupportReferenceGrant", "Supported features included in conformance tests suites")
ExemptFeatures = flag.String("exempt-features", "", "Exempt Features excluded from conformance tests suites")
)

0 comments on commit 92bec8a

Please # to comment.