Skip to content
Merged
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.
13 changes: 13 additions & 0 deletions Containerfile
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
# 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

# Test extension builder stage (added by ote-migration)
FROM golang:1.21 AS test-extension-builder
RUN mkdir -p /go/src/github.com/openshift/openstack-test
Expand All@@ -11,8 +20,12 @@ RUN make tests-ext-build && \
# 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/

# Copy test extension binary (added by ote-migration)
COPY --from=test-extension-builder /go/src/github.com/openshift/openstack-test/bin/openstack-test-tests-ext.tar.gz /usr/bin/

USER 1000:1000
ENV LC_ALL en_US.UTF-8

ENTRYPOINT ["/usr/bin/openstack-test"]
11 changes: 7 additions & 4 deletions Makefile
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@

openstack-tests: test/extended/openstack/* cmd/openshift-tests/*
go build -o $@ ./cmd/openshift-tests

# Update generated artifacts.
update:
mkdir -p ./test/extented/util/annotate/generated
Expand All@@ -9,13 +12,13 @@ verify:
./hack/verify.sh
.PHONY: verify

run: openstack-tests
./$< run openshift/openstack
.PHONY: run

# OTE test extension binary configuration
TESTS_EXT_BINARY := bin/openstack-test-tests-ext

run: tests-ext-build
./$(TESTS_EXT_BINARY) run-suite openstack-test/all
.PHONY: run

.PHONY: tests-ext-build
tests-ext-build:
@echo "Building OTE test extension binary..."
Expand Down
108 changes: 87 additions & 21 deletions README.md
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,99 @@
# openstack-test

This repository contains tests specific to OpenShift on OpenStack, built as an [OpenShift Tests Extension (OTE)][1].
This repository contains tests specific to OpenShift on OpenStack, based on the [openshift/origin][1] machinery.

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

## Running the tests

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

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

---

This builds the extension binary and runs the `openstack-test/all` suite.
## Rebase on Origin

### Available suites
### Step 1: Update Origin as a dependency

| Suite | Description |
|---|---|
| `openstack-test/conformance/parallel` | Parallel conformance tests (Level0, non-serial, non-disruptive) |
| `openstack-test/conformance/serial` | Serial conformance tests (must run sequentially) |
| `openstack-test/disruptive` | Disruptive tests (may affect cluster state) |
| `openstack-test/non-disruptive` | All non-disruptive tests (safe for development clusters) |
| `openstack-test/all` | All openstack-test tests |
Identify the Origin commit you want to rebase `openstack-test` onto.

To run a specific suite:
Origin is referenced as a dependency in `go.mod`. Update it with:
```sh
make extension
./bin/openstack-test-tests-ext run-suite openstack-test/conformance/parallel
GONOPROXY=* GONOSUMDB=* go get -d github.com/openshift/origin@<latest-commit-sha>
```

[1]: https://github.com/openshift-eng/openshift-tests-extension
[2]: test/extended/openstack
### Step 2: Update Origin dependencies' overrides

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

### 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/
```

Apply this diff to change Origin's code to use the locally-defined 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() {
```

### Step 4: Tidy up the dependencies

```bash
go mod tidy && go mod vendor
```
116 changes: 116 additions & 0 deletions cmd/openshift-tests/openshift-tests.go
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
package main

import (
"flag"
"fmt"
"math/rand"
"os"
"os/exec"
"syscall"
"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"
"github.com/openshift/origin/pkg/cmd/openshift-tests/disruption"
"github.com/openshift/origin/pkg/cmd/openshift-tests/images"
"github.com/openshift/origin/pkg/cmd/openshift-tests/monitor"
run_monitor "github.com/openshift/origin/pkg/cmd/openshift-tests/monitor/run"
"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"
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"
"github.com/openshift/origin/pkg/cmd/openshift-tests/run_resource_watch"
versioncmd "github.com/openshift/origin/pkg/cmd/openshift-tests/version"
testginkgo "github.com/openshift/origin/pkg/test/ginkgo"
exutil "github.com/openshift/origin/test/extended/util"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"k8s.io/cli-runtime/pkg/genericclioptions"
utilflag "k8s.io/component-base/cli/flag"
"k8s.io/component-base/logs"
"k8s.io/kubectl/pkg/util/templates"
)

func main() {
// KUBE_TEST_REPO_LIST is calculated during package initialization and prevents
// proper mirroring of images referenced by tests. Clear the value and re-exec the
// current process to ensure we can verify from a known state.
if len(os.Getenv("KUBE_TEST_REPO_LIST")) > 0 {
fmt.Fprintln(os.Stderr, "warning: KUBE_TEST_REPO_LIST may not be set when using openshift-tests and will be ignored")
os.Setenv("KUBE_TEST_REPO_LIST", "")
// resolve the call to execute since Exec() does not do PATH resolution
if err := syscall.Exec(exec.Command(os.Args[0]).Path, os.Args, os.Environ()); err != nil {
panic(fmt.Sprintf("%s: %v", os.Args[0], err))
}
return
}

logs.InitLogs()
defer logs.FlushLogs()

logrus.SetLevel(logrus.InfoLevel)

rand.Seed(time.Now().UTC().UnixNano())

pflag.CommandLine.SetNormalizeFunc(utilflag.WordSepNormalizeFunc)
//pflag.CommandLine.AddGoFlagSet(goflag.CommandLine)

root := &cobra.Command{
Long: templates.LongDesc(`This command verifies behavior of an OpenShift cluster by running remote tests against
the cluster API that exercise functionality. In general these tests may be disruptive
or require elevated privileges - see the descriptions of each test suite.
`),
// PersistentPreRun to always print the openshift-tests version; this populates
// down to subcommands as well. If you need to omit this output for a specific command,
// you can override PersistentPreRun to NoPrintVersion instead.
PersistentPreRun: cmd.PrintVersion,
}

ioStreams := genericclioptions.IOStreams{
In: os.Stdin,
Out: os.Stdout,
ErrOut: os.Stderr,
}

root.AddCommand(
run.NewRunCommand(ioStreams),
run_upgrade.NewRunUpgradeCommand(ioStreams),
images.NewImagesCommand(),
run_test.NewRunTestCommand(ioStreams),
dev.NewDevCommand(),
run_monitor.NewRunMonitorCommand(ioStreams),
monitor.NewMonitorCommand(ioStreams),
disruption.NewDisruptionCommand(ioStreams),
risk_analysis.NewTestFailureRiskAnalysisCommand(),
run_resource_watch.NewRunResourceWatchCommand(),
timeline.NewTimelineCommand(ioStreams),
run_disruption.NewRunInClusterDisruptionMonitorCommand(ioStreams),
collectdiskcertificates.NewRunCollectDiskCertificatesCommand(ioStreams),
render.NewRenderCommand(ioStreams),
versioncmd.NewVersionCommand(ioStreams),
)

f := flag.CommandLine.Lookup("v")
root.PersistentFlags().AddGoFlag(f)
pflag.CommandLine = pflag.NewFlagSet("empty", pflag.ExitOnError)
flag.CommandLine = flag.NewFlagSet("empty", flag.ExitOnError)
exutil.InitStandardFlags()

if err := func() error {
defer serviceability.Profile(os.Getenv("OPENSHIFT_PROFILE")).Stop()
return root.Execute()
}(); err != nil {
if ex, ok := err.(testginkgo.ExitError); ok {
fmt.Fprintf(os.Stderr, "Ginkgo exit error %d: %v\n", ex.Code, err)
os.Exit(ex.Code)
}
fmt.Fprintf(os.Stderr, "error: %v\n", err)
os.Exit(1)
}
}
Loading