Skip to content

Commit eeabc73

Browse files
Merge pull request #5388 from sergiordlr/mco-filter-tests-by-platform
MCO-1966: Filter extended tests by platform
2 parents 99f6e3a + 1aa5e87 commit eeabc73

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

cmd/machine-config-tests-ext/main.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"time"
88

99
"github.com/openshift-eng/openshift-tests-extension/pkg/cmd"
10+
et "github.com/openshift-eng/openshift-tests-extension/pkg/extension/extensiontests"
1011
v "github.com/openshift-eng/openshift-tests-extension/pkg/version"
1112
"github.com/openshift/machine-config-operator/pkg/version"
1213
exutil "github.com/openshift/machine-config-operator/test/extended-priv/util"
@@ -20,6 +21,37 @@ import (
2021
_ "github.com/openshift/machine-config-operator/test/extended-priv"
2122
)
2223

24+
func applyLabelFilters(specs et.ExtensionTestSpecs) {
25+
// Apply Platform label filters: tests with Platform:platformname only run on that platform
26+
specs.Walk(func(spec *et.ExtensionTestSpec) {
27+
for label := range spec.Labels {
28+
if strings.HasPrefix(label, "Platform:") {
29+
platformName := strings.TrimPrefix(label, "Platform:")
30+
spec.Include(et.PlatformEquals(platformName))
31+
}
32+
}
33+
})
34+
35+
// Apply NoPlatform label filters: tests with NoPlatform:platformname excluded from that platform
36+
specs.Walk(func(spec *et.ExtensionTestSpec) {
37+
for label := range spec.Labels {
38+
if strings.HasPrefix(label, "NoPlatform:") {
39+
platformName := strings.TrimPrefix(label, "NoPlatform:")
40+
spec.Exclude(et.PlatformEquals(platformName))
41+
}
42+
}
43+
})
44+
45+
// Exclude tests with "Exclude:REASON" labels
46+
specs.Walk(func(spec *et.ExtensionTestSpec) {
47+
for label := range spec.Labels {
48+
if strings.HasPrefix(label, "Exclude:") {
49+
spec.Exclude("true")
50+
}
51+
}
52+
})
53+
}
54+
2355
func main() {
2456
// Extension registry
2557
registry := e.NewRegistry()
@@ -48,6 +80,8 @@ func main() {
4880
panic(fmt.Sprintf("couldn't build extension test specs from ginkgo: %+v", err.Error()))
4981
}
5082

83+
applyLabelFilters(specs)
84+
5185
ext.AddSpecs(specs)
5286
registry.Register(ext)
5387

test/extended/boot_image_update_azure.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
)
1919

2020
// These tests are [Serial] because it modifies the cluster/machineconfigurations.operator.openshift.io object in each test.
21-
var _ = g.Describe("[sig-mco][Suite:openshift/machine-config-operator/disruptive][Serial][OCPFeatureGate:ManagedBootImagesAzure]", g.Ordered, func() {
21+
var _ = g.Describe("[sig-mco][Suite:openshift/machine-config-operator/disruptive][Serial][OCPFeatureGate:ManagedBootImagesAzure]", g.Label("Platform:azure"), g.Ordered, func() {
2222
defer g.GinkgoRecover()
2323
var (
2424
AllMachineSetFixture = filepath.Join("machineconfigurations", "managedbootimages-all.yaml")

0 commit comments

Comments
 (0)