Skip to content

Commit

Permalink
fix(e2e): fix local e2e scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ecordell committed May 11, 2018
1 parent 51fd078 commit fea0ca3
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 95 deletions.
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,18 @@ run-local-shift: rc

e2e-local: values_file = test/e2e/e2e-values.yaml
e2e-local: rc
./scripts/build_local.sh
./scripts/run_e2e_local.sh
. ./scripts/build_local.sh
. ./scripts/run_e2e_local.sh

e2e-local-shift: values_file = test/e2e/e2e-values.yaml
e2e-local-shift: rc
./scripts/build_local_shift.sh
./scripts/run_e2e_local.sh
. ./scripts/build_local_shift.sh
. ./scripts/run_e2e_local.sh

e2e-local-docker: values_file = test/e2e/e2e-values.yaml
e2e-local-docker: rc
./scripts/build_local.sh
./scripts/run_e2e_docker.sh
. ./scripts/build_local.sh
. ./scripts/run_e2e_docker.sh

DEP := $(GOPATH)/bin/dep
$(DEP):
Expand Down
13 changes: 0 additions & 13 deletions e2e-local-build.Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion e2e-local-run.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ RUN apt-get update
RUN apt-get install -y jq
COPY pkg pkg
COPY vendor vendor
COPY e2e e2e
COPY test/e2e test/e2e
RUN go test -c -o /bin/e2e ./test/e2e/...
CMD ["./test/e2e/e2e.sh"]
40 changes: 40 additions & 0 deletions e2e.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM golang:1.10 as builder
LABEL builder=true
WORKDIR /go/src/github.com/operator-framework/operator-lifecycle-manager
RUN curl -L https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 -o /bin/jq
RUN chmod +x /bin/jq
COPY . .
RUN make build-coverage
RUN go test -c -o /bin/e2e ./test/e2e/...

FROM alpine:latest as olm
LABEL olm=true
WORKDIR /
COPY --from=builder /go/src/github.com/operator-framework/operator-lifecycle-manager/bin/alm /bin/alm
EXPOSE 8080
CMD ["/bin/alm"]

FROM alpine:latest as catalog
LABEL catalog=true
WORKDIR /
COPY --from=builder /go/src/github.com/operator-framework/operator-lifecycle-manager/bin/catalog /bin/catalog
EXPOSE 8080
CMD ["/bin/catalog"]

FROM alpine:latest as broker
LABEL broker=true
WORKDIR /
COPY --from=builder /go/src/github.com/operator-framework/operator-lifecycle-manager/bin/servicebroker /bin/servicebroker
EXPOSE 8080
EXPOSE 8005
CMD ["/bin/servicebroker"]

FROM golang:1.10
LABEL e2e=true
RUN mkdir -p /var/e2e
WORKDIR /var/e2e
COPY --from=builder /bin/e2e /bin/e2e
COPY --from=builder /bin/jq /bin/jq
COPY ./test/e2e/e2e.sh /var/e2e/e2e.sh
COPY ./test/e2e/tap.jq /var/e2e/tap.jq
CMD ["/bin/e2e"]
10 changes: 5 additions & 5 deletions scripts/build_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ set -e
minikube start --extra-config=apiserver.Authorization.Mode=RBAC || { echo 'Cannot start minikube.'; exit 1; }
eval $(minikube docker-env) || { echo 'Cannot switch to minikube docker'; exit 1; }
kubectl config use-context minikube
docker build \
-t quay.io/coreos/catalog:local \
-t quay.io/coreos/olm:local \
-t quay.io/coreos/olm-service-broker:local \
-f e2e-local-build.Dockerfile .
docker build -f e2e.Dockerfile .
docker tag $(docker images --filter 'label=broker=true' --format '{{.CreatedAt}}\t{{.ID}}' | sort -nr | head -n 1 | cut -f2) quay.io/coreos/olm-service-broker:local
docker tag $(docker images --filter 'label=catalog=true' --format '{{.CreatedAt}}\t{{.ID}}' | sort -nr | head -n 1 | cut -f2) quay.io/coreos/catalog:local
docker tag $(docker images --filter 'label=e2e=true' --format '{{.CreatedAt}}\t{{.ID}}' | sort -nr | head -n 1 | cut -f2) quay.io/coreos/olm-e2e:local
docker tag $(docker images --filter 'label=olm=true' --format '{{.CreatedAt}}\t{{.ID}}' | sort -nr | head -n 1 | cut -f2) quay.io/coreos/olm:local
14 changes: 2 additions & 12 deletions scripts/run_e2e_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,10 @@ trap cleanupAndExit SIGINT SIGTERM EXIT
./scripts/install_local.sh ${namespace} test/e2e/resources

mkdir -p test/e2e/test-resources

pushd test/e2e/chart/templates
filenames=$(ls *.yaml)
popd

for f in ${filenames}
do
echo "Processing $f file..."
helm template --set namespace=${namespace} -f test/e2e/e2e-values.yaml -x templates/${f} test/e2e/chart > test/e2e/test-resources/${f}
done
helm template --set namespace=${namespace} -f test/e2e/e2e-values.yaml test/e2e/chart --output-dir test/e2e/test-resources

eval $(minikube docker-env) || { echo 'Cannot switch to minikube docker'; exit 1; }
docker build --no-cache -t quay.io/coreos/alm-e2e:local -f e2e-local-run.Dockerfile .
kubectl apply -f test/e2e/test-resources
kubectl apply -f test/e2e/test-resources/alm-e2e/templates
until kubectl -n ${namespace} logs job/e2e | grep -v "ContainerCreating"; do echo "waiting for job to run" && sleep 1; done
kubectl -n ${namespace} logs job/e2e -f

Expand Down
1 change: 0 additions & 1 deletion scripts/run_e2e_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,5 @@ trap cleanupAndExit SIGINT SIGTERM EXIT

./scripts/install_local.sh ${namespace} test/e2e/resources


# run tests
KUBECONFIG=~/.kube/config NAMESPACE=${namespace} go test -v ./test/e2e/... ${1/[[:alnum:]-]*/-run ${1}}
41 changes: 21 additions & 20 deletions test/e2e/csv_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,26 @@ type cleanupFunc func()

var immediateDeleteGracePeriod int64 = 0

func buildCSVCleanupFunc(c opClient.Interface, csv v1alpha1.ClusterServiceVersion) cleanupFunc {
func buildCSVCleanupFunc(t *testing.T, c opClient.Interface, csv v1alpha1.ClusterServiceVersion, deleteCRDs bool) cleanupFunc {
return func() {
err := c.DeleteCustomResource(apis.GroupName, v1alpha1.GroupVersion, testNamespace, v1alpha1.ClusterServiceVersionKind, csv.GetName())
if err != nil {
fmt.Println(err)
require.NoError(t, c.DeleteCustomResource(apis.GroupName, v1alpha1.GroupVersion, testNamespace, v1alpha1.ClusterServiceVersionKind, csv.GetName()))
if deleteCRDs {
for _, crd := range csv.Spec.CustomResourceDefinitions.Owned {
require.NoError(t, c.DeleteCustomResourceDefinition(crd.Name, &metav1.DeleteOptions{}))
}
}
}
}

func createCSV(c opClient.Interface, csv v1alpha1.ClusterServiceVersion) (cleanupFunc, error) {
func createCSV(t *testing.T, c opClient.Interface, csv v1alpha1.ClusterServiceVersion, cleanupCRDs bool) (cleanupFunc, error) {
csv.Kind = v1alpha1.ClusterServiceVersionKind
csv.APIVersion = v1alpha1.SchemeGroupVersion.String()
csv.Namespace = testNamespace
csvUnst, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&csv)
if err != nil {
return nil, err
}
require.NoError(t, err)
err = c.CreateCustomResource(&unstructured.Unstructured{Object: csvUnst})
if err != nil {
return nil, err
}
return buildCSVCleanupFunc(c, csv), nil
require.NoError(t, err)
return buildCSVCleanupFunc(t, c, csv, cleanupCRDs), nil

}

Expand Down Expand Up @@ -139,11 +137,14 @@ func fetchCSV(t *testing.T, c opClient.Interface, name string, checker csvCondit

func waitForDeploymentToDelete(t *testing.T, c opClient.Interface, name string) error {
return wait.Poll(pollInterval, pollDuration, func() (bool, error) {
t.Logf("waiting for deployment %s to delete", name)
_, err := c.GetDeployment(testNamespace, name)
if errors.IsNotFound(err) {
t.Logf("deleted %s", name)
return true, nil
}
if err != nil {
t.Logf("err trying to delete %s: %s", name, err)
return false, err
}
return false, nil
Expand Down Expand Up @@ -213,7 +214,7 @@ func TestCreateCSVWithUnmetRequirements(t *testing.T) {
},
}

cleanupCSV, err := createCSV(c, csv)
cleanupCSV, err := createCSV(t, c, csv, false)
require.NoError(t, err)
defer cleanupCSV()

Expand Down Expand Up @@ -290,7 +291,7 @@ func TestCreateCSVRequirementsMet(t *testing.T) {
require.NoError(t, err)
defer cleanupCRD()

cleanupCSV, err := createCSV(c, csv)
cleanupCSV, err := createCSV(t, c, csv, true)
require.NoError(t, err)
defer cleanupCSV()

Expand Down Expand Up @@ -388,9 +389,9 @@ func TestUpdateCSVSameDeploymentName(t *testing.T) {
require.NoError(t, err)
defer cleanupCRD()

cleanupCSV, err := createCSV(c, csv)
// don't need to cleanup this CSV, it will be deleted by the upgrade process
_, err = createCSV(t, c, csv, true)
require.NoError(t, err)
defer cleanupCSV()

// Wait for current CSV to succeed
_, err = fetchCSV(t, c, csv.Name, csvSucceededChecker)
Expand Down Expand Up @@ -465,7 +466,7 @@ func TestUpdateCSVSameDeploymentName(t *testing.T) {
},
}

cleanupNewCSV, err := createCSV(c, csvNew)
cleanupNewCSV, err := createCSV(t, c, csvNew, true)
require.NoError(t, err)
defer cleanupNewCSV()

Expand Down Expand Up @@ -562,9 +563,9 @@ func TestUpdateCSVDifferentDeploymentName(t *testing.T) {
require.NoError(t, err)
defer cleanupCRD()

cleanupCSV, err := createCSV(c, csv)
// don't need to clean up this CSV, it will be deleted by the upgrade process
_, err = createCSV(t, c, csv, true)
require.NoError(t, err)
defer cleanupCSV()

// Wait for current CSV to succeed
_, err = fetchCSV(t, c, csv.Name, csvSucceededChecker)
Expand Down Expand Up @@ -615,7 +616,7 @@ func TestUpdateCSVDifferentDeploymentName(t *testing.T) {
},
}

cleanupNewCSV, err := createCSV(c, csvNew)
cleanupNewCSV, err := createCSV(t, c, csvNew)
require.NoError(t, err)
defer cleanupNewCSV()

Expand Down
33 changes: 33 additions & 0 deletions test/e2e/e2e-values-shift.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
alm:
replicaCount: 1
image:
ref: quay.io/coreos/olm:local
pullPolicy: IfNotPresent
service:
internalPort: 8080
commandArgs: -test.coverprofile=/tmp/coverage/alm-coverage.cov

catalog:
replicaCount: 1
image:
ref: quay.io/coreos/catalog:local
pullPolicy: IfNotPresent
service:
internalPort: 8080
commandArgs: -test.coverprofile=/tmp/catalog-coverage.cov

servicebroker:
replicaCount: 1
image:
ref: quay.io/coreos/olm-service-broker:local
pullPolicy: IfNotPresent
service:
internalPort: 8080
brokerPort: 8005
commandArgs: -test.coverprofile=/tmp/service-broker-coverage.cov

e2e:
image:
ref: quay.io/coreos/olm-e2e:local

job_name: e2e
12 changes: 1 addition & 11 deletions test/e2e/e2e-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,8 @@ catalog:
internalPort: 8080
commandArgs: -test.coverprofile=/tmp/catalog-coverage.cov

servicebroker:
replicaCount: 1
image:
ref: quay.io/coreos/alm-service-broker:local
pullPolicy: IfNotPresent
service:
internalPort: 8080
brokerPort: 8005
commandArgs: -test.coverprofile=/tmp/service-broker-coverage.cov

e2e:
image:
ref: quay.io/coreos/alm-e2e:local
ref: quay.io/coreos/olm-e2e:local

job_name: e2e
Loading

0 comments on commit fea0ca3

Please sign in to comment.