Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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
140 changes: 140 additions & 0 deletions test/tests-extension/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# 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)'


METADATA := $(shell pwd)/.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
@if [ -z "$(ARTIFACT_DIR)" ]; then \
echo "Warning: ARTIFACT_DIR not set, using current directory for JUnit report"; \
ARTIFACT_DIR=.; \
fi
@mkdir -p $(ARTIFACT_DIR)
$(TOOLS_BIN_DIR)/openshift-apiserver-tests-ext run-suite $(SUITE) -j $(ARTIFACT_DIR)/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
Loading