Skip to content

Commit

Permalink
Merge pull request #666 from orozery/nit
Browse files Browse the repository at this point in the history
tests/e2e/k8s: Fix TestOperator
  • Loading branch information
orozery authored Jul 4, 2024
2 parents 8f72afc + a03a9c2 commit 132b685
Showing 1 changed file with 9 additions and 23 deletions.
32 changes: 9 additions & 23 deletions tests/e2e/k8s/test_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@ import (
"time"

"github.com/stretchr/testify/require"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
apiwait "k8s.io/apimachinery/pkg/util/wait"
"sigs.k8s.io/e2e-framework/klient/wait"
"sigs.k8s.io/e2e-framework/klient/wait/conditions"

clusterlink "github.com/clusterlink-net/clusterlink/pkg/apis/clusterlink.net/v1alpha1"
"github.com/clusterlink-net/clusterlink/pkg/dataplane/api"
"github.com/clusterlink-net/clusterlink/pkg/operator/controller"
"github.com/clusterlink-net/clusterlink/tests/e2e/k8s/services"
"github.com/clusterlink-net/clusterlink/tests/e2e/k8s/services/httpecho"
Expand Down Expand Up @@ -83,16 +79,19 @@ func (s *TestSuite) TestOperator() {
condStatus metav1.ConditionStatus,
) apiwait.ConditionWithContextFunc {
return func(ctx context.Context) (bool, error) {
done := false
if err := peerResource.Get(ctx, instance.GetName(), instance.GetNamespace(), instance); err != nil {
return false, err
}
if c, ok := instance.Status.Controlplane.Conditions[string(clusterlink.DeploymentReady)]; ok {
if c.Status == condStatus {
done = true
}

conds := &instance.Status.Controlplane.Conditions
if c, ok := (*conds)[string(clusterlink.DeploymentReady)]; !ok || c.Status != condStatus {
return false, nil
}
conds = &instance.Status.Dataplane.Conditions
if c, ok := (*conds)[string(clusterlink.DeploymentReady)]; !ok || c.Status != condStatus {
return false, nil
}
return done, nil
return true, nil
}
}

Expand Down Expand Up @@ -129,19 +128,6 @@ func (s *TestSuite) TestOperator() {
err = peerResource.Get(context.Background(), "instance2", controller.OperatorNamespace, instance2)
require.Nil(s.T(), err)
require.Equal(s.T(), metav1.ConditionTrue, instance2.Status.Controlplane.Conditions[string(clusterlink.DeploymentReady)].Status)

dep := appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: api.Name,
Namespace: s.fabric.Namespace(),
},
}
waitCon := conditions.New(peerResource).DeploymentConditionMatch(
&dep, appsv1.DeploymentAvailable, v1.ConditionTrue)
require.Nil(s.T(), wait.For(waitCon, wait.WithTimeout(time.Second*60)))
err = peerResource.Get(context.Background(), "instance2", controller.OperatorNamespace, instance2)
require.Nil(s.T(), err)

require.Equal(s.T(), metav1.ConditionTrue, instance2.Status.Dataplane.Conditions[string(clusterlink.DeploymentReady)].Status)
require.Equal(s.T(), metav1.ConditionTrue, instance2.Status.Ingress.Conditions[string(clusterlink.ServiceReady)].Status)

Expand Down

0 comments on commit 132b685

Please sign in to comment.