Travis is set to run one every push to a branch or PR. The results of the builds can be found here for branches and here for PRs.
In travis, 4 jobs are run to test the sdk:
For the Go, Ansible, and Helm tests, the before_install
and install
stages are the same:
- Check if non documentation files have been updated.
- If only documentation has been updated, skip these tests.
- Download dep and run
dep ensure
. - Build and install the sdk using
make install
. - Install ansible using
sudo pip install ansible
. - Run the
hack/ci/setup-openshift
script, which spins up an openshift cluster by configuring docker and then downloading theoc
v3.11 binary and runningoc cluster up
.
The Go, Ansible, and Helm tests then differ in what tests they run.
- Run some basic sanity checks.
- Run
go vet
. - Check that all source files have a license.
- Check that all error messages start with a lower case alphabetical character and do not end with punctuation, and log messages start with an upper case alphabetical character.
- Make sure the repo is in a clean state (this is particularly useful for making sure the
Gopkg.lock
file up to date afterdep ensure
).
- Run
- Run unit tests.
- Run subcommand tests.
- Run
test local
with no flags enabled. - Run
test local
with most configuration flags enabled. - Run
test local
in single namespace mode. - Run
test local
with--up-local
flag. - Run
test local
with both--up-local
and--kubeconfig
flags. - Create all test resources with kubectl and run
test local
with--no-setup
flag.
- Run
- Run go e2e tests.
- Use
operator-sdk
to create and configure a newmemcached-operator
project and install the memcached CRD in the cluster. - Run cluster test (namespace is autogenerated and deleted by test framework).
- Build
memcached-operator
image with--enable-tests
flag enabled (used in the in-cluster test later). - Deploy operator and resources to the cluster.
- Run the leader election test.
- Verify that operator deployment is ready.
- Verify that leader configmap specifies 1 leader and that the memcached operator has 2 pods (configuration for this is done in step 4.1).
- Delete current leader and wait for memcached-operator deployment to become ready again.
- Verify that leader configmap specifies 1 leader and that the memcached-operator has 2 pods.
- Verify that the name of the new leader is different from the name of the old leader.
- Run the memcached scale test.
- Create memcached CR specifying a desired cluster size of 3 and wait until memcached cluster is of size 3.
- Increase desired cluster size to 4 and wait until memcached cluster is of size 4.
- Build
- Run in-cluster test.
- Create new namespace for the test.
- Run the tests using the
test cluster
subcommand with the image generated in the cluster test (which contains the scale test described in step 4.2.4). - Delete the test namespace.
- Run local test.
- Create new namepace for the test.
- Start operator using
up local
subcommand. - Run memcached scale test (described in step 4.2.4)
- Delete the test namespace.
- Run TLS library tests.
- This test runs multiple simple tests of the operator-sdk's TLS library. The tests run in parallel and each tests runs in its own namespace.
- Use
- Run ansible e2e tests.
- Create base ansible operator project by running
hack/image/ansible/scaffold-ansible-image.go
. - Build base ansible operator image.
- Create and configure a new ansible type memcached-operator.
- Create cluster resources.
- Wait for operator to be ready.
- Create a memcached CR and wait for it to be ready.
- Create a configmap that the memcached-operator is configured to delete using a finalizer.
- Delete memcached CR and verify that the finalizer deleted the configmap.
- Run
operator-sdk migrate
to add go source to the operator. - Run
operator-sdk build
to compile the new binary and build a new image. - Re-run steps 4-8 to test the migrated operator.
- Create base ansible operator project by running
NOTE: All created resources, including the namespace, are deleted using a bash trap when the test finishes
- Run helm e2e tests.
- Create base helm operator project by running
hack/image/helm/scaffold-helm-image.go
. - Build base helm operator image.
- Create and configure a new helm type nginx-operator.
- Create cluster resources.
- Wait for operator to be ready.
- Create nginx CR and wait for it to be ready.
- Scale up the dependent deployment and verify the operator reconciles it back down.
- Scale up the CR and verify the dependent deployment scales up accordingly.
- Delete nginx CR and verify that finalizer (which writes a message in the operator logs) ran.
- Run
operator-sdk migrate
to add go source to the operator. - Run
operator-sdk build
to compile the new binary and build a new image. - Re-run steps 4-9 to test the migrated operator.
- Create base helm operator project by running
NOTE: All created resources, including the namespace, are deleted using a bash trap when the test finishes
The markdown test does not create a new cluster and runs in a barebones travis VM configured only for bash
. This allows documentation PRs to pass quickly, as they don't require code tests. The markdown checker uses a precompiled version of marker
stored in hack/ci/marker
to check the validity and correctness of the links in all markdown files in the doc
directory.
NOTE: There is currently a bug in marker that causes link with underscores (_
) to not be checked correctly.