github.com/dmvolod/operator-sdk@v0.8.2/doc/dev/testing/travis-build.md (about)

     1  # TravisCI Build Information
     2  
     3  Travis is set to run one every push to a branch or PR.
     4  The results of the builds can be found [here][branches] for branches and [here][pr-builds] for PRs.
     5  
     6  ## Test Workflow
     7  
     8  In Travis CI, 4 jobs are run to test the sdk:
     9  
    10  - [Go](#go-tests)
    11  - [Ansible](#ansible-tests)
    12  - [Helm](#helm-tests)
    13  - [Markdown](#markdown)
    14  
    15  ### Before Install for Go, Ansible, and Helm
    16  
    17  For the Go, Ansible, and Helm tests, the `before_install` and `install` stages are the same:
    18  
    19  1. Check if non documentation files have been updated.
    20      - If only documentation has been updated, skip these tests.
    21  2. Download dep and run `dep ensure`.
    22  3. Build and install the sdk using `make install`.
    23  4. Install ansible using `sudo pip install ansible`.
    24  5. Run the [`hack/ci/setup-openshift`][script] script, which spins up an openshift cluster by configuring docker and then downloading the `oc` v3.11 binary and running `oc cluster up`.
    25  
    26  The Go, Ansible, and Helm tests then differ in what tests they run.
    27  
    28  ### Go Tests
    29  
    30  1. Run some basic [sanity checks][sanity].
    31      1. Run `go vet`.
    32      2. Check that all source files have a license.
    33      3. 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.
    34      4. Make sure the repo is in a clean state (this is particularly useful for making sure the `Gopkg.lock` file up to date after `dep ensure`).
    35  2. Run unit tests.
    36      1. Run `make test`.
    37  3. Run [subcommand tests][subcommand].
    38      1. Run `test local` with no flags enabled.
    39      2. Run `test local` with most configuration flags enabled.
    40      3. Run `test local` in single namespace mode.
    41      4. Run `test local` with `--up-local` flag.
    42      5. Run `test local` with both `--up-local` and `--kubeconfig` flags.
    43      6. Create all test resources with kubectl and run `test local` with `--no-setup` flag.
    44      7. Run `scorecard` subcommand and check that expected score matches actual score.
    45      8. Run `scorecard` subcommand with json output enabled and verify the output.
    46  4. Run [go e2e tests][go-e2e].
    47      1. Use `operator-sdk` to create and configure a new `memcached-operator` project and install the memcached CRD in the cluster.
    48      2. Run cluster test (namespace is auto-generated and deleted by test framework).
    49          1. Build `memcached-operator` image with `--enable-tests` flag enabled (used in the in-cluster test later).
    50          2. Deploy operator and resources to the cluster.
    51          3. Run the leader election test.
    52              1. Verify that operator deployment is ready.
    53              2. Verify that leader configmap specifies 1 leader and that the memcached operator has 2 pods (configuration for this is done in step 4.1).
    54              3. Delete current leader and wait for memcached-operator deployment to become ready again.
    55              4. Verify that leader configmap specifies 1 leader and that the memcached-operator has 2 pods.
    56              5. Verify that the name of the new leader is different from the name of the old leader.
    57          4. Run the memcached scale test.
    58              1. Create memcached CR specifying a desired cluster size of 3 and wait until memcached cluster is of size 3.
    59              2. Increase desired cluster size to 4 and wait until memcached cluster is of size 4.
    60      3. Run local test.
    61          1. Create new namespace for the test.
    62          2. Start operator using `up local` subcommand.
    63          3. Run memcached scale test (described in step 4.2.4)
    64          4. Delete the test namespace.
    65      4. Run [TLS library tests][tls-tests].
    66          1. 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.
    67  
    68  ### Ansible tests
    69  
    70  1. Run [ansible e2e tests][ansible-e2e].
    71      1. Create base ansible operator project by running [`hack/image/ansible/scaffold-ansible-image.go`][ansible-base].
    72      2. Build base ansible operator image.
    73      3. Create and configure a new ansible type memcached-operator.
    74      4. Create cluster resources.
    75      5. Wait for operator to be ready.
    76      6. Create a memcached CR and wait for it to be ready.
    77      7. Create a configmap that the memcached-operator is configured to delete using a finalizer.
    78      8. Delete memcached CR and verify that the finalizer deleted the configmap.
    79      9. Run `operator-sdk migrate` to add go source to the operator (see this [note][deps_mgmt] on dependency management first).
    80      10. Run `operator-sdk build` to compile the new binary and build a new image.
    81      11. Re-run steps 4-8 to test the migrated operator.
    82  
    83  **NOTE**: All created resources, including the namespace, are deleted using a bash trap when the test finishes
    84  
    85  ### Helm Tests
    86  
    87  1. Run [helm e2e tests][helm-e2e].
    88      1. Create base helm operator project by running [`hack/image/helm/scaffold-helm-image.go`][helm-base].
    89      2. Build base helm operator image.
    90      3. Create and configure a new helm type nginx-operator.
    91      4. Create cluster resources.
    92      5. Wait for operator to be ready.
    93      6. Create nginx CR and wait for it to be ready.
    94      7. Scale up the dependent deployment and verify the operator reconciles it back down.
    95      8. Scale up the CR and verify the dependent deployment scales up accordingly.
    96      9. Delete nginx CR and verify that finalizer (which writes a message in the operator logs) ran.
    97      10. Run `operator-sdk migrate` to add go source to the operator (see this [note][deps_mgmt] on dependency management first).
    98      11. Run `operator-sdk build` to compile the new binary and build a new image.
    99      12. Re-run steps 4-9 to test the migrated operator.
   100  
   101  **NOTE**: All created resources, including the namespace, are deleted using a bash trap when the test finishes
   102  
   103  ### Markdown
   104  
   105  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`][marker-github] stored in [`hack/ci/marker`][marker-local] to check the validity and correctness of the links in all markdown files in the `doc` directory.
   106  
   107  **NOTE**: There is currently a bug in marker that causes link with underscores (`_`) to not be checked correctly.
   108  
   109  [branches]: https://travis-ci.org/operator-framework/operator-sdk/branches
   110  [pr-builds]: https://travis-ci.org/operator-framework/operator-sdk/pull_requests
   111  [script]: ../../../hack/ci/setup-openshift.sh
   112  [sanity]: ../../../hack/tests/sanity-check.sh
   113  [subcommand]: ../../../hack/tests/test-subcommand.sh
   114  [go-e2e]: ../../../hack/tests/e2e-go.sh
   115  [tls-tests]: ../../../test/e2e/tls_util_test.go
   116  [ansible-e2e]: ../../../hack/tests/e2e-ansible.sh
   117  [ansible-base]: ../../../hack/image/ansible/scaffold-ansible-image.go
   118  [helm-e2e]: ../../../hack/tests/e2e-helm.sh
   119  [helm-base]: ../../../hack/image/helm/scaffold-helm-image.go
   120  [marker-github]: https://github.com/crawford/marker
   121  [marker-local]: ../../../hack/ci/marker
   122  [deps_mgmt]: ../../user-guide.md#a-note-on-dependency-management