package couchctl import ( "fmt" "testing" "sigs.k8s.io/controller-runtime/pkg/client" "edge-infra.dev/pkg/edge/constants/api/cluster" "edge-infra.dev/pkg/edge/constants/api/fleet" "edge-infra.dev/pkg/edge/datasync/couchdb" "edge-infra.dev/pkg/k8s/testing/kmp" "edge-infra.dev/test/f2" "edge-infra.dev/test/f2/x/ktest" "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func TestTouchpointServerController(t *testing.T) { fin := f2.NewFeature("CouchServerReconciler Touchpoint"). WithLabel(_fleetType, fleet.Store). WithLabel(_clusterType, cluster.DSDS). Setup("Touchpoint CouchDBServer Exists", func(ctx f2.Context, t *testing.T) f2.Context { k := ktest.FromContextT(ctx, t) require.NoError(t, client.IgnoreAlreadyExists(k.Client.Create(ctx, touchpointSever))) return ctx }). Test("CouchDB Pods Ready", func(ctx f2.Context, t *testing.T) f2.Context { k := ktest.FromContextT(ctx, t) podNum := touchpointSever.Spec.Cluster.Nodes podLabel := fmt.Sprintf("%s-%s", couchdb.Namespace, laneNumber) for i := 0; i < podNum; i++ { pod := &corev1.Pod{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("%s-%d", podLabel, i), Namespace: couchdb.Namespace, }, } k.WaitOn(t, k.Check(pod, kmp.IsCurrent())) } return ctx }). Test("CouchDBServer Ready", func(ctx f2.Context, t *testing.T) f2.Context { k := ktest.FromContextT(ctx, t) k.WaitOn(t, k.Check(touchpointSever, kmp.IsReady())) return ctx }). Feature() f.Test(t, fin) }