From 0b7e2f5601694be8f5148b630b03812f25917df7 Mon Sep 17 00:00:00 2001 From: "Arati R." <33031346+suntala@users.noreply.github.com> Date: Fri, 20 Jun 2025 13:11:26 +0200 Subject: [PATCH] K8s/Dashboards: Add mode 1, 2 to dashboard TestIntegrationValidation (#107018) * Add mode 1 to dashboard TestIntegrationValidation * Reject update with version conflict also in mode 1 * Add integration testing for mode 2 --- .../integration/api_validation_test.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/pkg/tests/apis/dashboard/integration/api_validation_test.go b/pkg/tests/apis/dashboard/integration/api_validation_test.go index 1b92c7cd182..8b0e1c1cbb1 100644 --- a/pkg/tests/apis/dashboard/integration/api_validation_test.go +++ b/pkg/tests/apis/dashboard/integration/api_validation_test.go @@ -62,7 +62,7 @@ func TestIntegrationValidation(t *testing.T) { } // TODO: Skip mode3 - borken due to race conditions while setting default permissions across storage backends - dualWriterModes := []rest.DualWriterMode{rest.Mode0} + dualWriterModes := []rest.DualWriterMode{rest.Mode0, rest.Mode1, rest.Mode2} for _, dualWriterMode := range dualWriterModes { t.Run(fmt.Sprintf("DualWriterMode %d", dualWriterMode), func(t *testing.T) { // Create a K8sTestHelper which will set up a real API server @@ -396,17 +396,10 @@ func runDashboardValidationTests(t *testing.T, ctx TestContext) { require.NoError(t, err) require.NotNil(t, updatedDash1) - // Try to update with the second copy (should fail with version conflict for mode 0, 4 and 5, but not for mode 1, 2 and 3) - updatedDash2, err := updateDashboard(t, editorClient, dash2, "Updated by second user", nil) - if ctx.DualWriterMode == rest.Mode1 || ctx.DualWriterMode == rest.Mode2 || ctx.DualWriterMode == rest.Mode3 { - require.NoError(t, err) - require.NotNil(t, updatedDash2) - meta, _ := utils.MetaAccessor(updatedDash2) - require.Equal(t, "Updated by second user", meta.FindTitle(""), "Dashboard title should be updated") - } else { - require.Error(t, err) - require.Contains(t, err.Error(), "the object has been modified", "Should fail with version conflict error") - } + // Try to update with the second copy. Should fail with version conflict. + _, err = updateDashboard(t, editorClient, dash2, "Updated by second user", nil) + require.Error(t, err) + require.Contains(t, err.Error(), "the object has been modified", "Should fail with version conflict error") // Clean up err = adminClient.Resource.Delete(context.Background(), dashUID, v1.DeleteOptions{})