Skip to content

Commit

Permalink
Run integration tests on presubmit using boskos
Browse files Browse the repository at this point in the history
Using the scripts from knative/test-infra, run the integration tests
against a cluster created with boskos. A lot of the boskos stuff is
still kind of magical, for example I have no idea what is controlling
the $PROJECT_ID that is being used by knative projects on presubmit, but
after wrestling with it a bit and hacking around `--run-tests` I was
able to get it to work locally and deploy a cluster (I assume using
boskos?). I'll follow up on this more later on and update the docs when
I have more info.

Assuming we can get knative/test-infra#169
merged I'll revert the change to `e2e-tests.sh` in the `vendor` dir.

Fixes #16
  • Loading branch information
bobcatfish committed Oct 3, 2018
1 parent 0a4128b commit 2de59f6
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
27 changes: 26 additions & 1 deletion test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,29 @@ You can run this locally with:

```shell
test/presubmit-tests.sh
```
test/presubmit-tests.sh --build-tests
test/presubmit-tests.sh --unit-tests
```

The configuration for these tests lives
[in the `knative/test-infra` Prow configuration](https://github.com/knative/test-infra/blob/master/ci/prow/config.yaml).

### Running presubmit integration tests

By default the integration tests will try to get a new cluster using [boskos](https://github.com/kubernetes/test-infra/tree/master/boskos) and
[these hardcoded GKE projects](https://github.com/knative/test-infra/blob/master/ci/prow/boskos/resources.yaml#L15),
which only [the `knative/test-infra` OWNERS](https://github.com/knative/test-infra/blob/master/OWNERS)
have access to.

If you would like to run the integration tests against your cluster, you can use the
`K8S_CLUSTER_OVERRIDE` environment variable to force the scripts to use your own cluster,
and provide `KO_DOCKER_REPO` (as specified in the [DEVELOPMENT.md](../DEVELOPMENT.md#environment-setup)):

```shell
export K8S_CLUSTER_OVERRIDE=my_k8s_cluster # corresponds to a `context` in your kubeconfig
export KO_DOCKER_REPO=gcr.io/my_docker_repo # required for deployments using `ko`
test/presubmit-tests.sh --integration-tests
```

Otherwise, the script will attempt to use [boskos](https://github.com/kubernetes/test-infra/tree/master/boskos)
to create a new cluster in the script `$PROJECT_ID`.
1 change: 1 addition & 0 deletions test/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func tearDownMain(kubeClient *knativetest.KubeClient, logger *logging.BaseLogger
func TestMain(m *testing.M) {
initializeLogsAndMetrics()
logger := logging.GetContextLogger("TestMain")
logger.Infof("Using kubeconfig at `%s` with cluster `%s`", knativetest.Flags.Kubeconfig, knativetest.Flags.Cluster)

namespace = AppendRandomString("arendelle")
kubeClient := createNamespace(namespace, logger)
Expand Down
19 changes: 18 additions & 1 deletion test/presubmit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
# limitations under the License.

# This script runs the presubmit tests; it is started by prow for each PR.
# When running `--integration-tests`, use `K8S_CLUSTER_OVERRIDE` to point at your
# own cluster (a context in your kubeconfig), or the script will attempt to invoke
# boskos to obtain one of the knative testing clusters in GKE.

set -o xtrace

Expand Down Expand Up @@ -43,7 +46,21 @@ function unit_tests() {

function integration_tests() {
echo "Running integration tests"
echo "TODO(#16): add integration tests"

# Use knative test-infra scripts to make `fail-test` and `success` available.
# which will output helpful information for debugging failures, and ensure test
# results are made available.
source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/e2e-tests.sh
# Setup the cluster (if not using an existing cluster) and deploy the Pipeline CRD
source $(dirname $0)/cluster-setup.sh

options=""
(( EMIT_METRICS )) && options="-emitmetrics"
report_go_test \
-v -tags=e2e -count=1 -timeout=20m ./test \
${options} || fail_test

success
}

main $@
6 changes: 3 additions & 3 deletions vendor/github.com/knative/test-infra/scripts/e2e-tests.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2de59f6

Please sign in to comment.