Skip to content

Commit 5fa7ae2

Browse files
templecloudprydie
authored andcommitted
Add basic CI functionality for e2e and canary image testing. (#220)
1 parent a27001e commit 5fa7ae2

File tree

11 files changed

+978
-3
lines changed

11 files changed

+978
-3
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ manifests/bmcs-config.yaml
3232
manifests/bmcs-secret.yaml
3333
vendors.txt
3434

35+
env-old.sh
36+
config.yaml
37+
**/*cloudconfig_var.enc
38+
**/*kubeconfig_var.enc
39+
3540
# vim
3641
*.sw[op]
3742

Makefile

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ IMAGE := $(REGISTRY)/$(BIN)
1919

2020

2121
BUILD := $(shell git describe --always --dirty)
22-
# Allow overriding for release versions
22+
# allow overriding for release versions
2323
# Else just equal the build (git hash)
2424
VERSION ?= ${BUILD}
2525
GOOS ?= linux
@@ -80,6 +80,34 @@ manifests: build-dirs
8080
test:
8181
@./hack/test.sh $(SRC_DIRS)
8282

83+
# Deploys the current version to a specified cluster.
84+
# Requires binary, manifests, images to be built and pushed. Requires $KUBECONFIG set.
85+
.PHONY: upgrade
86+
upgrade:
87+
# Upgrade the current CCM to the specified version
88+
@./hack/deploy.sh deploy-build-version-ccm
89+
90+
# Deploys the current version to a specified cluster.
91+
# Requires a 'dist/oci-cloud-controller-manager-rollback.yaml' manifest. Requires $KUBECONFIG set.
92+
.PHONY: rollback
93+
rollback:
94+
# Rollback the current CCM to the specified version
95+
@./hack/deploy.sh rollback-original-ccm
96+
97+
.PHONY: e2e
98+
e2e:
99+
@./hack/test-e2e.sh
100+
101+
# Run the canary tests.
102+
.PHONY: canary
103+
canary:
104+
@./hack/test-canary.sh
105+
106+
# Validate the generated canary test image.
107+
.PHONY: validate-canary
108+
validate-canary:
109+
@./hack/validate-canary.sh
110+
83111
.PHONY: clean
84112
clean:
85113
@rm -rf dist

ci-docker-images/Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright 2018 Oracle and/or its affiliates. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
FROM oraclelinux:7.4
16+
17+
RUN yum install -y ca-certificates make openssl git jq && yum clean all
18+
19+
# Install golang environment
20+
RUN curl https://storage.googleapis.com/golang/go1.10.3.linux-amd64.tar.gz -O && \
21+
mkdir /tools && \
22+
tar xzf go1.10.3.linux-amd64.tar.gz -C /tools && \
23+
rm go1.10.3.linux-amd64.tar.gz && \
24+
mkdir -p /go/bin
25+
26+
ENV PATH=/tools/go/bin:/go/bin:/tools/linux-amd64:$PATH \
27+
GOPATH=/go \
28+
GOROOT=/tools/go
29+
30+
# Install the kubectl client
31+
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.11.0/bin/linux/amd64/kubectl && \
32+
chmod +x ./kubectl && \
33+
mv ./kubectl /usr/local/bin/kubectl
34+
35+
# Install Ginkgo
36+
RUN go get -u github.com/onsi/ginkgo/ginkgo

ci-docker-images/Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Copyright 2018 Oracle and/or its affiliates. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
OCIRUSERNAME ?= spinnaker/everest-ocir-push
16+
OCIREGISTRY ?= iad.ocir.io
17+
18+
IMAGE ?= iad.ocir.io/oracle/oci-cloud-controller-manager-ci-e2e
19+
VERSION ?= 1.0.1
20+
21+
.PHONY: build
22+
build:
23+
docker build \
24+
--build-arg=http_proxy \
25+
--build-arg=https_proxy \
26+
-f Dockerfile \
27+
-t ${IMAGE}:${VERSION} \
28+
.
29+
30+
.PHONY: push
31+
push: build
32+
@docker login -u '$(OCIRUSERNAME)' -p '$(OCIRPASSWORD)' $(OCIREGISTRY)
33+
docker push $(IMAGE):$(VERSION)
34+

hack/ci-util.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash
2+
3+
# Copyright 2018 Oracle and/or its affiliates. All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Utility functions for working with the CCM's Wercker CI.
18+
19+
# Functions *******************************************************************
20+
#
21+
22+
function _check_var() {
23+
local name=$1
24+
if [ -z ${!name} ]; then
25+
echo "WARNING: '""$name""' is required."
26+
fi
27+
}
28+
29+
# Check the required environnment variables are set when generating a
30+
# 'cloud-provider.yaml' file.
31+
function _check_vars() {
32+
_check_var OCI_REGION
33+
_check_var OCI_TENANCY
34+
_check_var OCI_COMPARTMENT
35+
_check_var OCI_USER
36+
_check_var FINGERPRINT
37+
_check_var PRIVATE_KEY
38+
_check_var OCI_SUBNET_01
39+
_check_var OCI_SUBNET_02
40+
}
41+
42+
# Generate a 'cloud-provider.yaml' file for use in CCM deployment and
43+
# e2e testing.
44+
function generate-cloud-provider-config() {
45+
local file=${1:-"./cloud-provider.yaml"}
46+
_check_vars
47+
cat > $file <<EOF
48+
auth:
49+
region: $OCI_REGION
50+
tenancy: $OCI_TENANCY
51+
compartment: $OCI_COMPARTMENT
52+
user: $OCI_USER
53+
key: |
54+
$PRIVATE_KEY
55+
fingerprint: $FINGERPRINT
56+
loadBalancer:
57+
disableSecurityListManagement: false
58+
subnet1: $OCI_SUBNET_01
59+
subnet2: $OCI_SUBNET_02
60+
EOF
61+
}
62+
63+
# The Wercker CI platform requires configuration files are base64 encoded.
64+
function base64_encode() {
65+
local input=$1
66+
local output=${2:-encoded}
67+
cat $input | openssl enc -base64 -A > $output
68+
}
69+
70+
function base64_decode() {
71+
local input=$1
72+
local output=${2:-decoded}
73+
cat $input | openssl enc -base64 -d -A > $output
74+
}
75+
76+
# If provided, execute the specified function.
77+
if [ ! -z "$1" ]; then
78+
$1
79+
else
80+
generate-cloud-provider-config
81+
fi

0 commit comments

Comments
 (0)