Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/testsuites/standard_suites.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,9 @@ var staticSuites = []ginkgo.TestSuite{
The conformance testing suite for certified third-party CNI plugins.
`),
Qualifiers: []string{
`name.contains("[Suite:k8s]") && name.contains("[sig-network]") &&
(name.contains("[Conformance]") ||
(name.contains("NetworkPolicy") && !name.contains("named port")) ||
`source == "openshift:payload:hyperkube" && name.contains("[sig-network]") &&
(name.contains("[Conformance]") ||
(name.contains("NetworkPolicy") && !name.contains("named port")) ||
name.contains("[Feature:IPv6DualStack]"))`,
},
},
Expand Down
67 changes: 66 additions & 1 deletion pkg/testsuites/suites_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import (
"testing"

"github.com/openshift-eng/openshift-tests-extension/pkg/extension/extensiontests"
"github.com/openshift/origin/pkg/test/ginkgo"
)

// TestSuiteQualifiersValidCEL validates that all CEL expressions in suite qualifiers
// are syntactically valid
func TestSuiteQualifiersValidCEL(t *testing.T) {
dummyTest := &extensiontests.ExtensionTestSpec{
Name: "[sig-test] Test a thing [Suite:openshift/conformance/parallel] [Early]",
Name: "[sig-test] Test a thing [Suite:openshift/conformance/parallel] [Early]",
Source: "openshift:payload:origin",
}
dummySpecs := extensiontests.ExtensionTestSpecs{dummyTest}

Expand Down Expand Up @@ -49,3 +51,66 @@ func TestSuiteQualifiersValidCEL(t *testing.T) {
}
})
}

func TestThirdPartySuiteMatchesHyperkubeTests(t *testing.T) {
var thirdPartySuite *ginkgo.TestSuite
for i := range staticSuites {
if staticSuites[i].Name == "openshift/network/third-party" {
thirdPartySuite = &staticSuites[i]
break
}
}
if thirdPartySuite == nil {
t.Fatal("openshift/network/third-party suite not found")
}

candidateTests := extensiontests.ExtensionTestSpecs{
{
Name: "[sig-network] NetworkPolicy API should support creating NetworkPolicy API operations [Conformance]",
Source: "openshift:payload:hyperkube",
},
{
Name: "[sig-network] Networking should provide Internet connection for containers [Feature:Networking-IPv4] [Conformance]",
Source: "openshift:payload:hyperkube",
},
{
Name: "[sig-network] NetworkPolicy should enforce policy based on Ports [Feature:IPv6DualStack]",
Source: "openshift:payload:hyperkube",
},
{
Name: "[sig-network] NetworkPolicy named port should not match",
Source: "openshift:payload:hyperkube",
},
{
Name: "[sig-storage] some storage test [Conformance]",
Source: "openshift:payload:hyperkube",
},
{
Name: "[sig-network] some origin network test [Conformance]",
Source: "openshift:payload:origin",
},
}

filtered, err := candidateTests.Filter(thirdPartySuite.Qualifiers)
if err != nil {
t.Fatalf("failed to filter: %v", err)
}

expectedNames := map[string]bool{
"[sig-network] NetworkPolicy API should support creating NetworkPolicy API operations [Conformance]": true,
"[sig-network] Networking should provide Internet connection for containers [Feature:Networking-IPv4] [Conformance]": true,
"[sig-network] NetworkPolicy should enforce policy based on Ports [Feature:IPv6DualStack]": true,
}

if len(filtered) != len(expectedNames) {
t.Errorf("expected %d tests, got %d", len(expectedNames), len(filtered))
for _, s := range filtered {
t.Logf(" matched: %s", s.Name)
}
}
for _, s := range filtered {
if !expectedNames[s.Name] {
t.Errorf("unexpected test matched: %s", s.Name)
}
}
}