Skip to content

Conversation

@ewoutp
Copy link
Contributor

@ewoutp ewoutp commented Feb 20, 2018

This PR adds a test framework to the project.
The concept is as follows:

  • Run make run-tests
  • It builds a test binary & docker image
  • It creates a new namespace (in k8s)
  • It deploys the operator in that namespace
  • It executes kubectl run .. to run the test docker image

Output looks like:

$ make run-tests
docker build --quiet -f Dockerfile.test -t arangodb/arangodb-operator-test .
sha256:e3a2f09bd21279e69c4f10138442ecb171bd0810875019df284209e172e46802
/Users/ewout/arangodb/k8s-operator/scripts/kube_delete_namespace.sh arangodb-operator-tests
namespace "arangodb-operator-tests" deleted
kubectl create namespace arangodb-operator-tests
namespace "arangodb-operator-tests" created
kubectl --namespace=arangodb-operator-tests create -f examples/deployment.yaml
deployment "arangodb-operator" created
kubectl --namespace arangodb-operator-tests run arangodb-operator-test -i --rm --quiet --restart=Never --image=arangodb/arangodb-operator-test --env="TEST_NAMESPACE=arangodb-operator-tests" -- -test.v
--- PASS: TestSimpleSingle (4.58s)
PASS
kubectl delete namespace arangodb-operator-tests --ignore-not-found --now
namespace "arangodb-operator-tests" deleted

Copy link
Contributor

@ObiWahn ObiWahn left a comment

Choose a reason for hiding this comment

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

@@ -36,30 +38,24 @@ func (d *Deployment) getJWTSecret(apiObject *api.ArangoDeployment) (string, erro
}
kubecli := d.deps.KubeCli
secretName := apiObject.Spec.Authentication.JWTSecretName
s, err := kubecli.CoreV1().Secrets(apiObject.GetNamespace()).Get(secretName, metav1.GetOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice that the version gets further abstracted away!

import (
"fmt"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want meta or metav1 here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

metav1 is used all over the place.

@ewoutp ewoutp merged commit b96da3b into master Feb 26, 2018
@ewoutp ewoutp deleted the test-framework branch February 26, 2018 10:33
@ghost ghost mentioned this pull request Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants