Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix flakey test #202

Merged
merged 47 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
29f85de
fix: if Pipeline is paused in order to update its spec, make sure it'…
juliev0 Aug 13, 2024
87dc0be
logging
juliev0 Aug 13, 2024
a358ec7
fix: empty commit
juliev0 Aug 14, 2024
eef5fc1
log
juliev0 Aug 14, 2024
8a1ec3e
merge main
juliev0 Aug 14, 2024
9479e08
add debug info to e2e
juliev0 Aug 15, 2024
26a85bd
fix: empty commit
juliev0 Aug 15, 2024
fd30def
fix: empty commit
juliev0 Aug 15, 2024
27d1f28
move the printing of Reason to where it will actually happen
juliev0 Aug 15, 2024
6c58dea
fix: empty commit
juliev0 Aug 15, 2024
3d5ee61
fix: empty commit
juliev0 Aug 15, 2024
5ce88d1
fix: empty commit
juliev0 Aug 15, 2024
4fcecad
fix: empty commit
juliev0 Aug 16, 2024
614476c
fix: empty commit
juliev0 Aug 16, 2024
4f8bef0
fix: empty commit
juliev0 Aug 16, 2024
d82c313
divide the e2e test into multiple files
juliev0 Aug 16, 2024
a0a592a
print Conditions for Pending Pod instead of Reason which isn't showin…
juliev0 Aug 16, 2024
1aa8a0f
fix: empty commit
juliev0 Aug 16, 2024
edfd0cd
fix: empty commit
juliev0 Aug 16, 2024
269fd23
fix: empty commit
juliev0 Aug 16, 2024
fb53995
print init container log
juliev0 Aug 16, 2024
cdb1d6a
print init container log
juliev0 Aug 16, 2024
bb49013
fix: empty commit
juliev0 Aug 17, 2024
6fe61a8
fix: empty commit
juliev0 Aug 17, 2024
75862fe
fix: empty commit
juliev0 Aug 17, 2024
25e166a
fix: empty commit
juliev0 Aug 17, 2024
8ce80be
fix: empty commit
juliev0 Aug 17, 2024
ee1fca6
fix: empty commit
juliev0 Aug 17, 2024
d3257da
try rearranging the order of testing
juliev0 Aug 17, 2024
69bd861
fix: empty commit
juliev0 Aug 17, 2024
f4e16cd
fix: empty commit
juliev0 Aug 17, 2024
92e2323
fix: empty commit
juliev0 Aug 17, 2024
7bf3f81
fix: empty commit
juliev0 Aug 17, 2024
56fdefb
fix: empty commit
juliev0 Aug 17, 2024
0fbc374
create a new cluster for 2nd e2e test
juliev0 Aug 17, 2024
1d02b2c
fix: empty commit
juliev0 Aug 17, 2024
ab0aea3
fix: empty commit
juliev0 Aug 18, 2024
d0ba912
fix: empty commit
juliev0 Aug 18, 2024
fb312d5
fix: empty commit
juliev0 Aug 18, 2024
17889ed
Merge remote-tracking branch 'origin/main' into test-e2e-pending
juliev0 Aug 18, 2024
8c4c065
fix: empty commit
juliev0 Aug 18, 2024
417aceb
don't assume 'Namespace' value
juliev0 Aug 18, 2024
637cadd
fix: empty commit
juliev0 Aug 18, 2024
53498e0
fix: empty commit
juliev0 Aug 18, 2024
c2b163a
add namespace parameter
juliev0 Aug 18, 2024
1de0df2
remove temporary debugging
juliev0 Aug 18, 2024
527cf85
fix lint by commenting function out
juliev0 Aug 18, 2024
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
9 changes: 9 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ jobs:
GOPATH: /home/runner/go
run: KUBECONFIG=~/.kube/config VERSION=${{ github.sha }} DOCKER_PUSH=true make test-e2e

- name: Create second cluster
run: |
export PATH=$PATH:/usr/local/bin
k3d cluster create e2e-data-loss-prevention
k3d kubeconfig get e2e-data-loss-prevention > ~/.kube/config
echo '127.0.0.1 localhost' | sudo tee -a /etc/hosts
echo 'Waiting for the cluster to be ready...'
until kubectl cluster-info; do sleep 1; done

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this resolves the CI flakey test by creating a clean cluster before the second e2e test runs

- name: Install Numaplane with dataLossPrevention=true
env:
GOPATH: /home/runner/go
Expand Down
95 changes: 95 additions & 0 deletions tests/e2e/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package e2e

import (
"context"
"fmt"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"sigs.k8s.io/controller-runtime/pkg/envtest"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/client-go/dynamic"
clientgo "k8s.io/client-go/kubernetes"

"github.com/numaproj/numaplane/internal/util"
"github.com/numaproj/numaplane/internal/util/kubernetes"
planepkg "github.com/numaproj/numaplane/pkg/client/clientset/versioned/typed/numaplane/v1alpha1"
)

var (
dynamicClient dynamic.DynamicClient
testEnv *envtest.Environment
ctx context.Context
cancel context.CancelFunc
suiteTimeout = 5 * time.Minute
testTimeout = 2 * time.Minute

pipelineRolloutClient planepkg.PipelineRolloutInterface
isbServiceRolloutClient planepkg.ISBServiceRolloutInterface
numaflowControllerRolloutClient planepkg.NumaflowControllerRolloutInterface
kubeClient clientgo.Interface
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

all these variables need to be in a file not including "_test.go" in the name in order to be referenced from the other files


const (
Namespace = "numaplane-system"
)

// document for Ginkgo framework and print to console
func document(testName string) {
snapshotCluster(testName)
By(testName)
}

func snapshotCluster(testName string) {
fmt.Printf("*** %+v: NAMESPACE POD STATE BEFORE TEST: %s\n", time.Now(), testName)
podList, _ := kubeClient.CoreV1().Pods(Namespace).List(ctx, metav1.ListOptions{})
if podList != nil {
for _, pod := range podList.Items {
fmt.Printf("Pod: %q, %q\n", pod.Name, pod.Status.Phase)
}
}
}

func verifyPodsRunning(namespace string, numPods int, labelSelector string) {
document(fmt.Sprintf("verifying %d Pods running with label selector %q", numPods, labelSelector))

Eventually(func() bool {
podsList, _ := kubeClient.CoreV1().Pods(namespace).List(ctx, metav1.ListOptions{LabelSelector: labelSelector})
if podsList != nil && len(podsList.Items) >= numPods {
for _, pod := range podsList.Items {
if pod.Status.Phase != "Running" {
return false
}
}
return true
}
return false

}).WithTimeout(testTimeout).Should(BeTrue())

}

func getNumaflowResourceStatus(u *unstructured.Unstructured) (kubernetes.GenericStatus, error) {
statusMap := u.Object["status"]
var status kubernetes.GenericStatus
err := util.StructToStruct(&statusMap, &status)
return status, err
}

// commenting out to please Lint, but leaving here because it could be useful later
/*
func printPodLogs(client clientgo.Interface, namespace, podName, containerName string) {
podLogOptions := &apiv1.PodLogOptions{Container: containerName}
stream, err := client.CoreV1().Pods(namespace).GetLogs(podName, podLogOptions).Stream(ctx)
if err != nil {
fmt.Printf("Error getting Pod logs: namespace=%q, pod=%q, container=%q\n", namespace, podName, containerName)
return
}
defer stream.Close()
logBytes, _ := io.ReadAll(stream)
fmt.Printf("Printing Log for namespace=%q, pod=%q, container=%q:\n%s\n", namespace, podName, containerName, string(logBytes))
}*/
Loading
Loading