Skip to content

Commit

Permalink
OPA e2e tests (kubermatic#6626)
Browse files Browse the repository at this point in the history
* OPA e2e tests

* fix lint

* fix prow regex and an error msg
  • Loading branch information
lsviben authored Mar 9, 2021
1 parent 25e491d commit c0a0cd7
Show file tree
Hide file tree
Showing 5 changed files with 515 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .prow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1255,6 +1255,46 @@ presubmits:
limits:
memory: 6Gi

#########################################################
# opa e2e tests
#########################################################

- name: pre-kubermatic-opa-e2e
run_if_changed: "(go.mod|go.sum|pkg/|.prow.yaml)"
decorate: true
clone_uri: "ssh://[email protected]/kubermatic/kubermatic.git"
labels:
preset-digitalocean: "true"
preset-kubeconfig-ci: "true"
preset-docker-pull: "true"
preset-docker-push: "true"
preset-kind-volume-mounts: "true"
preset-vault: "true"
preset-goproxy: "true"
spec:
containers:
- image: quay.io/kubermatic/e2e-kind:with-conformance-tests-v1.0.23
command:
- "./hack/ci/run-opa-e2e-tests.sh"
env:
- name: VERSION_TO_TEST
value: v1.20.2
- name: KUBERMATIC_EDITION
value: ee
- name: SERVICE_ACCOUNT_KEY
valueFrom:
secretKeyRef:
name: e2e-ci
key: serviceAccountSigningKey
securityContext:
privileged: true
resources:
requests:
memory: 4Gi
cpu: 2
limits:
memory: 6Gi

#########################################################
# misc
#########################################################
Expand Down
5 changes: 5 additions & 0 deletions hack/ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ environment.
TODO: This needs to be cleaned up greatly and adjusted to the KKP
Operator. The presubmit job for this script is currently not used.

## run-opa-e2e-tests.sh

This script sets up a local KKP installation in kind, deploys a
couple of test Presets and Users and then runs the OPA e2e tests.

## setup-kind-cluster.sh

TBD
Expand Down
66 changes: 66 additions & 0 deletions hack/ci/run-opa-e2e-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/usr/bin/env bash

# Copyright 2021 The Kubermatic Kubernetes Platform contributors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

### This script sets up a local KKP installation in kind, deploys a
### couple of test Presets and Users and then runs the OPA e2e tests.

set -euo pipefail

cd $(dirname $0)/../..
source hack/lib.sh

TEST_NAME="Pre-warm Go build cache"
echodate "Attempting to pre-warm Go build cache"

beforeGocache=$(nowms)
make download-gocache
pushElapsed gocache_download_duration_milliseconds $beforeGocache

export KIND_CLUSTER_NAME="${SEED_NAME:-kubermatic}"

source hack/ci/setup-kind-cluster.sh
source hack/ci/setup-kubermatic-in-kind.sh

echodate "Creating UI DigitalOcean preset..."
cat << EOF > preset-digitalocean.yaml
apiVersion: kubermatic.k8s.io/v1
kind: Preset
metadata:
name: e2e-digitalocean
namespace: kubermatic
spec:
digitalocean:
token: ${DO_E2E_TESTS_TOKEN}
EOF
retry 2 kubectl apply -f preset-digitalocean.yaml

echodate "Creating roxy2 user..."
cat << EOF > user.yaml
apiVersion: kubermatic.k8s.io/v1
kind: User
metadata:
name: c41724e256445bf133d6af1168c2d96a7533cd437618fdbe6dc2ef1fee97acd3
spec:
email: [email protected]
id: 1413636a43ddc27da27e47614faedff24b4ab19c9d9f2b45dd1b89d9_KUBE
name: roxy2
admin: true
EOF
retry 2 kubectl apply -f user.yaml

echodate "Running opa tests..."
go test -timeout 30m -tags e2e -v ./pkg/test/e2e/opa -kubeconfig "$KUBECONFIG"
echodate "Tests completed successfully!"
Loading

0 comments on commit c0a0cd7

Please sign in to comment.