Skip to content

Commit

Permalink
add TestInsertAgent e2e case
Browse files Browse the repository at this point in the history
Signed-off-by: dongjiang1989 <[email protected]>
  • Loading branch information
dongjiang1989 committed Jan 8, 2024
1 parent bb45a6c commit 400c0c4
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"github.com/alibaba/open-local/pkg/apis/storage"
"github.com/alibaba/open-local/test/framework"
"github.com/blang/semver/v4"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
Expand Down Expand Up @@ -91,6 +93,7 @@ func TestE2E(t *testing.T) {
defer testCtx.Cleanup(t)

t.Run("TestInstallCRD", testInsertCRD(context.Background()))
t.Run("TestInsertAgent", testInsertAgent(context.Background()))
}

func testInsertCRD(ctx context.Context) func(t *testing.T) {
Expand All @@ -109,3 +112,41 @@ func testInsertCRD(ctx context.Context) func(t *testing.T) {
}
}
}

func testInsertAgent(ctx context.Context) func(t *testing.T) {
return func(t *testing.T) {
testCtx := testframework.NewTestCtx(t)
defer testCtx.Cleanup(t)

testNS := testframework.CreateNamespace(context.Background(), t, testCtx)

err := testframework.CreateOrUpdateDaemonSetAndWaitUntilReady(context.Background(), testNS, &appsv1.DaemonSet{
TypeMeta: metav1.TypeMeta{
Kind: "DaemonSet",
APIVersion: "apps/v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "test-agent",
Namespace: testNS,
Annotations: map[string]string{},
},
Spec: appsv1.DaemonSetSpec{
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "agent",
Image: testframework.Image,
},
},
RestartPolicy: corev1.RestartPolicyOnFailure,
},
},
},
})

if err != nil {
t.Fatal(err)
}
}
}

0 comments on commit 400c0c4

Please sign in to comment.