Skip to content

Commit

Permalink
update integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
yuchen-db committed Jul 3, 2024
1 parent 16b9498 commit 0529eed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 6 additions & 3 deletions integration/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ func TestRolloutHappyCase(t *testing.T) {
requireEventuallyPod(t, api, ctx, rolloutOperatorPod, expectPodPhase(corev1.PodRunning), expectReady())

// Create mock service, and check that it is in the desired state.
createMockServiceZone(t, ctx, api, corev1.NamespaceDefault, "mock-zone-a")
createMockServiceZone(t, ctx, api, corev1.NamespaceDefault, "mock-zone-b")
createMockServiceZone(t, ctx, api, corev1.NamespaceDefault, "mock-zone-c")
sts_a := createMockServiceZone(t, ctx, api, corev1.NamespaceDefault, "mock-zone-a")
sts_b := createMockServiceZone(t, ctx, api, corev1.NamespaceDefault, "mock-zone-b")
sts_c := createMockServiceZone(t, ctx, api, corev1.NamespaceDefault, "mock-zone-c")

Check failure on line 30 in integration/e2e_test.go

View workflow job for this annotation

GitHub Actions / lint

sts_c declared and not used

Check failure on line 30 in integration/e2e_test.go

View workflow job for this annotation

GitHub Actions / integration

sts_c declared and not used

Check failure on line 30 in integration/e2e_test.go

View workflow job for this annotation

GitHub Actions / integration-boringcrypto

sts_c declared and not used
requireEventuallyPod(t, api, ctx, "mock-zone-a-0", expectPodPhase(corev1.PodRunning), expectReady(), expectVersion("1"))
requireEventuallyPod(t, api, ctx, "mock-zone-b-0", expectPodPhase(corev1.PodRunning), expectReady(), expectVersion("1"))
requireEventuallyPod(t, api, ctx, "mock-zone-c-0", expectPodPhase(corev1.PodRunning), expectReady(), expectVersion("1"))

require.Equal(t, 1, sts_a.Status.AvailableReplicas, "Available replicas should be 1")
require.Equal(t, 1, sts_b.Status.AvailableReplicas, "Available replicas should be 1")
require.Equal(t, 1, sts_b.Status.AvailableReplicas, "Available replicas should be 1")
// Update all mock service statefulsets.
_, err := api.AppsV1().StatefulSets(corev1.NamespaceDefault).Update(ctx, mockServiceStatefulSet("mock-zone-a", "2", false), metav1.UpdateOptions{})
require.NoError(t, err, "Can't update StatefulSet")
Expand Down
5 changes: 3 additions & 2 deletions integration/manifests_mock_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
"k8s.io/client-go/kubernetes"
)

func createMockServiceZone(t *testing.T, ctx context.Context, api *kubernetes.Clientset, namespace, name string) {
func createMockServiceZone(t *testing.T, ctx context.Context, api *kubernetes.Clientset, namespace, name string) *appsv1.StatefulSet {
t.Helper()
{
_, err := api.AppsV1().StatefulSets(namespace).Create(ctx, mockServiceStatefulSet(name, "1", true), metav1.CreateOptions{})
sts, err := api.AppsV1().StatefulSets(namespace).Create(ctx, mockServiceStatefulSet(name, "1", true), metav1.CreateOptions{})

Check failure on line 22 in integration/manifests_mock_service_test.go

View workflow job for this annotation

GitHub Actions / lint

sts declared and not used

Check failure on line 22 in integration/manifests_mock_service_test.go

View workflow job for this annotation

GitHub Actions / integration

sts declared and not used

Check failure on line 22 in integration/manifests_mock_service_test.go

View workflow job for this annotation

GitHub Actions / integration-boringcrypto

sts declared and not used
require.NoError(t, err, "Can't create StatefulSet")
}

Expand All @@ -31,6 +31,7 @@ func createMockServiceZone(t *testing.T, ctx context.Context, api *kubernetes.Cl
_, err := api.NetworkingV1().Ingresses(namespace).Create(ctx, mockServiceIngress(name), metav1.CreateOptions{})
require.NoError(t, err, "Can't create Ingress")
}
return sts

Check failure on line 34 in integration/manifests_mock_service_test.go

View workflow job for this annotation

GitHub Actions / lint

undefined: sts (typecheck)

Check failure on line 34 in integration/manifests_mock_service_test.go

View workflow job for this annotation

GitHub Actions / integration

undefined: sts

Check failure on line 34 in integration/manifests_mock_service_test.go

View workflow job for this annotation

GitHub Actions / integration-boringcrypto

undefined: sts
}

func mockServiceService(name string) *corev1.Service {
Expand Down

0 comments on commit 0529eed

Please sign in to comment.