Skip to content

Commit c6c90ef

Browse files
committed
setup OTE freamwork and migration one case from openshift-tests-private repo
Signed-off-by: zhaozhanqi <zzhao@redhat.com>
1 parent 41be31e commit c6c90ef

File tree

7 files changed

+939
-1
lines changed

7 files changed

+939
-1
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.24-openshift-4.21 AS builder
22
WORKDIR /go/src/github.com/openshift/cluster-network-operator
33
COPY . .
4-
RUN hack/build-go.sh
4+
RUN hack/build-go.sh && make build-e2e-tests && gzip -9 test/bin/cluster-network-operator-tests-ext
55

66
FROM registry.ci.openshift.org/ocp/4.21:base-rhel9
77
COPY --from=builder /go/src/github.com/openshift/cluster-network-operator/cluster-network-operator /usr/bin/
88
COPY --from=builder /go/src/github.com/openshift/cluster-network-operator/cluster-network-check-endpoints /usr/bin/
99
COPY --from=builder /go/src/github.com/openshift/cluster-network-operator/cluster-network-check-target /usr/bin/
10+
COPY --from=builder /go/src/github.com/openshift/cluster-network-operator/test/bin/cluster-network-operator-tests-ext.gz /usr/bin/cluster-network-operator-tests-ext.gz
1011

1112
COPY manifests /manifests
1213
COPY bindata /bindata

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,10 @@ clean:
4646
$(RM) cluster-network-operator cluster-network-check-endpoints cluster-network-check-target
4747
.PHONY: clean
4848

49+
# Build the e2e test binary
50+
.PHONY: build-e2e-tests
51+
build-e2e-tests:
52+
@echo "Building cluster-network-operator-tests-ext binary..."
53+
$(MAKE) -C test build
54+
4955
GO_TEST_PACKAGES :=./pkg/... ./cmd/...

test/Makefile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Makefile for CNO E2E Test
2+
3+
# Binary name
4+
BINARY_NAME := cluster-network-operator-tests-ext
5+
6+
# Build directory
7+
BUILD_DIR := bin
8+
9+
# Go module and package
10+
GO_MODULE := github.com/openshift/cluster-network-operator
11+
12+
# Version information
13+
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
14+
BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
15+
16+
# Go build flags
17+
LDFLAGS := -X '$(GO_MODULE)/pkg/version.commitFromGit=$(GIT_COMMIT)' \
18+
-X '$(GO_MODULE)/pkg/version.buildDate=$(BUILD_DATE)' \
19+
-X '$(GO_MODULE)/pkg/version.versionFromGit=$(GIT_COMMIT)'
20+
21+
# Default target
22+
.PHONY: all
23+
all: build
24+
25+
# Build the binary
26+
.PHONY: build
27+
build:
28+
@echo "Building $(BINARY_NAME)..."
29+
@mkdir -p $(BUILD_DIR)
30+
cd cmd && go build -o ../$(BUILD_DIR)/$(BINARY_NAME) -ldflags="$(LDFLAGS)" .
31+
32+
# Build for Linux (useful for container builds)
33+
.PHONY: build-linux
34+
build-linux:
35+
@echo "Building $(BINARY_NAME) for Linux..."
36+
@mkdir -p $(BUILD_DIR)
37+
cd cmd && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
38+
go build -o ../$(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 -ldflags="$(LDFLAGS)" .
39+
40+
# Clean build artifacts
41+
.PHONY: clean
42+
clean:
43+
@echo "Cleaning build artifacts..."
44+
rm -rf $(BUILD_DIR)
45+

test/cmd/main.go

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

0 commit comments

Comments
 (0)