Skip to content

Commit

Permalink
Optimize image pushes and integration tests (#5)
Browse files Browse the repository at this point in the history
* Optimize image pushes and integration tests

* Upgrade microk8s

* Try with MicroK8s’ registry add-on

* Change version

* Change version and image

* Change version and image

* Change version and image

* Change version and image

* Retry until push

* Retry until push

* Retry until push

* Debug remote

* Debug remote with fix

* Debug remote with fix

* Namespace and image

* Update travis and fix env

* Update travis and remove debug

* Update travis and remove debug

* Update travis and remove debug

* Address comments
  • Loading branch information
anandswaminathan authored Jun 3, 2019
1 parent 6606c2c commit 5aa8a13
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 29 deletions.
14 changes: 9 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ services:
- docker
jobs:
include:
- stage: build
name: docker build and push
install: true
script: make dockerhub_push
- stage: build
name: unit tests
install: make install
Expand All @@ -22,8 +18,16 @@ jobs:
install: make install
name: lint
script: make lint
- stage: integ-test
- stage: build
name: integration tests
install: integ/install.sh
before_script: integ/setup.sh
script: "sudo -E \"PATH=$PATH\" integ/test.sh"
- stage: release
if: TRAVIS_PULL_REQUEST = false
name: docker build and push
install: true
script: make dockerhub_push

after_success:
- bash < (curl -s https://codecov.io/bash)
8 changes: 4 additions & 4 deletions integ/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ $ INTEGRATION=true RUN_DIRECT=true go test
### Running in Image mode

```
$ INTEGRATION=true IMAGE={operator image} go test
$ INTEGRATION=true OPERATOR_IMAGE={operator image} go test
```

Note that you will need to either build an image with tag flinkk8soperator:latest specify the operator image using the
`IMAGE` environment
Note that you will need to either build an image with tag flinkk8soperator:latest or specify the operator image using the
`OPERATOR_IMAGE` environment

### Options

Expand All @@ -73,7 +73,7 @@ variables. Supported options include:
create or delete the namespace.
* `RUN_DIRECT` If set, will run the operator directly; otherwise will
submit run it via a deployment inside Kubernetes
* `IMAGE` The image to use for the operator when running in image
* `OPERATOR_IMAGE` The image to use for the operator when running in image
mode. By default, `lyft/flinkk8soperator:latest`

You can also pass [gocheck](http://labix.org/gocheck) options to the
Expand Down
7 changes: 4 additions & 3 deletions integ/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

set -e

docker login -u "$DOCKER_REGISTRY_USERNAME" -p "$DOCKER_REGISTRY_PASSWORD"

sudo snap install microk8s --classic --channel=1.12/stable
sudo snap install microk8s --classic --channel=1.13/stable
microk8s.status --wait-ready
microk8s.enable dns
microk8s.enable registry

sh boilerplate/lyft/golang_test_targets/dep_install.sh

Expand Down
2 changes: 1 addition & 1 deletion integ/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (s *IntegSuite) SetUpSuite(c *C) {
}
// var runDirect = flag.Bool("runDirect", false, "if set, runs the operator from the current source instead of from an image")
var runDirect = os.Getenv("RUN_DIRECT") != ""
// var image = flag.String("image", "lyft/flinkk8soperator:latest", "image for the operator")
// var image = flag.String("operatorImage", "flinkk8soperator:latest", "image for the operator")
var image = os.Getenv("OPERATOR_IMAGE")
if image == "" {
image = "flinkk8soperator:latest"
Expand Down
17 changes: 7 additions & 10 deletions integ/setup.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
#!/usr/bin/env bash

export DOCKER_IMAGE=flinkk8soperator:$(git rev-parse HEAD)
export OPERATOR_IMAGE=127.0.0.1:32000/flinkk8soperator:local

microk8s.docker build -t $DOCKER_IMAGE .
microk8s.docker tag $DOCKER_IMAGE $OPERATOR_IMAGE
microk8s.docker push 127.0.0.1:32000/flinkk8soperator

microk8s.start
microk8s.status --wait-ready
microk8s.enable dns

microk8s.kubectl proxy --port 8001 &

# Enable our private docker registry
# TODO: remove for open source
microk8s.kubectl create secret docker-registry dockerhub \
--docker-server=docker.io \
--docker-username=$DOCKER_REGISTRY_USERNAME \
--docker-password=$DOCKER_REGISTRY_PASSWORD \
--docker-email=none

microk8s.kubectl config view > ~/.kube/config
3 changes: 1 addition & 2 deletions integ/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

set -e

export NAMESPACE=default
export OPERATOR_IMAGE=lyft/flinkk8soperator:$(git rev-parse HEAD)
export INTEGRATION=true
export OPERATOR_IMAGE=127.0.0.1:32000/flinkk8soperator:local

# needed to create the checkpoints directory with world-writable permissions
umask 000
Expand Down
6 changes: 2 additions & 4 deletions integ/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (f *TestUtil) CreateOperator() error {
resources[v1.ResourceMemory] = resource.MustParse("0.5Gi")
deployment := appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: "flinkk8soperatore",
Name: "flinkk8soperator",
Namespace: f.Namespace.Name,
},
Spec: appsv1.DeploymentSpec{
Expand Down Expand Up @@ -212,11 +212,9 @@ func (f *TestUtil) CreateOperator() error {
VolumeMounts: []v1.VolumeMount{
{Name: "config-volume", MountPath: "/etc/flinkk8soperator/config"},
},
ImagePullPolicy: v1.PullIfNotPresent,
},
},
ImagePullSecrets: []v1.LocalObjectReference{
{Name: "dockerhub"},
},
},
},
},
Expand Down

0 comments on commit 5aa8a13

Please sign in to comment.