Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/cluster-openshift-apiserver-operator
/cluster-openshift-apiserver-operator-tests-ext
/cluster-openshift-apiserver-operator-tests-ext.gz
.idea/
telepresence.log

3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.24-openshift-4.21 AS builder
WORKDIR /go/src/github.com/openshift/cluster-openshift-apiserver-operator
COPY . .
RUN GODEBUG=tls13=1 make build \
&& make tests-ext-build \
RUN GODEBUG=tls13=1 make build --warn-undefined-variables \
&& gzip cluster-openshift-apiserver-operator-tests-ext

FROM registry.ci.openshift.org/ocp/4.21:base-rhel9
Expand Down
37 changes: 0 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,6 @@ IMAGE_REGISTRY :=registry.svc.ci.openshift.org
ENCRYPTION_PROVIDERS=aescbc aesgcm
ENCRYPTION_PROVIDER?=aescbc

# -------------------------------------------------------------------
# OpenShift Tests Extension (Cluster OpenShift API Server Operator)
# -------------------------------------------------------------------
TESTS_EXT_BINARY := cluster-openshift-apiserver-operator-tests-ext
TESTS_EXT_PACKAGE := ./cmd/cluster-openshift-apiserver-operator-tests-ext

TESTS_EXT_GIT_COMMIT := $(shell git rev-parse --short HEAD)
TESTS_EXT_BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
TESTS_EXT_GIT_TREE_STATE := $(shell if git diff --quiet; then echo clean; else echo dirty; fi)

TESTS_EXT_LDFLAGS := -X 'github.com/openshift-eng/openshift-tests-extension/pkg/version.CommitFromGit=$(TESTS_EXT_GIT_COMMIT)' \
-X 'github.com/openshift-eng/openshift-tests-extension/pkg/version.BuildDate=$(TESTS_EXT_BUILD_DATE)' \
-X 'github.com/openshift-eng/openshift-tests-extension/pkg/version.GitTreeState=$(TESTS_EXT_GIT_TREE_STATE)'


# This will call a macro called "build-image" which will generate image specific targets based on the parameters:
# $0 - macro name
# $1 - target name
Expand All @@ -51,10 +36,6 @@ $(call add-bindata,v3.11.0,./bindata/v3.11.0/...,bindata,v311_00_assets,pkg/oper

$(call verify-golang-versions,Dockerfile)

clean:
$(RM) ./cluster-openshift-apiserver-operator
.PHONY: clean

GO_TEST_PACKAGES :=./pkg/... ./cmd/...

TEST_E2E_ENCRYPTION_TARGETS=$(addprefix test-e2e-encryption-,$(ENCRYPTION_PROVIDERS))
Expand Down Expand Up @@ -92,24 +73,6 @@ test-e2e: GO_TEST_PACKAGES :=./test/e2e/...
test-e2e: GO_TEST_FLAGS += -timeout 1h
test-e2e: test-unit

# -------------------------------------------------------------------
# Build binary with metadata (CI-compliant)
# -------------------------------------------------------------------
.PHONY: tests-ext-build
tests-ext-build:
GOOS=$(GOOS) GOARCH=$(GOARCH) GO_COMPLIANCE_POLICY=exempt_all CGO_ENABLED=0 \
go build -o $(TESTS_EXT_BINARY) -ldflags "$(TESTS_EXT_LDFLAGS)" $(TESTS_EXT_PACKAGE)

# -------------------------------------------------------------------
# Run "update" and strip env-specific metadata
# -------------------------------------------------------------------
.PHONY: tests-ext-update
tests-ext-update: tests-ext-build
./$(TESTS_EXT_BINARY) update
for f in .openshift-tests-extension/*.json; do \
jq 'map(del(.codeLocations))' "$$f" > tmpp && mv tmpp "$$f"; \
done

# Configure the 'telepresence' target
# See vendor/github.com/openshift/build-machinery-go/scripts/run-telepresence.sh for usage and configuration details
export TP_DEPLOYMENT_YAML ?=./manifests/0000_30_openshift-apiserver-operator_07_deployment.yaml
Expand Down
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,36 @@ All of these are sparse configurations, i.e. unvalidated json snippets which are
## Debugging

To gather all information necessary for debugging operator please use the [must-gather](https://github.com/openshift/must-gather) tool.

## Tests

This repository is compatible with the [OpenShift Tests Extension (OTE)](https://github.com/openshift-eng/openshift-tests-extension) framework.

### Building the test binary

```bash
make build
```

### Running test suites and tests

```bash
# Run a specific test suite or test
./cluster-openshift-apiserver-operator-tests-ext run-suite openshift/cluster-openshift-apiserver-operator/all
./cluster-openshift-apiserver-operator-tests-ext run-test "test-name"

# Run with JUnit output
./cluster-openshift-apiserver-operator-tests-ext run-suite openshift/cluster-openshift-apiserver-operator/all --junit-path /tmp/junit.xml
```

### Listing available tests and suites

```bash
# List all test suites
./cluster-openshift-apiserver-operator-tests-ext list suites

# List tests in a suite
./cluster-openshift-apiserver-operator-tests-ext list tests --suite=openshift/cluster-openshift-apiserver-operator/all
```

For more information about the OTE framework, see the [openshift-tests-extension documentation](https://github.com/openshift-eng/openshift-tests-extension).
126 changes: 34 additions & 92 deletions cmd/cluster-openshift-apiserver-operator-tests-ext/main.go
Original file line number Diff line number Diff line change
@@ -1,112 +1,54 @@
/*
This command is used to run the Cluster OpenShift API Server Operator tests extension for OpenShift.
It registers the Cluster OpenShift API Server Operator tests with the OpenShift Tests Extension framework
and provides a command-line interface to execute them.
For further information, please refer to the documentation at:
https://github.com/openshift-eng/openshift-tests-extension/blob/main/cmd/example-tests/main.go
*/
package main

import (
"fmt"
"context"
"os"
"strings"

"github.com/openshift-eng/openshift-tests-extension/pkg/cmd"
e "github.com/openshift-eng/openshift-tests-extension/pkg/extension"
et "github.com/openshift-eng/openshift-tests-extension/pkg/extension/extensiontests"
g "github.com/openshift-eng/openshift-tests-extension/pkg/ginkgo"

"github.com/spf13/cobra"
"k8s.io/component-base/cli"

otecmd "github.com/openshift-eng/openshift-tests-extension/pkg/cmd"
oteextension "github.com/openshift-eng/openshift-tests-extension/pkg/extension"
"github.com/openshift/cluster-openshift-apiserver-operator/pkg/version"

// The import below is necessary to ensure that the OAS operator tests are registered with the extension.
_ "github.com/openshift/cluster-openshift-apiserver-operator/test/extended"
"k8s.io/klog/v2"
)

func main() {
registry := e.NewRegistry()
ext := e.NewExtension("openshift", "payload", "cluster-openshift-apiserver-operator")
command := newOperatorTestCommand(context.Background())
code := cli.Run(command)
os.Exit(code)
}

// Suite: conformance/parallel (fast, parallel-safe)
ext.AddSuite(e.Suite{
Name: "openshift/cluster-openshift-apiserver-operator/conformance/parallel",
Parents: []string{"openshift/conformance/parallel"},
Qualifiers: []string{
`!(name.contains("[Serial]") || name.contains("[Slow]"))`,
},
})
func newOperatorTestCommand(ctx context.Context) *cobra.Command {
registry := prepareOperatorTestsRegistry()

// Suite: conformance/serial (explicitly serial tests)
ext.AddSuite(e.Suite{
Name: "openshift/cluster-openshift-apiserver-operator/conformance/serial",
Parents: []string{"openshift/conformance/serial"},
Qualifiers: []string{
`name.contains("[Serial]")`,
},
})

// Suite: optional/slow (long-running tests)
ext.AddSuite(e.Suite{
Name: "openshift/cluster-openshift-apiserver-operator/optional/slow",
Parents: []string{"openshift/optional/slow"},
Qualifiers: []string{
`name.contains("[Slow]")`,
cmd := &cobra.Command{
Use: "cluster-openshift-apiserver-operator-tests-ext",
Short: "A binary used to run cluster-openshift-apiserver-operator tests as part of OTE.",
Run: func(cmd *cobra.Command, args []string) {
// no-op, logic is provided by the OTE framework
if err := cmd.Help(); err != nil {
klog.Fatal(err)
}
},
})

// Suite: all (includes everything)
ext.AddSuite(e.Suite{
Name: "openshift/cluster-openshift-apiserver-operator/all",
})

specs, err := g.BuildExtensionTestSpecsFromOpenShiftGinkgoSuite()
if err != nil {
panic(fmt.Sprintf("couldn't build extension test specs from ginkgo: %+v", err.Error()))
}

// Ensure [Disruptive] tests are also [Serial]
specs = specs.Walk(func(spec *et.ExtensionTestSpec) {
if strings.Contains(spec.Name, "[Disruptive]") && !strings.Contains(spec.Name, "[Serial]") {
spec.Name = strings.ReplaceAll(
spec.Name,
"[Disruptive]",
"[Serial][Disruptive]",
)
}
})

// Preserve original-name labels for renamed tests
specs = specs.Walk(func(spec *et.ExtensionTestSpec) {
for label := range spec.Labels {
if strings.HasPrefix(label, "original-name:") {
parts := strings.SplitN(label, "original-name:", 2)
if len(parts) > 1 {
spec.OriginalName = parts[1]
}
}
}
})

// Ignore obsolete tests
ext.IgnoreObsoleteTests(
// "[sig-openshift-apiserver] <test name here>",
)

// Initialize environment before running any tests
specs.AddBeforeAll(func() {
// do stuff
})
if v := version.Get().String(); len(v) == 0 {
cmd.Version = "<unknown>"
} else {
cmd.Version = v
}

ext.AddSpecs(specs)
registry.Register(ext)
cmd.AddCommand(otecmd.DefaultExtensionCommands(registry)...)

root := &cobra.Command{
Long: "Cluster OpenShift API Server Operator Tests Extension",
}
return cmd
}

root.AddCommand(cmd.DefaultExtensionCommands(registry)...)
func prepareOperatorTestsRegistry() *oteextension.Registry {
registry := oteextension.NewRegistry()
extension := oteextension.NewExtension("openshift", "payload", "cluster-openshift-apiserver-operator")

if err := root.Execute(); err != nil {
os.Exit(1)
}
registry.Register(extension)
return registry
}
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ require (
github.com/ghodss/yaml v1.0.0
github.com/go-bindata/go-bindata v3.1.2+incompatible
github.com/gonum/graph v0.0.0-20190426092945-678096d81a4b
github.com/onsi/ginkgo/v2 v2.23.4
github.com/onsi/gomega v1.38.0
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250804142706-7b3ab438a292
github.com/openshift/api v0.0.0-20250724151358-f313adb86331
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee
Expand Down Expand Up @@ -49,7 +47,6 @@ require (
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/gonum/blas v0.0.0-20181208220705-f22b278b28ac // indirect
Expand All @@ -74,6 +71,8 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/onsi/ginkgo/v2 v2.23.4 // indirect
github.com/onsi/gomega v1.38.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/profile v1.7.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En
github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE=
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
Expand Down

This file was deleted.

Loading