Skip to content

Commit ac4e989

Browse files
Merge pull request #1972 from jchunkins/modify_makefiles
update makefile, workflow, and docs
2 parents e3bff44 + 054a341 commit ac4e989

File tree

6 files changed

+85
-45
lines changed

6 files changed

+85
-45
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v2
12-
- run: make -f x.mk e2e-local NODES=2 JUNIT_DIRECTORY=./artifacts/
12+
- run: make e2e-local NODES=2 JUNIT_DIRECTORY=./artifacts/
1313
- name: Archive Test Artifacts # test results, failed or not, are always uploaded.
1414
if: ${{ always() }}
1515
uses: actions/upload-artifact@v2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,3 +454,4 @@ apiserver.crt
454454
apiserver.key
455455

456456
!vendor/**
457+
test/e2e-local.image.tar

Makefile

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ CONTROLLER_GEN := go run $(MOD_FLAGS) ./vendor/sigs.k8s.io/controller-tools/cmd/
2525
YQ_INTERNAL := go run $(MOD_FLAGS) ./vendor/github.com/mikefarah/yq/v3/
2626
KUBEBUILDER_ASSETS := $(or $(or $(KUBEBUILDER_ASSETS),$(dir $(shell command -v kubebuilder))),/usr/local/kubebuilder/bin)
2727
export KUBEBUILDER_ASSETS
28+
GO := GO111MODULE=on GOFLAGS="$(MOD_FLAGS)" go
29+
GINKGO := $(GO) run github.com/onsi/ginkgo/ginkgo
30+
BINDATA := $(GO) run github.com/go-bindata/go-bindata/v3/go-bindata
2831

2932
# ART builds are performed in dist-git, with content (but not commits) copied
3033
# from the source repo. Thus at build time if your code is inspecting the local
@@ -89,15 +92,15 @@ build-linux: clean $(CMDS)
8992

9093
build-wait: clean bin/wait
9194

92-
bin/wait:
95+
bin/wait: FORCE
9396
GOOS=linux GOARCH=386 go build $(MOD_FLAGS) -o $@ $(PKG)/test/e2e/wait
9497

9598
build-util-linux: arch_flags=GOOS=linux GOARCH=386
9699
build-util-linux: build-util
97100

98101
build-util: bin/cpb
99102

100-
bin/cpb:
103+
bin/cpb: FORCE
101104
CGO_ENABLED=0 $(arch_flags) go build $(MOD_FLAGS) -ldflags '-extldflags "-static"' -o $@ ./util/cpb
102105

103106
$(CMDS): version_flags=-ldflags "-X $(PKG)/pkg/version.GitCommit=$(GIT_COMMIT) -X $(PKG)/pkg/version.OLMVersion=`cat OLM_VERSION`"
@@ -128,9 +131,36 @@ setup-bare: clean e2e.namespace
128131
e2e:
129132
go test -v $(MOD_FLAGS) -failfast -timeout 150m ./test/e2e/... -namespace=openshift-operators -kubeconfig=${KUBECONFIG} -olmNamespace=openshift-operator-lifecycle-manager -dummyImage=bitnami/nginx:latest -ginkgo.flakeAttempts=3
130133

131-
e2e-local: build-linux build-wait build-util-linux
132-
. ./scripts/build_local.sh
133-
. ./scripts/run_e2e_local.sh $(TEST)
134+
### Start: End To End Tests ###
135+
136+
# Phony prerequisite for targets that rely on the go build cache to determine staleness.
137+
.PHONY: FORCE
138+
FORCE:
139+
140+
# main entry point for running end to end tests. used by .github/workflows/e2e-tests.yml See test/e2e/README.md for details
141+
.PHONY: e2e-local
142+
e2e-local: bin/e2e-local.test test/e2e-local.image.tar
143+
$(GINKGO) -nodes $(or $(NODES),1) -flakeAttempts 3 -randomizeAllSpecs $(if $(TEST),-focus '$(TEST)') -v -timeout 90m $< -- -namespace=operators -olmNamespace=operator-lifecycle-manager -dummyImage=bitnami/nginx:latest -kind.images=../test/e2e-local.image.tar
144+
145+
# this target updates the zz_chart.go file with files found in deploy/chart
146+
# this will always fire since it has been marked as phony
147+
.PHONY: test/e2e/assets/chart/zz_chart.go
148+
test/e2e/assets/chart/zz_chart.go: $(shell find deploy/chart -type f)
149+
$(BINDATA) -o $@ -pkg chart -prefix deploy/chart/ $^
150+
151+
# execute kind and helm end to end tests
152+
bin/e2e-local.test: FORCE test/e2e/assets/chart/zz_chart.go
153+
$(GO) test -c -tags kind,helm -o $@ ./test/e2e
154+
155+
# set go env and other vars, ensure that the dockerfile exists, and then build wait, cpb, and other command binaries and finally the kind image archive
156+
test/e2e-local.image.tar: export GOOS=linux
157+
test/e2e-local.image.tar: export GOARCH=386
158+
test/e2e-local.image.tar: build_cmd=build
159+
test/e2e-local.image.tar: e2e.Dockerfile bin/wait bin/cpb $(CMDS)
160+
docker build -t quay.io/operator-framework/olm:local -f $< bin
161+
docker save -o $@ quay.io/operator-framework/olm:local
162+
163+
### Finish: End To End Tests ###
134164

135165
e2e-bare: setup-bare
136166
. ./scripts/run_e2e_bare.sh $(TEST)

scripts/package_release.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ charttmpdir=$(mktemp -d 2>/dev/null || mktemp -d -t charttmpdir)
1717
charttmpdir=${charttmpdir}/chart
1818

1919
cp -R deploy/chart/ "${charttmpdir}"
20-
sed -i "s/^[Vv]ersion:.*\$/version: ${version}/" "${charttmpdir}/Chart.yaml"
20+
21+
# overwrite the destination Chart.yaml file with a modified copy containing the version
22+
sed "s/^[Vv]ersion:.*\$/version: ${version}/" deploy/chart/Chart.yaml > "${charttmpdir}/Chart.yaml"
2123

2224
mkdir -p "${chartdir}"
2325

test/e2e/README.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,49 @@ This runs a series of tests against the Kubernetes API to verify that OLM is fun
99

1010
## How to use
1111

12-
`make e2e-local` in the root of the repository will fetch golang dependencies, start Minikube or using an existing Kind environment, build the appropriate images and run the tests in a fresh namespace each time.
1312

14-
Subsequent runs of the test suite do not need to go through the full setup process. Running individual tests (or the whole suite) can be accomplished by running `./test/e2e/run_e2e_local.sh [TestName]` with an optional test name.
13+
Execute `make e2e-local` in the root of the repository, which will:
14+
15+
- optionally update `test/e2e/assets/chart/zz_chart.go` as needed
16+
- build local executables used during testing
17+
- `bin/e2e-local.test`
18+
- `bin/wait`
19+
- `bin/cpb`
20+
- `bin/catalog`
21+
- `bin/olm`
22+
- `bin/package-server`
23+
- build docker file `e2e.Dockerfile` which includes the local executables in a `kind` image archive `test/e2e-local.image.tar`
24+
- execute `ginkgo` to run the pre-compiled test package `bin/e2e-local.test` with the `kind` image archive. This runs BDD tests defined in `test/e2e`
25+
- these tests are run in a kind cluster that is started fresh each time the test is executed
26+
27+
28+
Examples:
29+
30+
- Run all BDD tests (this takes a long time)
31+
32+
```bash
33+
make e2e-local
34+
```
35+
36+
- Run a specific BDD test using the `TEST` argument to make. Note that this argument uses regular expressions.
37+
38+
```bash
39+
make e2e-local TEST='API service resource not migrated if not adoptable'
40+
```
41+
42+
- If you have previously created the `bin/e2e-local.test` executable and want a quick way to ensure that your TEST regex argument will work, you can bypass the
43+
make file and use `-dryRun` with `-focus` and see if the regex would trigger your specific test(s).
44+
45+
```bash
46+
GO111MODULE=on GOFLAGS="-mod=vendor" go run github.com/onsi/ginkgo/ginkgo -dryRun -focus 'API service resource not migrated if not adoptable' bin/e2e-local.test
47+
```
48+
49+
- It is also possible to specify the number of parallel test nodes (i.e. one or more instances of `go test`) to run using the `NODES` argument. Defaults to 1 if not specified
50+
51+
```bash
52+
make e2e-local NODES=2
53+
```
54+
55+
## Build infrastructure
56+
57+
Note that the make file target `e2e-local` is executed by the github workflow `.github/workflows/e2e-tests.yml` and uses two parallel `go test` processes.

x.mk

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)