Skip to content
Closed
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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/openshift-apiserver
/openshift-apiserver-tests-ext
/openshift-apiserver-tests-ext.gz
/_output
.idea
/test/extended/tests-extension/bin/
48 changes: 48 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ include $(addprefix ./vendor/github.com/openshift/build-machinery-go/make/, \

IMAGE_REGISTRY?=registry.svc.ci.openshift.org

# -------------------------------------------------------------------
# OpenShift Tests Extension (OpenShift API Server)
# -------------------------------------------------------------------
TESTS_EXT_BINARY := openshift-apiserver-tests-ext
TESTS_EXT_DIR := ./test/extended/tests-extension
TESTS_EXT_OUTPUT := $(TESTS_EXT_DIR)/$(TESTS_EXT_BINARY)
TESTS_EXT_PACKAGE := ./cmd/openshift-apiserver-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 suffix
Expand All @@ -20,6 +36,10 @@ $(call build-image,ocp-openshift-apiserver,$(IMAGE_REGISTRY)/ocp/4.3:openshift-a

$(call verify-golang-versions,images/Dockerfile.rhel)

clean: tests-ext-clean
$(RM) ./openshift-apiserver
.PHONY: clean

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

update:
Expand All @@ -35,3 +55,31 @@ verify:
hack/verify-generated-defaulters.sh
hack/verify-generated-openapi.sh
.PHONY: verify

# -------------------------------------------------------------------
# Build binary with metadata (CI-compliant)
# -------------------------------------------------------------------
.PHONY: tests-ext-build
tests-ext-build:
$(MAKE) -C $(TESTS_EXT_DIR) build

# -------------------------------------------------------------------
# Run "update" and strip env-specific metadata
# -------------------------------------------------------------------
.PHONY: tests-ext-update
tests-ext-update:
$(MAKE) -C $(TESTS_EXT_DIR) build-update

# -------------------------------------------------------------------
# Clean test extension binaries
# -------------------------------------------------------------------
.PHONY: tests-ext-clean
tests-ext-clean:
$(MAKE) -C $(TESTS_EXT_DIR) clean

# -------------------------------------------------------------------
# Run test suite
# -------------------------------------------------------------------
.PHONY: run-suite
run-suite:
$(MAKE) -C $(TESTS_EXT_DIR) run-suite SUITE=$(SUITE) JUNIT_DIR=$(JUNIT_DIR)
8 changes: 8 additions & 0 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
reviewers:
- deads2k
- mfojtik
- sttts
- tkashem
- p0lyn0mial
- benluddy
- sanchezl
- dgrisonnet
approvers:
- deads2k
- mfojtik
- sttts
- tkashem
- p0lyn0mial
- benluddy
- sanchezl
Expand Down
33 changes: 1 addition & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1 @@
## 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
./openshift-apiserver-tests-ext run-suite openshift/openshift-apiserver/all
./openshift-apiserver-tests-ext run-test "test-name"

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

### Listing available tests and suites

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

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

For more information about the OTE framework, see the [openshift-tests-extension documentation](https://github.com/openshift-eng/openshift-tests-extension).
### TODO: ADD README.md here
54 changes: 0 additions & 54 deletions cmd/openshift-apiserver-tests-ext/main.go

This file was deleted.

1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ require (
github.com/jteeuwen/go-bindata v3.0.8-0.20151023091102-a0ff2567cfb7+incompatible
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-20251113163031-356b66aa5c24
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
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,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-20251113163031-356b66aa5c24 h1:bwmjtFaipakIwAyZxnDLgtkLY1Nf1nK9lRCmADvHirE=
github.com/openshift-eng/openshift-tests-extension v0.0.0-20251113163031-356b66aa5c24/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
5 changes: 3 additions & 2 deletions images/Dockerfile.rhel
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.24-openshift-4.21 AS
WORKDIR /go/src/github.com/openshift/openshift-apiserver
COPY . .
RUN make build --warn-undefined-variables \
&& gzip openshift-apiserver-tests-ext
&& make tests-ext-build \
&& gzip test/extended/tests-extension/bin/openshift-apiserver-tests-ext

FROM registry.ci.openshift.org/ocp/4.21:base-rhel9
COPY --from=builder /go/src/github.com/openshift/openshift-apiserver/openshift-apiserver /usr/bin/
COPY --from=builder /go/src/github.com/openshift/openshift-apiserver/openshift-apiserver-tests-ext.gz /usr/bin/
COPY --from=builder /go/src/github.com/openshift/openshift-apiserver/test/extended/tests-extension/bin/openshift-apiserver-tests-ext.gz /usr/bin/
ENTRYPOINT ["/usr/bin/openshift-apiserver"]
LABEL io.k8s.display-name="OpenShift API Server Command" \
io.k8s.description="OpenShift is a platform for developing, building, and deploying containerized applications." \
Expand Down
88 changes: 88 additions & 0 deletions test/extended/tests-extension/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# 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

TOOLS_BIN_DIR := $(CURDIR)/bin
BINARY_NAME := openshift-apiserver-tests-ext

.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 Development
.PHONY: verify #HELP To verify the code
verify: tidy fmt vet

.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: build
build: #HELP Build the extended tests binary
@mkdir -p $(TOOLS_BIN_DIR)
GO_COMPLIANCE_POLICY="exempt_all" CGO_ENABLED=0 go build -mod=mod -ldflags "$(LDFLAGS)" -o $(TOOLS_BIN_DIR)/$(BINARY_NAME) ./cmd/...

.PHONY: update-metadata
update-metadata: build #HELP Build and run 'update-metadata' to generate test metadata
$(TOOLS_BIN_DIR)/$(BINARY_NAME) update
$(MAKE) clean-metadata

.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)/$(BINARY_NAME) list -o names

.PHONY: run-suite
run-suite: build #HELP Run a test suite (usage: make run-suite SUITE=<suite-name> [JUNIT_DIR=<dir>])
@if [ -z "$(SUITE)" ]; then \
echo "Error: SUITE variable is required. Usage: make run-suite SUITE=<suite-name> [JUNIT_DIR=<dir>]"; \
exit 1; \
fi
@JUNIT_ARG=""; \
if [ -n "$(JUNIT_DIR)" ]; then \
mkdir -p $(JUNIT_DIR); \
JUNIT_ARG="--junit-path=$(JUNIT_DIR)/junit.xml"; \
fi; \
$(TOOLS_BIN_DIR)/$(BINARY_NAME) run-suite $(SUITE) $$JUNIT_ARG

.PHONY: clean-metadata
clean-metadata: #HELP Remove 'codeLocations' from metadata JSON
@echo "Cleaning metadata (removing codeLocations)..."
@for f in $(METADATA)/*.json; do \
jq 'map(del(.codeLocations))' "$$f" > "$$f.tmp" && mv "$$f.tmp" "$$f"; \
done

.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
17 changes: 17 additions & 0 deletions test/extended/tests-extension/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
reviewers:
- p0lyn0mial
- benluddy
- dgrisonnet
- dinhxuanvu
- xingxingxia
- wangke19
- gangwgr
approvers:
- p0lyn0mial
- benluddy
- dgrisonnet
- dinhxuanvu
- xingxingxia
- wangke19
- gangwgr
component: openshift-apiserver-tests
Loading