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 9b67441
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 56 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}}
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
14 changes: 13 additions & 1 deletion test/e2e/subscription_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,19 @@ var (
Kind: csvv1alpha1.ClusterServiceVersionKind,
APIVersion: csvv1alpha1.GroupVersion,
}

strategy = install.StrategyDetailsDeployment{
DeploymentSpecs: []install.StrategyDeploymentSpec{
{
Name: genName("dep-"),
Spec: newNginxDeployment(genName("nginx-")),
},
},
}
strategyRaw, _ = json.Marshal(strategy)
installStrategy = csvv1alpha1.NamedInstallStrategy{
StrategyName: install.InstallStrategyNameDeployment,
StrategyName: install.InstallStrategyNameDeployment,
StrategySpecRaw: strategyRaw,
}
outdatedCSV = csvv1alpha1.ClusterServiceVersion{
TypeMeta: csvType,
Expand Down Expand Up @@ -340,4 +351,5 @@ func TestCreateSubscriptionManualApproval(t *testing.T) {
require.NotNil(t, installPlan)

require.Equal(t, v1alpha1.ApprovalManual, installPlan.Spec.Approval)
require.Equal(t, v1alpha1.InstallPlanPhaseRequiresApproval, installPlan.Status.Phase)
}
7 changes: 1 addition & 6 deletions test/e2e/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,11 @@ func waitForAndFetchChildren(t *testing.T, c opClient.Interface, version string,

owned := 0
for _, obj := range crList.Items {
t.Log(obj.GetName())
t.Log(obj.GetOwnerReferences())
t.Log(owner)
t.Log(owner.GetUID())
if ownerutil.IsOwnedBy(obj, owner) {
owned += 1
res = append(res, obj)
}
}
t.Log(owned)

// waiting for count number of objects to exist
if owned != count {
Expand All @@ -147,7 +142,7 @@ func waitForAndFetchChildren(t *testing.T, c opClient.Interface, version string,

func cleanupCustomResource(t *testing.T, c opClient.Interface, group, kind, name string) cleanupFunc {
return func() {
t.Log("deleting %s %s", kind, name)
t.Logf("deleting %s %s", kind, name)
require.NoError(t, c.DeleteCustomResource(apis.GroupName, group, testNamespace, kind, name))
}
}

0 comments on commit 9b67441

Please sign in to comment.