@@ -18,7 +18,7 @@ limitations under the License.
1818package tests
1919
2020import (
21- "strings "
21+ "os "
2222 "testing"
2323
2424 . "github.com/onsi/gomega"
@@ -27,9 +27,11 @@ import (
2727 "sigs.k8s.io/controller-runtime/pkg/client/config"
2828 "sigs.k8s.io/gateway-api/apis/v1alpha2"
2929 "sigs.k8s.io/gateway-api/apis/v1beta1"
30+ "sigs.k8s.io/gateway-api/conformance/apis/v1alpha1"
3031 "sigs.k8s.io/gateway-api/conformance/tests"
3132 "sigs.k8s.io/gateway-api/conformance/utils/flags"
3233 "sigs.k8s.io/gateway-api/conformance/utils/suite"
34+ "sigs.k8s.io/yaml"
3335)
3436
3537func TestConformance (t * testing.T ) {
@@ -43,39 +45,54 @@ func TestConformance(t *testing.T) {
4345 g .Expect (v1alpha2 .AddToScheme (client .Scheme ())).To (Succeed ())
4446 g .Expect (v1beta1 .AddToScheme (client .Scheme ())).To (Succeed ())
4547
46- supportedFeatures := parseSupportedFeatures (* flags .SupportedFeatures )
47- exemptFeatures := parseSupportedFeatures (* flags .ExemptFeatures )
48+ supportedFeatures := suite . ParseSupportedFeatures (* flags .SupportedFeatures )
49+ exemptFeatures := suite . ParseSupportedFeatures (* flags .ExemptFeatures )
4850
4951 t .Logf (`Running conformance tests with %s GatewayClass\n cleanup: %t\n` +
5052 `debug: %t\n enable all features: %t \n supported features: [%v]\n exempt features: [%v]` ,
5153 * flags .GatewayClassName , * flags .CleanupBaseResources , * flags .ShowDebug ,
5254 * flags .EnableAllSupportedFeatures , * flags .SupportedFeatures , * flags .ExemptFeatures )
5355
54- cSuite := suite .New (suite.Options {
55- Client : client ,
56- GatewayClassName : * flags .GatewayClassName ,
57- Debug : * flags .ShowDebug ,
58- CleanupBaseResources : * flags .CleanupBaseResources ,
59- SupportedFeatures : supportedFeatures ,
60- ExemptFeatures : exemptFeatures ,
61- EnableAllSupportedFeatures : * flags .EnableAllSupportedFeatures ,
56+ expSuite , err := suite .NewExperimentalConformanceTestSuite (suite.ExperimentalConformanceOptions {
57+ Options : suite.Options {
58+ Client : client ,
59+ GatewayClassName : * flags .GatewayClassName ,
60+ Debug : * flags .ShowDebug ,
61+ CleanupBaseResources : * flags .CleanupBaseResources ,
62+ SupportedFeatures : supportedFeatures ,
63+ ExemptFeatures : exemptFeatures ,
64+ EnableAllSupportedFeatures : * flags .EnableAllSupportedFeatures ,
65+ },
66+ Implementation : v1alpha1.Implementation {
67+ Organization : "nginxinc" ,
68+ Project : "nginx-kubernetes-gateway" ,
69+ URL : "https://github.com/nginxinc/nginx-kubernetes-gateway" ,
70+ Version : * flags .ImplementationVersion ,
71+ Contact : []string {
72+ "https://github.com/nginxinc/nginx-kubernetes-gateway/discussions/new/choose" ,
73+ },
74+ },
75+ ConformanceProfiles : sets .New (suite .HTTPConformanceProfileName ),
6276 })
63- cSuite .Setup (t )
64- cSuite .Run (t , tests .ConformanceTests )
65- }
77+ g .Expect (err ).To (Not (HaveOccurred ()))
78+
79+ expSuite .Setup (t )
80+ err = expSuite .Run (t , tests .ConformanceTests )
81+ g .Expect (err ).To (Not (HaveOccurred ()))
82+
83+ report , err := expSuite .Report ()
84+ g .Expect (err ).To (Not (HaveOccurred ()))
85+
86+ yamlReport , err := yaml .Marshal (report )
87+ g .Expect (err ).ToNot (HaveOccurred ())
88+
89+ f , err := os .Create (* flags .ReportOutput )
90+ g .Expect (err ).ToNot (HaveOccurred ())
91+ defer f .Close ()
92+
93+ _ , err = f .WriteString ("CONFORMANCE PROFILE\n " )
94+ g .Expect (err ).ToNot (HaveOccurred ())
6695
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
96+ _ , err = f .Write (yamlReport )
97+ g .Expect (err ).ToNot (HaveOccurred ())
8198}
0 commit comments