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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,20 @@ oc create -f manifests/04_cluster-ingress-operator.yaml

### Integration tests

Integration tests are still very immature. To run them, use the GCP test cluster instructions and then run the tests with:
Integration tests are still very immature. To run them, start with an OpenShift 4.0 cluster and then run the following,
substituting for your own details where appropriate. This assumes `KUBECONFIG` is set.

```
KUBECONFIG=/path/to/admin.kubeconfig CLUSTER_NAME=your_gcp_cluster_name make test-integration
# 1. Uninstall any existing cluster-version-operator and cluster-ingress-operator.
$ hack/uninstall.sh

# 2. Build and push a new cluster-ingress-operator image.
$ REPO=docker.io/username/origin-cluster-ingress-operator make release-local

# 3. Run `oc apply` as instructed to install the locally-built operator.

# 4. Run integration tests against the cluster.
$ CLUSTER_NAME=your-cluster-name make test-integration
```

**Important**: Note that the resources and namespaces used for the test are currently fixed and the tests will clean up after themselves, including deleting the `openshift-cluster-ingress-router` namespace. Don't run these tests in a cluster where data loss is a concern.
**Important**: Don't run these tests in a cluster where data loss is a concern.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ $(GOBINDATA_BIN):
test:
go test ./...

release-local:
MANIFESTS=$(shell mktemp -d) hack/release-local.sh

test-integration:
go test -v -tags integration ./test/integration
hack/test-integration.sh

clean:
go clean
rm -f $(BIN)

.PHONY: all build generate test test-integration clean
.PHONY: all build generate test test-integration clean release-local
32 changes: 32 additions & 0 deletions hack/release-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -euo pipefail

REPO="${REPO:-}"
MANIFESTS="${MANIFESTS:-}"

if [ -z "$REPO" ]; then echo "REPO is required"; exit 1; fi
if [ -z "$MANIFESTS" ]; then echo "MANIFESTS is required"; exit 1; fi

TEMP_COMMIT="false"
test -z "$(git status --porcelain)" || TEMP_COMMIT="true"

if [[ "${TEMP_COMMIT}" == "true" ]]; then
git add .
git commit -m "Temporary" || true
fi

REV=$(git rev-parse --short HEAD)
docker build -t $REPO:$REV -f images/cluster-ingress-operator/Dockerfile .
docker push $REPO:$REV

if [[ "${TEMP_COMMIT}" == "true" ]]; then
git reset --soft HEAD~1
fi

cp -R manifests/ $MANIFESTS
cat manifests/02-deployment.yaml | sed "s~openshift/origin-cluster-ingress-operator:latest~$REPO:$REV~" > "$MANIFESTS/02-deployment.yaml"

echo "Pushed $REPO:$REV"
echo "Install manifests using:"
echo ""
echo "oc apply -f $MANIFESTS"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing -R for recursion.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think -f does the recursion.

12 changes: 12 additions & 0 deletions hack/test-integration.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -euo pipefail

CLUSTER_NAME="${CLUSTER_NAME:-}"

if [ -z "${CLUSTER_NAME}" ]; then echo "CLUSTER_NAME is required"; exit 1; fi
if [ -z "${KUBECONFIG:-}" ]; then echo "KUBECONFIG is required"; exit 1; fi

# Required for the operator-sdk.
export KUBERNETES_CONFIG="${KUBECONFIG}"

go test -v -tags integration ./test/integration --cluster-name "${CLUSTER_NAME}"
18 changes: 18 additions & 0 deletions hack/uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
set -uo pipefail

# Disable the CVO
oc patch -n openshift-cluster-version daemonsets/cluster-version-operator --patch '{"spec": {"template": {"spec": {"nodeSelector": {"node-role.kubernetes.io/fake": ""}}}}}'

# Uninstall tectonic ingress
oc delete namespaces/openshift-ingress

# Uninstall the cluster-ingress-operator
oc delete --force --grace-period 0 -n openshift-cluster-ingress-operator clusteringresses/default
oc delete namespaces/openshift-cluster-ingress-operator
oc delete namespaces/openshift-cluster-ingress-router
oc delete clusterroles/cluster-ingress-operator:operator
oc delete clusterroles/cluster-ingress:router
oc delete clusterrolebindings/cluster-ingress-operator:operator
oc delete clusterrolebindings/cluster-ingress:router
oc delete customresourcedefinition.apiextensions.k8s.io/clusteringresses.ingress.openshift.io
23 changes: 23 additions & 0 deletions pkg/manifests/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions test/assets/app-ingress/namespace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ kind: Namespace
apiVersion: v1
metadata:
name: cluster-ingress-test
labels:
openshift.io/cluster-ingress-operator-test: ""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reserved for future use: should make it easier to identify test namespaces for cleanup.

12 changes: 0 additions & 12 deletions test/assets/app-ingress/route-internal.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: default
namespace: cluster-ingress-test
spec:
host: app-ingress-test.apps.CLUSTER_NAME.origin-gce.dev.openshift.com
host: app.NAMESPACE.apps.CLUSTER_NAME.devcluster.openshift.com
to:
kind: Service
name: app
11 changes: 0 additions & 11 deletions test/assets/cluster-ingress-default.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions test/assets/cluster-ingress-internal.yaml

This file was deleted.

Loading