Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions deploy/e2e/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: e2e-test
rules:
- apiGroups:
- ""
resources:
- pods
- serviceaccounts
- services
- services/finalizers
- endpoints
- persistentvolumeclaims
- events
- configmaps
- secrets
- namespaces
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps
resources:
- deployments
- daemonsets
- replicasets
- statefulsets
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- monitoring.coreos.com
resources:
- servicemonitors
verbs:
- get
- create
- apiGroups:
- apps
resourceNames:
- mongodb-kubernetes-operator
resources:
- deployments/finalizers
verbs:
- update
- apiGroups:
- ""
resources:
- pods
verbs:
- get
- apiGroups:
- apps
resources:
- replicasets
- deployments
verbs:
- get
- apiGroups:
- mongodb.com
resources:
- mongodbcommunity
- mongodbcommunity/status
- mongodbcommunity/spec
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- rbac.authorization.k8s.io
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed a new role to add these additional permissions so the test could create the operator role. Furthermore, this had to be a cluster role for the clusterwide test.

resources:
- rolebindings
- roles
- clusterrolebindings
- clusterroles
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
12 changes: 12 additions & 0 deletions deploy/e2e/role_binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: e2e-test
subjects:
- kind: ServiceAccount
name: e2e-test
namespace: default
roleRef:
kind: ClusterRole
name: e2e-test
apiGroup: rbac.authorization.k8s.io
4 changes: 4 additions & 0 deletions deploy/e2e/service_account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: e2e-test
10 changes: 5 additions & 5 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ realized that is is very important to have a clean environment to work, and as s
adopted a strategy that makes it easier for everyone to contribute.

This strategy is based on using
[`operator-sdk`](https://github.com/operator-framework/operator-sdk) for running
the tests, and making the test-runner itself run as a Kubernetes Pod. This
[`envtest`](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/envtest) for setting up the tests
and `go test` for running the tests, and making the test-runner itself run as a Kubernetes Pod. This
makes it easier to run the tests in environments with access to a Kubernetes
cluster with no go toolchain installed locally, making it easier to reproduce
our local working environments in CI/CD systems.
Expand Down Expand Up @@ -41,7 +41,7 @@ each one of them in charge of some part of the lifecycle of the MongoDB database

# Developing locally

The operator is built using the latest stable `operator-sdk` and `golang`. We use a simple
The operator is built using `golang`. We use a simple
json file that describe some local options that you need to set for the testing environment
to be able to run properly. Create a json file with the following content:

Expand Down Expand Up @@ -137,13 +137,13 @@ python scripts/dev/e2e.py --help
to get a list.

## Troubleshooting
When you run a test locally, if the `operator-sdk-test` pod is present, you will have to
When you run a test locally, if the `e2e-test` pod is present, you will have to
first manually delete it; failing to do so will cause the `test-runner` pod to fail.

# Writing new E2E tests

You can start with `replica_set` test as an starting point to write a new test.
The tests are written using `operator-sdk`.
The tests are written using `envtest` and they are run using `go test`.

Adding a new test is as easy as to create a new directory in `test/e2e` with the
new E2E test, and to run them:
Expand Down
16 changes: 13 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,31 @@ go 1.14

require (
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/go-logr/zapr v0.1.1 // indirect
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect
github.com/golang/protobuf v1.4.2 // indirect
github.com/hashicorp/go-multierror v1.0.0
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/imdario/mergo v0.3.9
github.com/klauspost/compress v1.9.8 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/operator-framework/operator-sdk v0.19.4
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the operator-sdk test code was the only dependency on operator-sdk.

github.com/onsi/ginkgo v1.12.0 // indirect
github.com/onsi/gomega v1.9.0 // indirect
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.5.1 // indirect
github.com/prometheus/procfs v0.0.11 // indirect
github.com/rogpeppe/go-internal v1.5.2 // indirect
github.com/stretchr/objx v0.3.0
github.com/stretchr/testify v1.5.1
github.com/xdg/stringprep v1.0.0
go.mongodb.org/mongo-driver v1.3.2
go.uber.org/zap v1.14.1
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect
golang.org/x/net v0.0.0-20200625001655-4c5254603344 // indirect
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect
golang.org/x/text v0.3.3 // indirect
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
golang.org/x/tools v0.0.0-20200403190813-44a64ad78b9b // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.25.0 // indirect
k8s.io/api v0.18.2
k8s.io/apimachinery v0.18.2
k8s.io/client-go v12.0.0+incompatible
Expand Down
Loading