Skip to content

Commit 2513cbe

Browse files
Merge pull request #2616 from machine424/extd
MON-4288: set up openshift-tests-extension and add a sanity test
2 parents 26d99b4 + 3a14395 commit 2513cbe

File tree

308 files changed

+203703
-11
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

308 files changed

+203703
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/operator
2+
/tests-ext
23

34
jsonnet/vendor/
45
/tmp
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[
2+
{
3+
"name": "[Jira:Monitoring][sig-instrumentation] sanity test should always pass [Suite:openshift/cluster-monitoring-operator/conformance/parallel]",
4+
"labels": {},
5+
"resources": {
6+
"isolation": {}
7+
},
8+
"source": "openshift:payload:cluster-monitoring-operator",
9+
"lifecycle": "blocking",
10+
"environmentSelector": {}
11+
}
12+
]

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.23-openshift-4.19 AS
44
WORKDIR /go/src/github.com/openshift/cluster-monitoring-operator
55
COPY . .
66
ENV GOFLAGS="-mod=vendor"
7-
RUN make operator-no-deps
7+
RUN make operator-no-deps && make tests-ext-build && gzip tests-ext
88

99
FROM registry.ci.openshift.org/ocp/4.19:base-rhel9
1010
LABEL io.k8s.display-name="OpenShift cluster-monitoring-operator" \
@@ -15,6 +15,7 @@ LABEL io.k8s.display-name="OpenShift cluster-monitoring-operator" \
1515
maintainer="OpenShift Monitoring Team <[email protected]>"
1616

1717
COPY --from=builder /go/src/github.com/openshift/cluster-monitoring-operator/operator /usr/bin/
18+
COPY --from=builder /go/src/github.com/openshift/cluster-monitoring-operator/tests-ext.gz /usr/bin/cluster-monitoring-operator-tests-ext.gz
1819
COPY manifests /manifests
1920
COPY assets /assets
2021
USER 1001

Makefile

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ GO_BUILD_RECIPE=GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build --ldflags="
5656
MARKDOWN_DOCS=$(shell find . -type f -name '*.md' ! -path '*/vendor/*' ! -path './git/*' \
5757
! -name 'data-collection.md' ! -name 'sample-metrics.md' | sort)
5858

59+
TESTS_EXT_GIT_COMMIT := $(shell git rev-parse --short HEAD)
60+
TESTS_EXT_BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
61+
TESTS_EXT_GIT_TREE_STATE := $(shell if git diff --quiet; then echo clean; else echo dirty; fi)
62+
TESTS_EXT_LDFLAGS := -X 'github.com/openshift-eng/openshift-tests-extension/pkg/version.CommitFromGit=$(TESTS_EXT_GIT_COMMIT)' \
63+
-X 'github.com/openshift-eng/openshift-tests-extension/pkg/version.BuildDate=$(TESTS_EXT_BUILD_DATE)' \
64+
-X 'github.com/openshift-eng/openshift-tests-extension/pkg/version.GitTreeState=$(TESTS_EXT_GIT_TREE_STATE)'
65+
5966
.PHONY: all
6067
all: clean format generate build test
6168

@@ -82,7 +89,7 @@ run-local: build
8289
fi
8390

8491
.PHONY: build
85-
build: operator
92+
build: operator tests-ext-build
8693

8794
.PHONY: operator
8895
operator: $(GOLANG_FILES)
@@ -94,6 +101,19 @@ operator: $(GOLANG_FILES)
94101
operator-no-deps:
95102
$(GO_BUILD_RECIPE) -o operator $(GO_PKG)/cmd/operator
96103

104+
.PHONY: tests-ext-build
105+
tests-ext-build:
106+
# GO_COMPLIANCE_POLICY="exempt_all" must only be used for test related binaries.
107+
# It prevents various FIPS compliance policies from being applied to this compilation.
108+
GOOS=$(GOOS) GOARCH=$(GOARCH) GO_COMPLIANCE_POLICY="exempt_all" CGO_ENABLED=0 go build -o tests-ext -ldflags "$(TESTS_EXT_LDFLAGS)" $(GO_PKG)/cmd/tests-ext
109+
110+
# Metadata validation: https://github.com/openshift/enhancements/blob/master/enhancements/testing/openshift-tests-extension.md#update---metadata-validation
111+
.PHONY: tests-ext-update
112+
tests-ext-update: tests-ext-build
113+
./tests-ext update
114+
# TODO: temp remove .codeLocations as they depend on the env where "update" in run, see https://issues.redhat.com/browse/TRT-2186.
115+
for f in .openshift-tests-extension/*.json; do jq 'map(del(.codeLocations))' "$$f" > tmpp && mv tmpp "$$f"; done
116+
97117
.PHONY: image
98118
image: .hack-operator-image
99119

@@ -126,7 +146,7 @@ update: $(JB_BIN)
126146
cd jsonnet && $(JB_BIN) update $(COMPONENTS)
127147

128148
.PHONY: generate
129-
generate: build-jsonnet docs
149+
generate: build-jsonnet docs tests-ext-update
130150

131151
.PHONY: verify
132152
verify: check-assets check-rules check-runbooks

cmd/tests-ext/main.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"github.com/openshift-eng/openshift-tests-extension/pkg/cmd"
8+
9+
"github.com/spf13/cobra"
10+
11+
e "github.com/openshift-eng/openshift-tests-extension/pkg/extension"
12+
g "github.com/openshift-eng/openshift-tests-extension/pkg/ginkgo"
13+
14+
_ "github.com/openshift/cluster-monitoring-operator/test/ext"
15+
)
16+
17+
func main() {
18+
registry := e.NewRegistry()
19+
20+
ext := e.NewExtension("openshift", "payload", "cluster-monitoring-operator")
21+
ext.AddSuite(e.Suite{
22+
Name: "openshift/cluster-monitoring-operator/conformance/parallel",
23+
Parents: []string{
24+
"openshift/conformance/parallel",
25+
},
26+
Qualifiers: []string{
27+
"name.contains('[Suite:openshift/cluster-monitoring-operator/conformance/parallel')",
28+
},
29+
})
30+
31+
specs, err := g.BuildExtensionTestSpecsFromOpenShiftGinkgoSuite()
32+
if err != nil {
33+
panic(fmt.Sprintf("couldn't build extension test specs from ginkgo: %+v", err.Error()))
34+
}
35+
36+
ext.AddSpecs(specs)
37+
registry.Register(ext)
38+
39+
root := &cobra.Command{
40+
Long: "OpenShift Tests Extension for Cluster Monitoring Operator",
41+
}
42+
root.AddCommand(cmd.DefaultExtensionCommands(registry)...)
43+
44+
if err := func() error {
45+
return root.Execute()
46+
}(); err != nil {
47+
os.Exit(1)
48+
}
49+
}

go.mod

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ require (
1515
github.com/google/uuid v1.6.0
1616
github.com/imdario/mergo v0.3.16
1717
github.com/mattn/go-shellwords v1.0.12
18+
github.com/onsi/ginkgo/v2 v2.22.0
19+
github.com/onsi/gomega v1.36.1
20+
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250702172817-97309544869d
1821
github.com/openshift/api v0.0.0-20250320170726-75d64d71980b
1922
github.com/openshift/client-go v0.0.0-20250125113824-8e1f0b8fa9a7
2023
github.com/openshift/library-go v0.0.0-20250402180609-ce2ba53fb2a4
@@ -24,6 +27,7 @@ require (
2427
github.com/prometheus/client_golang v1.20.4
2528
github.com/prometheus/common v0.60.0
2629
github.com/prometheus/prometheus v0.54.1
30+
github.com/spf13/cobra v1.8.1
2731
github.com/stretchr/testify v1.9.0
2832
golang.org/x/net v0.34.0
2933
golang.org/x/sync v0.10.0
@@ -78,6 +82,7 @@ require (
7882
github.com/go-openapi/spec v0.20.14 // indirect
7983
github.com/go-openapi/swag v0.23.0 // indirect
8084
github.com/go-openapi/validate v0.23.0 // indirect
85+
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
8186
github.com/gogo/protobuf v1.3.2 // indirect
8287
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
8388
github.com/golang/protobuf v1.5.4 // indirect
@@ -86,6 +91,7 @@ require (
8691
github.com/google/gnostic-models v0.6.9 // indirect
8792
github.com/google/go-cmp v0.6.0 // indirect
8893
github.com/google/gofuzz v1.2.0 // indirect
94+
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect
8995
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc // indirect
9096
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
9197
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
@@ -110,7 +116,6 @@ require (
110116
github.com/prometheus/common/sigv4 v0.1.0 // indirect
111117
github.com/prometheus/procfs v0.15.1 // indirect
112118
github.com/robfig/cron v1.2.0 // indirect
113-
github.com/spf13/cobra v1.8.1 // indirect
114119
github.com/spf13/pflag v1.0.5 // indirect
115120
github.com/stoewer/go-strcase v1.3.0 // indirect
116121
github.com/x448/float16 v0.8.4 // indirect
@@ -136,10 +141,11 @@ require (
136141
golang.org/x/sys v0.29.0 // indirect
137142
golang.org/x/term v0.28.0 // indirect
138143
golang.org/x/time v0.9.0 // indirect
144+
golang.org/x/tools v0.26.0 // indirect
139145
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
140146
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
141147
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 // indirect
142-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 // indirect
148+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61 // indirect
143149
google.golang.org/grpc v1.65.0 // indirect
144150
google.golang.org/protobuf v1.36.3 // indirect
145151
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
@@ -151,3 +157,6 @@ require (
151157
sigs.k8s.io/kube-storage-version-migrator v0.0.6-0.20230721195810-5c8923c5ff96 // indirect
152158
sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect
153159
)
160+
161+
// Some utils are only available in the fork https://github.com/openshift-eng/openshift-tests-extension/blob/8ef37c67e666954f9b95e52320c9c20d6b53d241/go.mod#L37
162+
replace github.com/onsi/ginkgo/v2 => github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20241205171354-8006f302fd12

go.sum

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ github.com/go-openapi/validate v0.23.0/go.mod h1:EeiAZ5bmpSIOJV1WLfyYF9qp/B1ZgSa
180180
github.com/go-resty/resty/v2 v2.13.1 h1:x+LHXBI2nMB1vqndymf26quycC4aggYJ7DECYbiz03g=
181181
github.com/go-resty/resty/v2 v2.13.1/go.mod h1:GznXlLxkq6Nh4sU59rPmUw3VtgpO3aS96ORAI6Q7d+0=
182182
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
183-
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
184183
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
185184
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
186185
github.com/go-zookeeper/zk v1.0.3 h1:7M2kwOsc//9VeeFiPtf+uSJlVpU66x9Ba5+8XK7/TDg=
@@ -382,20 +381,22 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+
382381
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
383382
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
384383
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
385-
github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg=
386-
github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
387384
github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw=
388385
github.com/onsi/gomega v1.36.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
389386
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
390387
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
391388
github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM=
392389
github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
390+
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250702172817-97309544869d h1:nlVcuw7cyXIYMtQn97y/CMq1yoovvLnc2AFqi15DgXA=
391+
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250702172817-97309544869d/go.mod h1:6gkP5f2HL0meusT0Aim8icAspcD1cG055xxBZ9yC68M=
393392
github.com/openshift/api v0.0.0-20250320170726-75d64d71980b h1:GGuFSHESP0BSOu70AqV4u9IVrjYdaeu4Id+HXRIOvkw=
394393
github.com/openshift/api v0.0.0-20250320170726-75d64d71980b/go.mod h1:yk60tHAmHhtVpJQo3TwVYq2zpuP70iJIFDCmeKMIzPw=
395394
github.com/openshift/client-go v0.0.0-20250125113824-8e1f0b8fa9a7 h1:4iliLcvr1P9EUMZgIaSNEKNQQzBn+L6PSequlFOuB6Q=
396395
github.com/openshift/client-go v0.0.0-20250125113824-8e1f0b8fa9a7/go.mod h1:2tcufBE4Cu6RNgDCxcUJepa530kGo5GFVfR9BSnndhI=
397396
github.com/openshift/library-go v0.0.0-20250402180609-ce2ba53fb2a4 h1:MDnTCGqFUULZ4+0fr0sQYlB80yTun8nEZ062azvFSCk=
398397
github.com/openshift/library-go v0.0.0-20250402180609-ce2ba53fb2a4/go.mod h1:DAa3BGl0CFtkfJn/g5rU8kDDTErfMVA/QlFm4cvU+MI=
398+
github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20241205171354-8006f302fd12 h1:AKx/w1qpS8We43bsRgf8Nll3CGlDHpr/WAXvuedTNZI=
399+
github.com/openshift/onsi-ginkgo/v2 v2.6.1-0.20241205171354-8006f302fd12/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
399400
github.com/ovh/go-ovh v1.6.0 h1:ixLOwxQdzYDx296sXcgS35TOPEahJkpjMGtzPadCjQI=
400401
github.com/ovh/go-ovh v1.6.0/go.mod h1:cTVDnl94z4tl8pP1uZ/8jlVxntjSIf09bNcQ5TJSC7c=
401402
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
@@ -794,8 +795,8 @@ google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de h1:F6qOa9AZTYJXOUE
794795
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:VUhTRKeHn9wwcdrk73nvdC9gF178Tzhmt/qyaFcPLSo=
795796
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 h1:YcyjlL1PRr2Q17/I0dPk2JmYS5CDXfcdb2Z3YRioEbw=
796797
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7/go.mod h1:OCdP9MfskevB/rbYvHTsXTtKC+3bHWajPdoKgjcYkfo=
797-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 h1:2035KHhUv+EpyB+hWgJnaWKJOdX1E95w2S8Rr4uWKTs=
798-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
798+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61 h1:N9BgCIAUvn/M+p4NJccWPWb3BWh88+zyL0ll9HgbEeM=
799+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240924160255-9d4c2d233b61/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
799800
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
800801
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
801802
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=

test/ext/sanity.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package ext
2+
3+
import (
4+
g "github.com/onsi/ginkgo/v2"
5+
o "github.com/onsi/gomega"
6+
)
7+
8+
var _ = g.Describe("[Jira:Monitoring][sig-instrumentation] sanity test", func() {
9+
g.It("should always pass [Suite:openshift/cluster-monitoring-operator/conformance/parallel]", func() {
10+
o.Expect(true).To(o.BeTrue())
11+
})
12+
})

vendor/github.com/go-task/slim-sprig/v3/.editorconfig

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/go-task/slim-sprig/v3/.gitattributes

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)