Skip to content

Commit

Permalink
Add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
friedrichwilken committed Oct 31, 2023
1 parent 5ec2f1a commit 8e627cb
Show file tree
Hide file tree
Showing 9 changed files with 273 additions and 125 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,67 @@ jobs:
if: failure()
run: |
kubectl get eventing -n kyma-system -o yaml
PeerAuthentication:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install k3d tools
run: |
make -C hack/ci/ install-k3d-tools
- name: Install Istio
run: |
helm repo add istio https://istio-release.storage.googleapis.com/charts
helm repo update
kubectl create namespace istio-system
helm install istio-base istio/base -n istio-system --set defaultRevision=default
- name: Install Kyma CLI & setup k3d cluster using kyma CLI
run: |
make kyma
make -C hack/ci/ create-k3d
kubectl version
kubectl cluster-info
- name: Install eventing-manager
run: |
make install IMG=$MANAGER_IMAGE
- name: Wait for the 'pull-eventing-manager-build' job to succeed
uses: kyma-project/wait-for-commit-status-action@2b3ffe09af8b6f40e1213d5fb7f91a7bd41ffb20
with:
context: "pull-eventing-manager-build"
commit_ref: "${{ github.event.pull_request.head.sha }}" # Note: 'github.event.pull_request.head.sha' is not same as 'github.sha' on pull requests.
timeout: 600000 # 10 minutes in milliseconds
# The check interval is kept long otherwise it will exhaust the GitHub rate limit (More info: https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limiting)
check_interval: 60000 # 1 minute in milliseconds
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_OWNER: "${{ github.repository_owner }}"
GITHUB_REPO: "eventing-manager"

- name: Deploy the controller to the cluster
run: |
kubectl create ns kyma-system || true
make deploy IMG=$MANAGER_IMAGE
- name: Setup NATS
run: |
make -C hack/ci/ get-nats-via-lifecycle-manager
- name: Setup and test the eventing-manager
run: |
e2e-setup-with-pa
- name: On error get NATS CR
if: failure()
run: |
kubectl get nats -n kyma-system -o yaml
- name: On error get eventing CR
if: failure()
run: |
kubectl get eventing -n kyma-system -o yaml
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ $(KYMA):
e2e-setup:
go test -v ./hack/e2e/setup/setup_test.go --tags=e2e

.PHONY: e2e-setup-with-pa
e2e-setup-with-pa:
go test -v ./hack/e2e/setup/setup_test.go --tags=e2e --peerauthentication

# e2e-cleanup will delete the Eventing CR and check if the required resources are de-provisioned or not.
.PHONY: e2e-cleanup
e2e-cleanup: e2e-eventing-cleanup
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

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

7 changes: 4 additions & 3 deletions hack/e2e/cleanup/cleanup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import (
"os"
"testing"

eventingv1alpha1 "github.com/kyma-project/eventing-manager/api/v1alpha1"
"github.com/kyma-project/eventing-manager/hack/e2e/common/testenvironment"
"github.com/kyma-project/eventing-manager/pkg/eventing"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

eventingv1alpha1 "github.com/kyma-project/eventing-manager/api/v1alpha1"
"github.com/kyma-project/eventing-manager/hack/e2e/common/testenvironment"
"github.com/kyma-project/eventing-manager/pkg/eventing"

. "github.com/kyma-project/eventing-manager/hack/e2e/common"
. "github.com/kyma-project/eventing-manager/hack/e2e/common/fixtures"
)
Expand Down
13 changes: 9 additions & 4 deletions hack/e2e/common/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,23 @@ import (
natsv1alpha1 "github.com/kyma-project/nats-manager/api/v1alpha1"
)

func GetK8sClients() (*kubernetes.Clientset, client.Client, error) {
func GetRestConfig() (*rest.Config, error) {
kubeConfigPath := ""
if _, ok := os.LookupEnv("KUBECONFIG"); ok {
kubeConfigPath = os.Getenv("KUBECONFIG")
} else {
userHomeDir, err := os.UserHomeDir()
if err != nil {
return nil, nil, err
return nil, err
}
kubeConfigPath = filepath.Join(userHomeDir, ".kube", "config")
}

var kubeConfig *rest.Config
kubeConfig, err := clientcmd.BuildConfigFromFlags("", kubeConfigPath)
return clientcmd.BuildConfigFromFlags("", kubeConfigPath)
}

func GetK8sClients() (*kubernetes.Clientset, client.Client, error) {
kubeConfig, err := GetRestConfig()
if err != nil {
return nil, nil, err
}
Expand Down Expand Up @@ -77,3 +80,5 @@ func GetK8sClients() (*kubernetes.Clientset, client.Client, error) {

return clientSet, k8sClient, nil
}


3 changes: 2 additions & 1 deletion hack/e2e/eventing/cleanup/cleanup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
"os"
"testing"

"github.com/kyma-project/eventing-manager/hack/e2e/common/testenvironment"
"github.com/stretchr/testify/require"

"github.com/kyma-project/eventing-manager/hack/e2e/common/testenvironment"
)

var testEnvironment *testenvironment.TestEnvironment
Expand Down
Loading

0 comments on commit 8e627cb

Please sign in to comment.