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.
22 changes: 9 additions & 13 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# Will be replaced in the CI
FROM golang:1.21 AS builder

WORKDIR /src

COPY ./ ./

RUN go build -o /bin/openstack-test ./cmd/openshift-tests
FROM golang:1.21 AS test-extension-builder
RUN mkdir -p /go/src/github.com/openshift/openstack-test
WORKDIR /go/src/github.com/openshift/openstack-test
COPY . .
RUN make tests-ext-build && \
cd bin && \
tar -czvf openstack-test-test-extension.tar.gz openstack-test-tests-ext && \
rm -f openstack-test-tests-ext

# Will be replaced in the CI with registry.ci.openshift.org/ocp/4.y:tools
FROM registry.access.redhat.com/ubi8/ubi

COPY --from=builder /bin/openstack-test /usr/bin/

USER 1000:1000
ENV LC_ALL en_US.UTF-8

ENTRYPOINT ["/usr/bin/openstack-test"]
COPY --from=test-extension-builder /go/src/github.com/openshift/openstack-test/bin/openstack-test-test-extension.tar.gz /usr/bin/
27 changes: 15 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
TESTS_EXT_BINARY := bin/openstack-test-tests-ext

openstack-tests: test/extended/openstack/* cmd/openshift-tests/*
go build -o $@ ./cmd/openshift-tests
.PHONY: tests-ext-build
tests-ext-build:
@echo "Building OTE test extension binary..."
@mkdir -p bin
GOTOOLCHAIN=auto GOSUMDB=sum.golang.org go build -mod=vendor -o $(TESTS_EXT_BINARY) ./cmd/extension
@echo "Extension binary built: $(TESTS_EXT_BINARY)"

# Update generated artifacts.
update:
mkdir -p ./test/extented/util/annotate/generated
go generate ./test/extended
.PHONY: update
.PHONY: extension
extension: tests-ext-build

.PHONY: clean-extension
clean-extension:
@echo "Cleaning extension binary..."
@rm -f $(TESTS_EXT_BINARY)

.PHONY: verify
verify:
./hack/verify.sh
.PHONY: verify

run: openstack-tests
./$< run openshift/openstack
.PHONY: run
101 changes: 16 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,99 +1,30 @@
# openstack-test

This repository contains tests specific to OpenShift on OpenStack, based on the [openshift/origin][1] machinery.
OpenShift-on-OpenStack end-to-end test suite, built as an [openshift-tests-extension (OTE)][1] plugin.

The tests sit in [`test/extended/openstack`][2]
The tests sit in [`test/extended/openstack`][2].

Run the tests by exporting both OpenShift and OpenStack credentials, then running `make run`:
1. `export OS_CLOUD=<OS_CLOUD>`
1. `export KUBECONFIG=<kubeconfig>`
1. `make run`
## Build

[1]: https://github.com/openshift/origin
[2]: test/extended/openstack

---

## Rebase on Origin

### Step 1: Update Origin as a dependency

Identify the Origin commit you want to rebase `openstack-test` onto.

Origin is referenced as a dependency in `go.mod`. Update it with:
```sh
GONOPROXY=* GONOSUMDB=* go get -d github.com/openshift/origin@<latest-commit-sha>
make extension
```

### Step 2: Update Origin dependencies' overrides

In `go.mod`, manually replace all the overrides ("replace") to match Origin's
`go.mod`.
## List tests

### Step 3: Update Origin's code in openstack-test

We manually vendor Origin code in three packages. To ensure compatibility, manually rebase from Origin and then apply some changes:

```bash
cp ${ORIGIN}/cmd/openshift-tests/openshift-tests.go cmd/openshift-tests/openshift-tests.go
cp ${ORIGIN}/pkg/cmd/openshift-tests/run/*.go pkg/cmd/openshift-tests/run/
cp ${ORIGIN}/test/extended/util/annotate/*.go test/extended/util/annotate/
```sh
./bin/openstack-test-tests-ext list
```

Apply this diff to change Origin's code to use the locally-defined tests:
## Run tests

```diff
diff --git a/cmd/openshift-tests/openshift-tests.go b/cmd/openshift-tests/openshift-tests.go
index 1d06b4145f..292c587263 100644
--- a/cmd/openshift-tests/openshift-tests.go
+++ b/cmd/openshift-tests/openshift-tests.go
@@ -10,6 +10,7 @@ import (
"time"

"github.com/openshift/library-go/pkg/serviceability"
+ "github.com/openshift/openstack-test/pkg/cmd/openshift-tests/run"
"github.com/openshift/origin/pkg/cmd"
collectdiskcertificates "github.com/openshift/origin/pkg/cmd/openshift-tests/collect-disk-certificates"
"github.com/openshift/origin/pkg/cmd/openshift-tests/dev"
@@ -20,7 +21,6 @@ import (
"github.com/openshift/origin/pkg/cmd/openshift-tests/monitor/timeline"
"github.com/openshift/origin/pkg/cmd/openshift-tests/render"
risk_analysis "github.com/openshift/origin/pkg/cmd/openshift-tests/risk-analysis"
- "github.com/openshift/origin/pkg/cmd/openshift-tests/run"
run_disruption "github.com/openshift/origin/pkg/cmd/openshift-tests/run-disruption"
run_test "github.com/openshift/origin/pkg/cmd/openshift-tests/run-test"
run_upgrade "github.com/openshift/origin/pkg/cmd/openshift-tests/run-upgrade"
diff --git a/pkg/cmd/openshift-tests/run/command.go b/pkg/cmd/openshift-tests/run/command.go
index 57bdd4801e..49dd02a2e4 100644
--- a/pkg/cmd/openshift-tests/run/command.go
+++ b/pkg/cmd/openshift-tests/run/command.go
@@ -4,8 +4,8 @@ import (
"context"
"fmt"

+ "github.com/openshift/openstack-test/pkg/testsuites"
"github.com/openshift/origin/pkg/clioptions/imagesetup"
- "github.com/openshift/origin/pkg/testsuites"
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/kubectl/pkg/util/templates"
diff --git a/test/extended/util/annotate/annotate.go b/test/extended/util/annotate/annotate.go
index 6e47a3dc17..d66399ce77 100644
--- a/test/extended/util/annotate/annotate.go
+++ b/test/extended/util/annotate/annotate.go
@@ -7,7 +7,7 @@ import (

// this ensures that all origin tests are picked by ginkgo as defined
// in test/extended/include.go
- _ "github.com/openshift/origin/test/extended"
+ _ "github.com/openshift/openstack-test/test/extended"
)

func main() {
```
Export both OpenShift and OpenStack credentials, then:

### Step 4: Tidy up the dependencies
```sh
export OS_CLOUD=<OS_CLOUD>
export KUBECONFIG=<kubeconfig>
./bin/openstack-test-tests-ext run-suite openstack-test/all
```

```bash
go mod tidy && go mod vendor
```
[1]: https://github.com/openshift-eng/openshift-tests-extension
[2]: test/extended/openstack
139 changes: 139 additions & 0 deletions cmd/extension/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
package main

import (
"flag"
"fmt"
"os"
"regexp"
"strings"

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

"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/openshift/origin/test/extended/util"
framework "k8s.io/kubernetes/test/e2e/framework"

_ "github.com/openshift/openstack-test/test/extended/openstack"
)

func main() {
pflag.CommandLine = pflag.NewFlagSet("empty", pflag.ExitOnError)
flag.CommandLine = flag.NewFlagSet("empty", flag.ExitOnError)
util.InitStandardFlags()
framework.AfterReadingAllFlags(&framework.TestContext)

logs.InitLogs()
defer logs.FlushLogs()

registry := e.NewRegistry()
ext := e.NewExtension("openshift", "payload", "openstack-test")

registerSuites(ext)

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

componentSpecs := allSpecs.Select(func(spec *et.ExtensionTestSpec) bool {
for _, loc := range spec.CodeLocations {
if strings.Contains(loc, "/test/extended/openstack/") && !strings.Contains(loc, "/go/pkg/mod/") && !strings.Contains(loc, "/vendor/") {
return true
}
}
return false
})

componentSpecs.AddBeforeAll(func() {
if err := util.InitTest(false); err != nil {
panic(err)
}
util.WithCleanup(func() {})
})

componentSpecs.Walk(func(spec *et.ExtensionTestSpec) {
for label := range spec.Labels {
if strings.HasPrefix(label, "Platform:") {
platformName := strings.TrimPrefix(label, "Platform:")
spec.Include(et.PlatformEquals(platformName))
}
}

re := regexp.MustCompile(`\[platform:([a-z]+)\]`)
if match := re.FindStringSubmatch(spec.Name); match != nil {
platform := match[1]
spec.Include(et.PlatformEquals(platform))
}

spec.Lifecycle = et.LifecycleInforming
})

ext.AddSpecs(componentSpecs)

registry.Register(ext)

root := &cobra.Command{
Long: "Openstack-test Tests",
}

root.AddCommand(cmd.DefaultExtensionCommands(registry)...)

if err := func() error {
return root.Execute()
}(); err != nil {
os.Exit(1)
}
}

func registerSuites(ext *e.Extension) {
suites := []e.Suite{
{
Name: "openstack-test/conformance/parallel",
Parents: []string{
"openshift/conformance/parallel",
},
Description: "Parallel conformance tests (Level0, non-serial, non-disruptive)",
Qualifiers: []string{
`name.contains("[Level0]") && !(name.contains("[Serial]") || name.contains("[Disruptive]"))`,
},
},
{
Name: "openstack-test/conformance/serial",
Parents: []string{
"openshift/conformance/serial",
},
Description: "Serial conformance tests (must run sequentially)",
Qualifiers: []string{
`name.contains("[Level0]") && name.contains("[Serial]") && !name.contains("[Disruptive]")`,
},
},
{
Name: "openstack-test/disruptive",
Parents: []string{"openshift/disruptive"},
Description: "Disruptive tests (may affect cluster state)",
Qualifiers: []string{
`name.contains("[Disruptive]")`,
},
},
{
Name: "openstack-test/non-disruptive",
Description: "All non-disruptive tests (safe for development clusters)",
Qualifiers: []string{
`!name.contains("[Disruptive]")`,
},
},
{
Name: "openstack-test/all",
Description: "All openstack-test tests",
},
}

for _, suite := range suites {
ext.AddSuite(suite)
}
}
Loading