Skip to content

Commit

Permalink
Fix envtests
Browse files Browse the repository at this point in the history
  • Loading branch information
adejanovski committed Apr 8, 2024
1 parent df8aa44 commit c4cf8b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 deletions.
28 changes: 4 additions & 24 deletions controllers/k8ssandra/medusa_reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,20 +246,9 @@ func createMultiDcClusterWithMedusa(t *testing.T, ctx context.Context, f *framew
require.True(err != nil && errors.IsNotFound(err), "dc2 should not be created until dc1 is ready")

t.Log("update dc1 status to ready")
err = f.PatchDatacenterStatus(ctx, dc1Key, func(dc *cassdcapi.CassandraDatacenter) {
dc.Status.CassandraOperatorProgress = cassdcapi.ProgressReady
dc.SetCondition(cassdcapi.DatacenterCondition{
Type: cassdcapi.DatacenterReady,
Status: corev1.ConditionTrue,
LastTransitionTime: metav1.Now(),
})
})
err = f.SetDatacenterStatusReady(ctx, dc1Key)
require.NoError(err, "failed to update dc1 status to ready")

require.Eventually(func() bool {
return f.UpdateDatacenterGeneration(ctx, t, dc1Key)
}, timeout, interval, "failed to update dc1 generation")

reconcileMedusaStandaloneDeployment(ctx, t, f, kc, "dc2", f.DataPlaneContexts[1])
t.Log("check that dc2 was created")
require.Eventually(f.DatacenterExists(ctx, dc2Key), timeout, interval)
Expand Down Expand Up @@ -290,20 +279,11 @@ func createMultiDcClusterWithMedusa(t *testing.T, ctx context.Context, f *framew
require.NoError(err, "failed to get dc2")

t.Log("update dc2 status to ready")
err = f.PatchDatacenterStatus(ctx, dc2Key, func(dc *cassdcapi.CassandraDatacenter) {
dc.Status.CassandraOperatorProgress = cassdcapi.ProgressReady
dc.SetCondition(cassdcapi.DatacenterCondition{
Type: cassdcapi.DatacenterReady,
Status: corev1.ConditionTrue,
LastTransitionTime: metav1.Now(),
})
})
if err = f.SetDatacenterStatusReady(ctx, dc2Key); err != nil {
assert.Fail(t, "error setting status ready", err)
}
require.NoError(err, "failed to update dc2 status to ready")

require.Eventually(func() bool {
return f.UpdateDatacenterGeneration(ctx, t, dc2Key)
}, timeout, interval, "failed to update dc2 generation")

t.Log("check that dc2 was rebuilt")
verifyRebuildTaskCreated(ctx, t, f, dc2Key, dc1Key)
rebuildTaskKey := framework.NewClusterKey(f.DataPlaneContexts[1], kc.Namespace, "dc2-rebuild")
Expand Down
7 changes: 7 additions & 0 deletions test/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,13 @@ func (f *Framework) SetDatacenterStatusReady(ctx context.Context, key ClusterKey
LastTransitionTime: now,
})
dc.Status.ObservedGeneration = dc.Generation
dc.Status.NodeStatuses = cassdcapi.CassandraStatusMap{}
for i := 0; i < int(dc.Spec.Size); i++ {
dc.Status.NodeStatuses[fmt.Sprintf("node%d", i)] = cassdcapi.CassandraNodeStatus{
HostID: fmt.Sprintf("host%d", i),
}

}
})
}

Expand Down

0 comments on commit c4cf8b3

Please sign in to comment.