Skip to content

Commit 65b3f12

Browse files
committed
add the option to omit the annotations when running 'list tests' that is useful when generating the labels, and some more cleanup
1 parent ea6eff3 commit 65b3f12

File tree

4 files changed

+1750
-1710
lines changed

4 files changed

+1750
-1710
lines changed

openshift-hack/cmd/k8s-tests-ext/k8s-tests.go

+20-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import (
44
"flag"
55
"os"
66
"reflect"
7+
"strconv"
78

9+
et "github.com/openshift-eng/openshift-tests-extension/pkg/extension/extensiontests"
10+
"github.com/sirupsen/logrus"
11+
"k8s.io/kubernetes/openshift-hack/e2e/annotate/generated"
812
"k8s.io/kubernetes/test/e2e/framework"
913

1014
"github.com/spf13/cobra"
@@ -95,12 +99,22 @@ func main() {
9599
// the environmental skip code from the enhancement once its implemented.
96100
// - Make sure to account for test renames that occur because of removal of these
97101
// annotations
98-
//TODO: this will have to be added back for now, but can we use the new logic anyways? test it...
99-
//specs.Walk(func(spec *et.ExtensionTestSpec) {
100-
// if annotations, ok := generated.Annotations[spec.Name]; ok {
101-
// spec.Name += annotations
102-
// }
103-
//})
102+
var omitAnnotations bool
103+
omitAnnotationsVal := os.Getenv("OMIT_ANNOTATIONS")
104+
if omitAnnotationsVal != "" {
105+
omitAnnotations, err = strconv.ParseBool(omitAnnotationsVal)
106+
if err != nil {
107+
logrus.WithError(err).Fatal("Failed to parse OMIT_ANNOTATIONS")
108+
}
109+
}
110+
if !omitAnnotations {
111+
logrus.Infof("adding annotations as OMIT_ANNOTATIONS was either false, or not provided")
112+
specs.Walk(func(spec *et.ExtensionTestSpec) {
113+
if annotations, ok := generated.Annotations[spec.Name]; ok {
114+
spec.Name += annotations
115+
}
116+
})
117+
}
104118

105119
specs = filterOutDisabledSpecs(specs)
106120
addLabelsToSpecs(specs)

openshift-hack/e2e/kube_e2e_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ func TestMain(m *testing.M) {
110110
func TestE2E(t *testing.T) {
111111
ginkgo.GetSuite().SetAnnotateFn(func(name string, node types.TestSpec) {
112112
if newLabels, ok := generated.Labels[name]; ok {
113-
node.AppendText(strings.Replace(newLabels, ",", " ", -1))
113+
node.AppendText(fmt.Sprintf(" %s", strings.Replace(newLabels, ",", " ", -1)))
114114
} else {
115115
// If the name isn't found in the generated labels file, it is because the test has been disabled via OTE
116-
node.AppendText("[Disabled:missing]")
116+
node.AppendText(" [Disabled:missing]")
117117
}
118118
if strings.Contains(name, "Kubectl client Kubectl prune with applyset should apply and prune objects") {
119119
fmt.Printf("Trying to annotate %q\n", name)

0 commit comments

Comments
 (0)