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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
38 changes: 36 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ IMAGE_REGISTRY?=registry.svc.ci.openshift.org
# OpenShift Tests Extension (OpenShift API Server)
# -------------------------------------------------------------------
TESTS_EXT_BINARY := openshift-apiserver-tests-ext
TESTS_EXT_PACKAGE := ./cmd/openshift-apiserver-tests-ext
TESTS_EXT_PACKAGE := ./test/tests-extension/cmd

TESTS_EXT_GIT_COMMIT := $(shell git rev-parse --short HEAD)
TESTS_EXT_BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
Expand Down Expand Up @@ -59,8 +59,9 @@ verify:
# -------------------------------------------------------------------
.PHONY: tests-ext-build
tests-ext-build:
cd test/tests-extension && \
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)
go build -o ../../$(TESTS_EXT_BINARY) -ldflags "$(TESTS_EXT_LDFLAGS)" ./cmd

# -------------------------------------------------------------------
# Run "update" and strip env-specific metadata
Expand All @@ -71,3 +72,36 @@ tests-ext-update: tests-ext-build
for f in .openshift-tests-extension/*.json; do \
jq 'map(del(.codeLocations))' "$f" > tmpp && mv tmpp "$f"; \
done

# -------------------------------------------------------------------
# Additional tests-extension targets
# -------------------------------------------------------------------
.PHONY: tests-ext-verify
tests-ext-verify:
cd test/tests-extension && make verify

.PHONY: tests-ext-clean
tests-ext-clean:
cd test/tests-extension && make clean

.PHONY: tests-ext-run-suite
tests-ext-run-suite:
cd test/tests-extension && make run-suite SUITE=$(SUITE) ARTIFACT_DIR=$(ARTIFACT_DIR)

.PHONY: tests-ext-list
tests-ext-list:
cd test/tests-extension && make list-test-names

.PHONY: tests-ext-build-update
tests-ext-build-update:
cd test/tests-extension && make build-update

# Add tests-extension targets to main targets
all: tests-ext-build
.PHONY: all

clean: tests-ext-clean
.PHONY: clean

verify: tests-ext-verify
.PHONY: verify
6 changes: 2 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ require (
github.com/google/gofuzz v1.2.0
github.com/hashicorp/golang-lru v0.5.4
github.com/jteeuwen/go-bindata v3.0.8-0.20151023091102-a0ff2567cfb7+incompatible
github.com/onsi/ginkgo/v2 v2.23.4
github.com/onsi/gomega v1.38.0
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.1.1
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250804142706-7b3ab438a292
github.com/openshift/api v0.0.0-20250820105013-6282350d0c39
github.com/openshift/apiserver-library-go v0.0.0-20250710132015-f0d44ef6e53b
github.com/openshift/build-machinery-go v0.0.0-20250806130835-622c0378eb0d
Expand Down Expand Up @@ -81,7 +78,6 @@ require (
github.com/go-openapi/jsonpointer v0.21.1 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.1 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
Expand Down Expand Up @@ -116,6 +112,8 @@ require (
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/onsi/ginkgo/v2 v2.23.4 // indirect
github.com/onsi/gomega v1.38.0 // indirect
github.com/opencontainers/runc v1.2.1 // indirect
github.com/opencontainers/runtime-spec v1.2.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,6 @@ github.com/opencontainers/runc v1.2.1 h1:mQkmeFSUxqFaVmvIn1VQPeQIKpHFya5R07aJw0D
github.com/opencontainers/runc v1.2.1/go.mod h1:/PXzF0h531HTMsYQnmxXkBD7YaGShm/2zcRB79dksUc=
github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk=
github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250804142706-7b3ab438a292 h1:3athg6KQ+TaNfW4BWZDlGFt1ImSZEJWgzXtPC1VPITI=
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250804142706-7b3ab438a292/go.mod h1:6gkP5f2HL0meusT0Aim8icAspcD1cG055xxBZ9yC68M=
github.com/openshift/api v0.0.0-20250820105013-6282350d0c39 h1:X42iTyo3AAHS36BkiBkU8FvxfK8NEDmnBi3QrnaCIlA=
github.com/openshift/api v0.0.0-20250820105013-6282350d0c39/go.mod h1:SPLf21TYPipzCO67BURkCfK6dcIIxx0oNRVWaOyRcXM=
github.com/openshift/apiserver-library-go v0.0.0-20250710132015-f0d44ef6e53b h1:rIfs2f1zo9GLyxk6tak2bHzX01VTz6Xheay2NECfZpg=
Expand Down
12 changes: 0 additions & 12 deletions test/extended/main.go

This file was deleted.

38 changes: 38 additions & 0 deletions test/tests-extension/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work

# Build artifacts
bin/
.openshift-tests-extension/

# IDE files
.vscode/
.idea/
*.swp
*.swo
*~

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
138 changes: 138 additions & 0 deletions test/tests-extension/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Get the directory where this Makefile is, so we can use it below for including
DIR := $(strip $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))))

# Definitions for the extended tests

GO_PKG_NAME := github.com/openshift-eng/openshift-tests-extension

GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo 'unknown')
BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
GIT_TREE_STATE := $(shell if git rev-parse --git-dir > /dev/null 2>&1; then if git diff --quiet; then echo clean; else echo dirty; fi; else echo unknown; fi)

LDFLAGS := -X '$(GO_PKG_NAME)/pkg/version.CommitFromGit=$(GIT_COMMIT)' \
-X '$(GO_PKG_NAME)/pkg/version.BuildDate=$(BUILD_DATE)' \
-X '$(GO_PKG_NAME)/pkg/version.GitTreeState=$(GIT_TREE_STATE)'

REPO_ROOT := $(shell git rev-parse --show-toplevel)
METADATA := $(REPO_ROOT)/.openshift-tests-extension/openshift_payload_openshift-apiserver.json

.PHONY: help
help: #HELP Display essential help.
@awk 'BEGIN {FS = ":[^#]*#HELP"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\n"} /^[a-zA-Z_0-9-]+:.*#HELP / { printf " \033[36m%-17s\033[0m %s\n", $$1, $$2 } ' $(MAKEFILE_LIST)

#SECTION Tests
TOOLS_BIN_DIR := $(CURDIR)/bin

.PHONY: run-suite #HELP Run tests by suite name and generate JUnit report (e.g., make run-suite SUITE=openshift/openshift-apiserver/all ARTIFACT_DIR=/tmp/artifacts)
run-suite: build #HELP Run tests by suite name and generate JUnit report
@if [ -z "$(SUITE)" ]; then \
echo "Error: SUITE variable is required. Available suites:"; \
echo " - openshift/openshift-apiserver/all"; \
echo " - openshift/openshift-apiserver/conformance/parallel"; \
echo " - openshift/openshift-apiserver/conformance/serial"; \
echo " - openshift/openshift-apiserver/optional/slow"; \
echo ""; \
echo "Usage: make run-suite SUITE=openshift/openshift-apiserver/all [ARTIFACT_DIR=/tmp/artifacts]"; \
exit 1; \
fi
@ARTIFACT_DIR_FINAL=$${ARTIFACT_DIR:-$(CURDIR)}; \
echo "Using ARTIFACT_DIR: $$ARTIFACT_DIR_FINAL"; \
mkdir -p $$ARTIFACT_DIR_FINAL; \
$(TOOLS_BIN_DIR)/openshift-apiserver-tests-ext run-suite $(SUITE) -j $$ARTIFACT_DIR_FINAL/junit_$(shell date +%Y%m%d-%H%M%S).xml

#SECTION Development
.PHONY: verify #HELP To verify the code
verify: tidy fmt vet lint

.PHONY: tidy #HELP Run go mod tidy.
tidy:
go mod tidy

.PHONY: fmt
fmt: #HELP Run go fmt against code.
go fmt ./...

.PHONY: vet
vet: #HELP Run go vet against code.
go vet ./...

.PHONY: lint
lint: #HELP Run golangci linter.
@echo "Linting not configured for tests-extension"

.PHONY: fix-lint
fix-lint: #HELP Fix lint issues
@echo "Linting not configured for tests-extension"

# GO_COMPLIANCE_POLICY="exempt_all" must only be used for test related binaries.
# It prevents various FIPS compliance policies from being applied to this compilation.
# Do not set globally.
.PHONY: build
build: #HELP Build the extended tests binary
@mkdir -p $(TOOLS_BIN_DIR)
GO_COMPLIANCE_POLICY="exempt_all" go build -ldflags "$(LDFLAGS)" -o $(TOOLS_BIN_DIR)/openshift-apiserver-tests-ext ./cmd/...

.PHONY: update-metadata
update-metadata: build #HELP Build and run 'update-metadata' to generate test metadata
$(TOOLS_BIN_DIR)/openshift-apiserver-tests-ext update --component openshift:payload:openshift-apiserver
$(MAKE) clean-metadata


# Ensure TestID is unique over time.
# TestID is built over Product:Type:ComponentName:TestDescription
# (i.e. openshift:payload:openshift-apiserver:TestName)
# Details:
# - https://github.com/openshift/enhancements/blob/master/enhancements/testing/openshift-tests-extension.md#test-id
# - https://github.com/openshift-eng/ci-test-mapping
#──────────────────────────────────────────────────────────────
# How to rename a test?
# 1. Run: make list-test-names
# 2. Find the current full test name (e.g. "[sig-abc] My test does XYZ")
# 3. Add a Ginkgo label: ginkgo.Label("original-name:[sig-abc] My test does XYZ"). if there is existing original-name label, please do not update the label again and keep it unchanged.
# 4. Change the test name string and run: make build-update
# **Example**
# It("should pass a renamed sanity check",
# Label("original-name:[sig-openshift-apiserver] OLMv1 should pass a trivial sanity check"),
# func(ctx context.Context) {
# Expect(len("test")).To(BeNumerically(">", 0))
# })
# Note: You only add the label once. Do not update it after future renames.
#──────────────────────────────────────────────────────────────
# How to delete a test?
# 1. Run: make list-test-names
# 2. In main.go add:
# ext.IgnoreObsoleteTests(
# "[sig-openshift-apiserver] My removed test name",
# )
# 3. Delete the test code in your suite file (e.g. oas.go)
# 4. Run: make build-update.
# This will regenerate the metadata without the test entry.
#────────────────────────────────────────────────────────────────────
.PHONY: build-update
build-update: build update-metadata #HELP Build and update metadata and sanitize output

.PHONY: clean
clean: #HELP Remove build artifacts
rm -rf $(TOOLS_BIN_DIR)

#SECTION Metadata

.PHONY: list-test-names
list-test-names: build #HELP Show current full test names
@$(TOOLS_BIN_DIR)/openshift-apiserver-tests-ext list -o names

# Remove 'codeLocations' to avoid absolute paths like:
# "/Users/$(USER)/go/src/.../oas.go:12"
# These are machine-specific and make the metadata non-idempotent.
# More info: https://issues.redhat.com/browse/TRT-2186
.PHONY: clean-metadata
clean-metadata: #HELP Remove 'codeLocations' from metadata JSON
@echo "Cleaning metadata (removing codeLocations)..."
@jq 'map(del(.codeLocations))' $(METADATA) > $(METADATA).tmp && mv $(METADATA).tmp $(METADATA)

.PHONY: verify-metadata #HELP To verify that the metadata was properly updated
verify-metadata: update-metadata
@if ! git diff --exit-code $(METADATA); then \
echo "ERROR: Metadata is out of date. Please run 'make build-update' and commit the result."; \
exit 1; \
fi
42 changes: 22 additions & 20 deletions test/extended/README.md → test/tests-extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ They use the framework: https://github.com/openshift-eng/openshift-tests-extensi

| Command | Description |
|----------------------------------------------------------------------------|--------------------------------------------------------------------------|
| `make tests-ext-build` | Builds the test extension binary. |
| `./openshift-apiserver-tests-ext list` | Lists all available test cases. |
| `./openshift-apiserver-tests-ext run-suite <suite-name>` | Runs a test suite. e.g., `openshift/openshift-apiserver/conformance/parallel` |
| `./openshift-apiserver-tests-ext run <test-name>` | Runs one specific test. |
| `make build` | Builds the test extension binary. |
| `./bin/openshift-apiserver-tests-ext list` | Lists all available test cases. |
| `make run-suite SUITE=openshift/openshift-apiserver/all` | Runs a test suite. e.g., `openshift/openshift-apiserver/conformance/parallel` |
| `./bin/openshift-apiserver-tests-ext run <test-name>` | Runs one specific test. |


## How to Run the Tests Locally
Expand All @@ -22,7 +22,7 @@ Use the environment variable `KUBECONFIG` to point to your cluster configuration

```shell
export KUBECONFIG=path/to/kubeconfig
./openshift-apiserver-tests-ext run <test-name>
make run-suite SUITE=openshift/openshift-apiserver/all
```

### Local Test using OCP
Expand All @@ -48,25 +48,25 @@ export KUBECONFIG=~/.kube/cluster-bot.kubeconfig

**Example:**
```shell
./openshift-apiserver-tests-ext run-suite openshift/openshift-apiserver/all
make run-suite SUITE=openshift/openshift-apiserver/all
```

## Writing Tests

You can write tests in the `test/extended/` directory.
You can write tests in the `test/` directory.

## Development Workflow

- Add or update tests in: `test/extended/`
- Run `make build` to build the operator binary and `make tests-ext-build` for the test binary.
- Add or update tests in: `test/`
- Run `make build` to build the test binary.
- You can run the full suite or one test using the commands in the table above.
- Before committing your changes:
- Run `make tests-ext-update`
- Run `make build-update`
- Run `make verify` to check formatting, linting, and validation

## How to Rename a Test

1. Run `./openshift-apiserver-tests-ext list` to see the current test names
1. Run `make list-test-names` to see the current test names
2. Find the name of the test you want to rename
3. Add a Ginkgo label with the original name, like this:

Expand All @@ -78,14 +78,14 @@ It("should pass a renamed sanity check",
})
```

4. Run `make tests-ext-update` to update the metadata
4. Run `make build-update` to update the metadata

**Note:** Only add the label once. Do not update it again after future renames.

## How to Delete a Test

1. Run `./openshift-apiserver-tests-ext list` to find the test name
2. Add the test name to the `IgnoreObsoleteTests` block in `cmd/openshift-apiserver-tests-ext/main.go`, like this:
1. Run `make list-test-names` to find the test name
2. Add the test name to the `IgnoreObsoleteTests` block in `cmd/main.go`, like this:

```go
ext.IgnoreObsoleteTests(
Expand All @@ -94,7 +94,7 @@ ext.IgnoreObsoleteTests(
```

3. Delete the test code from your suite.
4. Run `make tests-ext-update` to clean the metadata
4. Run `make build-update` to clean the metadata

**WARNING**: Deleting a test may cause issues with Sippy https://sippy.dptools.openshift.org/sippy-ng/
or other tools that expected the Unique TestID tracked outside of this repository. [More info](https://github.com/openshift-eng/ci-test-mapping)
Expand Down Expand Up @@ -135,10 +135,12 @@ More info: https://docs.ci.openshift.org/docs/architecture/ci-operator/#testing-

| Target | Description |
|--------------------------|------------------------------------------------------------------------------|
| `make build` | Builds the operator binary. |
| `make tests-ext-build` | Builds the test extension binary. |
| `make tests-ext-update` | Updates the metadata JSON file and cleans machine-specific codeLocations. |
| `make build` | Builds the test extension binary. |
| `make run-suite` | Runs tests by suite name and generates JUnit report. |
| `make build-update` | Builds and updates metadata and sanitizes output. |
| `make verify` | Runs formatting, vet, and linter. |
| `make list-test-names` | Shows current full test names. |
| `make clean` | Removes build artifacts. |

**Note:** Metadata is stored in: `.openshift-tests-extension/openshift_payload_openshift-apiserver.json`

Expand All @@ -163,9 +165,9 @@ rely on these tests to validate that their solutions are compatible and conforma
It is generally preferred to include tests in the same image as the component
being tested whenever possible.

### Why do we need to run `make tests-ext-update`?
### Why do we need to run `make build-update`?

Running `make tests-ext-update` ensures that each test gets a unique and stable **TestID** over time.
Running `make build-update` ensures that each test gets a unique and stable **TestID** over time.

The TestID is used to identify tests across the OpenShift CI/CD pipeline and reporting tools like Sippy.
It helps track test results, detect regressions, and ensures the correct tests are
Expand Down
Loading