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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
*.out

/oauth-apiserver
/oauth-apiserver-tests-ext
/oauth-apiserver-tests-ext
/oauth-apiserver-tests-ext.gz
35 changes: 0 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,6 @@ include $(addprefix ./vendor/github.com/openshift/build-machinery-go/make/, \
)

IMAGE_REGISTRY?=registry.svc.ci.openshift.org
# -------------------------------------------------------------------
# OpenShift Tests Extension (OpenShift Oauth APIServer)
# -------------------------------------------------------------------
TESTS_EXT_BINARY := oauth-apiserver-tests-ext
TESTS_EXT_PACKAGE := ./cmd/oauth-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
Expand All @@ -33,10 +20,6 @@ $(call build-image,ocp-oauth-apiserver,$(IMAGE_REGISTRY)/ocp/4.3:oauth-apiserver

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

clean:
$(RM) ./oauth-apiserver
.PHONY: clean

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

update:
Expand Down Expand Up @@ -67,21 +50,3 @@ run-e2e-test: GO_TEST_FLAGS += ^${WHAT}$$
run-e2e-test: GO_TEST_PACKAGES += -count 1
run-e2e-test: test-unit
.PHONY: run-e2e-test

# -------------------------------------------------------------------
# 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
6 changes: 0 additions & 6 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
reviewers:
- deads2k
- tkashem
- p0lyn0mial
- benluddy
- sanchezl
- dgrisonnet
approvers:
- deads2k
- tkashem
- p0lyn0mial
- benluddy
- sanchezl
- dgrisonnet
component: oauth-apiserver
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## 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
./oauth-apiserver-tests-ext run-suite "openshift/oauth-apiserver/all"
./oauth-apiserver-tests-ext run-test "test-name"

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

### Listing available tests and suites

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

# List tests in a suite
./oauth-apiserver-tests-ext list tests --suite=openshift/oauth-apiserver/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/oauth-apiserver-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 OpenShift OAuth API Server tests extension for OpenShift.
It registers the OpenShift OAuth API Server 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/oauth-apiserver/pkg/version"

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

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

// Suite: conformance/parallel (fast, parallel-safe)
ext.AddSuite(e.Suite{
Name: "openshift/oauth-apiserver/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/oauth-apiserver/conformance/serial",
Parents: []string{"openshift/conformance/serial"},
Qualifiers: []string{
`name.contains("[Serial]")`,
},
})

// Suite: optional/slow (long-running tests)
ext.AddSuite(e.Suite{
Name: "openshift/oauth-apiserver/optional/slow",
Parents: []string{"openshift/optional/slow"},
Qualifiers: []string{
`name.contains("[Slow]")`,
cmd := &cobra.Command{
Use: "oauth-apiserver-tests-ext",
Short: "A binary used to run oauth-apiserver 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/oauth-apiserver/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: "OpenShift OAuth API Server Tests Extension",
}
return cmd
}

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

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 @@ -8,8 +8,6 @@ require (
github.com/google/go-cmp v0.7.0
github.com/google/uuid v1.6.0
github.com/jteeuwen/go-bindata v3.0.8-0.20151023091102-a0ff2567cfb7+incompatible
github.com/onsi/ginkgo/v2 v2.24.0
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-20250812222054-88b2b21555f3
github.com/openshift/apiserver-library-go v0.0.0-20250710132015-f0d44ef6e53b
Expand Down Expand Up @@ -56,7 +54,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-jwt/jwt/v4 v4.5.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
Expand All @@ -77,6 +74,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.24.0 // 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: 0 additions & 1 deletion images/Dockerfile.rhel7
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.24-openshift-4.21 AS
WORKDIR /go/src/github.com/openshift/oauth-apiserver
COPY . .
RUN make build --warn-undefined-variables \
&& make tests-ext-build \
&& gzip oauth-apiserver-tests-ext

FROM registry.ci.openshift.org/ocp/4.21:base-rhel9
Expand Down

This file was deleted.

Loading