diff --git a/test/functional/daprrp/resources/dapr_pubsub_test.go b/test/functional/daprrp/resources/dapr_pubsub_test.go index f53b039e5eb..74ac549a06c 100644 --- a/test/functional/daprrp/resources/dapr_pubsub_test.go +++ b/test/functional/daprrp/resources/dapr_pubsub_test.go @@ -56,14 +56,10 @@ func Test_DaprPubSubBroker_Manual(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "dpsb-manual-app-ctnr"), - validation.NewK8sPodForResource(name, "dpsb-manual-redis"). - ValidateLabels(false), - validation.NewK8sServiceForResource(name, "dpsb-manual-redis"). - ValidateLabels(false), - - validation.NewDaprComponent(name, "dpsb-manual"). - ValidateLabels(false), + validation.NewK8sPodForResource("dpsb-manual-app-ctnr", name, true), + validation.NewK8sPodForResource("dpsb-manual-redis", name, false), + validation.NewK8sServiceForResource("dpsb-manual-redis", name, false), + validation.NewK8sDaprComponent("dpsb-manual", name, false), }, }, }, @@ -113,11 +109,8 @@ func Test_DaprPubSubBroker_Recipe(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "dpsb-recipe-ctnr"). - ValidateLabels(false), - - validation.NewDaprComponent(name, "dpsb-recipe"). - ValidateLabels(false), + validation.NewK8sPodForResource("dpsb-recipe-ctnr", name, false), + validation.NewK8sDaprComponent("dpsb-recipe", name, false), }, }, }, diff --git a/test/functional/daprrp/resources/dapr_secretstore_test.go b/test/functional/daprrp/resources/dapr_secretstore_test.go index a7ac14ed7a6..e8f76e35d07 100644 --- a/test/functional/daprrp/resources/dapr_secretstore_test.go +++ b/test/functional/daprrp/resources/dapr_secretstore_test.go @@ -55,11 +55,8 @@ func Test_DaprSecretStore_Manual(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "gnrc-scs-ctnr"), - - // Not sure why we skip validating the labels - validation.NewDaprComponent(name, "gnrc-scs-manual"). - ValidateLabels(false), + validation.NewK8sPodForResource("gnrc-scs-ctnr", name, true), + validation.NewK8sDaprComponent("gnrc-scs-manual", name, false), }, }, }, @@ -104,11 +101,8 @@ func Test_DaprSecretStore_Recipe(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "gnrc-scs-ctnr-recipe"). - ValidateLabels(false), - - validation.NewDaprComponent(name, "gnrc-scs-recipe"). - ValidateLabels(false), + validation.NewK8sPodForResource("gnrc-scs-ctnr-recipe", name, true), + validation.NewK8sDaprComponent("gnrc-scs-recipe", name, false), }, }, }, diff --git a/test/functional/daprrp/resources/dapr_serviceinvocation_test.go b/test/functional/daprrp/resources/dapr_serviceinvocation_test.go index b20f663922f..5926b02a206 100644 --- a/test/functional/daprrp/resources/dapr_serviceinvocation_test.go +++ b/test/functional/daprrp/resources/dapr_serviceinvocation_test.go @@ -54,8 +54,8 @@ func Test_DaprServiceInvocation(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "dapr-frontend"), - validation.NewK8sPodForResource(name, "dapr-backend"), + validation.NewK8sPodForResource("dapr-frontend", name, true), + validation.NewK8sPodForResource("dapr-backend", name, true), }, }, }, diff --git a/test/functional/daprrp/resources/dapr_statestore_test.go b/test/functional/daprrp/resources/dapr_statestore_test.go index 50b80d1e5b4..5b97ed8657c 100644 --- a/test/functional/daprrp/resources/dapr_statestore_test.go +++ b/test/functional/daprrp/resources/dapr_statestore_test.go @@ -56,16 +56,12 @@ func Test_DaprStateStore_Manual(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "dapr-sts-manual-ctnr"), + validation.NewK8sPodForResource("dapr-sts-manual-ctnr", name, true), // Deployed as supporting resources using Kubernetes Bicep extensibility. - validation.NewK8sPodForResource(name, "dapr-sts-manual-redis"). - ValidateLabels(false), - validation.NewK8sServiceForResource(name, "dapr-sts-manual-redis"). - ValidateLabels(false), - - validation.NewDaprComponent(name, "dapr-sts-manual"). - ValidateLabels(false), + validation.NewK8sPodForResource("dapr-sts-manual-redis", name, false), + validation.NewK8sServiceForResource("dapr-sts-manual-redis", name, false), + validation.NewK8sDaprComponent("dapr-sts-manual", name, false), }, }, }, @@ -115,11 +111,8 @@ func Test_DaprStateStore_Recipe(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "dapr-sts-recipe-ctnr"). - ValidateLabels(false), - - validation.NewDaprComponent(name, "dapr-sts-recipe"). - ValidateLabels(false), + validation.NewK8sPodForResource("dapr-sts-recipe-ctnr", name, true), + validation.NewK8sDaprComponent("dapr-sts-recipe", name, false), }, }, }, diff --git a/test/functional/datastoresrp/resources/microsoftsql_test.go b/test/functional/datastoresrp/resources/microsoftsql_test.go index fe1c70ea403..dd0975efb63 100644 --- a/test/functional/datastoresrp/resources/microsoftsql_test.go +++ b/test/functional/datastoresrp/resources/microsoftsql_test.go @@ -68,7 +68,7 @@ func Test_MicrosoftSQL_Manual(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "mssql-app-ctnr"), + validation.NewK8sPodForResource("mssql-app-ctnr", name, true), }, }, }, diff --git a/test/functional/datastoresrp/resources/mongodb_test.go b/test/functional/datastoresrp/resources/mongodb_test.go index f46369ad1ed..57eabbf35ef 100644 --- a/test/functional/datastoresrp/resources/mongodb_test.go +++ b/test/functional/datastoresrp/resources/mongodb_test.go @@ -66,9 +66,9 @@ func Test_MongoDB_Manual(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "mdb-us-app-ctnr").ValidateLabels(false), - validation.NewK8sPodForResource(name, "mdb-us-ctnr").ValidateLabels(false), - validation.NewK8sServiceForResource(name, "mdb-us-rte").ValidateLabels(false), + validation.NewK8sPodForResource("mdb-us-app-ctnr", name, true), + validation.NewK8sPodForResource("mdb-us-ctnr", name, true), + validation.NewK8sServiceForResource("mdb-us-rte", name, true), }, }, }, @@ -114,7 +114,7 @@ func Test_MongoDB_Recipe(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "mongodb-app-ctnr").ValidateLabels(false), + validation.NewK8sPodForResource("mongodb-app-ctnr", name, true), }, }, }, @@ -170,7 +170,7 @@ func Test_MongoDB_RecipeParameters(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "mdb-param-ctnr").ValidateLabels(false), + validation.NewK8sPodForResource("mdb-param-ctnr", name, true), }, }, }, @@ -225,7 +225,7 @@ func Test_MongoDB_Recipe_ContextParameter(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "mdb-ctx-ctnr").ValidateLabels(false), + validation.NewK8sPodForResource("mdb-ctx-ctnr", name, true), }, }, }, diff --git a/test/functional/datastoresrp/resources/redis_test.go b/test/functional/datastoresrp/resources/redis_test.go index 7dd32a8ca6f..49d45e48896 100644 --- a/test/functional/datastoresrp/resources/redis_test.go +++ b/test/functional/datastoresrp/resources/redis_test.go @@ -64,9 +64,9 @@ func Test_Redis_Manual(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "rds-app-ctnr"), - validation.NewK8sPodForResource(name, "rds-ctnr"), - validation.NewK8sServiceForResource(name, "rds-rte"), + validation.NewK8sPodForResource("rds-app-ctnr", name, true), + validation.NewK8sPodForResource("rds-ctnr", name, true), + validation.NewK8sServiceForResource("rds-rte", name, true), }, }, }, diff --git a/test/functional/datastoresrp/resources/sql_test.go b/test/functional/datastoresrp/resources/sql_test.go index 1f93e3e40be..1e5e3a4debb 100644 --- a/test/functional/datastoresrp/resources/sql_test.go +++ b/test/functional/datastoresrp/resources/sql_test.go @@ -69,9 +69,9 @@ func Test_SQLDatabase_Manual(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "sql-app-ctnr"), - validation.NewK8sPodForResource(name, "sql-ctnr"), - validation.NewK8sServiceForResource(name, "sql-rte"), + validation.NewK8sPodForResource("sql-app-ctnr", name, true), + validation.NewK8sPodForResource("sql-ctnr", name, true), + validation.NewK8sServiceForResource("sql-rte", name, true), }, }, }, @@ -112,8 +112,8 @@ func Test_SQLDatabase_Recipe(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "sql-recipe-app-ctnr").ValidateLabels(false), - validation.NewK8sPodForResource(name, "sql-recipe-resource").ValidateLabels(false), + validation.NewK8sPodForResource("sql-recipe-app-ctnr", name, true), + validation.NewK8sPodForResource("sql-recipe-resource", name, true), }, }, }, diff --git a/test/functional/messagingrp/resources/rabbitmq_test.go b/test/functional/messagingrp/resources/rabbitmq_test.go index 23e35122eaa..cadfbded76d 100644 --- a/test/functional/messagingrp/resources/rabbitmq_test.go +++ b/test/functional/messagingrp/resources/rabbitmq_test.go @@ -64,9 +64,9 @@ func Test_RabbitMQ_Manual(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "rmq-app-ctnr"), - validation.NewK8sPodForResource(name, "rmq-ctnr"), - validation.NewK8sServiceForResource(name, "rmq-rte"), + validation.NewK8sPodForResource("rmq-app-ctnr", name, true), + validation.NewK8sPodForResource("rmq-ctnr", name, true), + validation.NewK8sServiceForResource("rmq-rte", name, true), }, }, }, @@ -104,8 +104,8 @@ func Test_RabbitMQ_Recipe(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "rmq-recipe-app-ctnr").ValidateLabels(false), - validation.NewK8sPodForResource(name, "rmq-recipe-resource").ValidateLabels(false), + validation.NewK8sPodForResource("rmq-recipe-app-ctnr", name, true), + validation.NewK8sPodForResource("rmq-recipe-resource", name, true), }, }, }, diff --git a/test/functional/samples/tutorial_test.go b/test/functional/samples/tutorial_test.go index eee017a112b..71fbeed5649 100644 --- a/test/functional/samples/tutorial_test.go +++ b/test/functional/samples/tutorial_test.go @@ -110,7 +110,7 @@ func Test_FirstApplicationSample(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(appName, "demo"), + validation.NewK8sPodForResource("demo", appName, true), }, }, }, diff --git a/test/functional/shared/cli/cli_test.go b/test/functional/shared/cli/cli_test.go index a380184825a..a8f6ec49913 100644 --- a/test/functional/shared/cli/cli_test.go +++ b/test/functional/shared/cli/cli_test.go @@ -441,8 +441,8 @@ func Test_CLI(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ "default-kubernetes-cli": { - validation.NewK8sPodForResource(name, "containera"), - validation.NewK8sPodForResource(name, "containerb"), + validation.NewK8sPodForResource("containera", name, true), + validation.NewK8sPodForResource("containerb", name, true), }, }, }, @@ -481,8 +481,8 @@ func Test_CLI_JSON(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ "default-kubernetes-cli-json": { - validation.NewK8sPodForResource(name, "containera-json"), - validation.NewK8sPodForResource(name, "containerb-json"), + validation.NewK8sPodForResource("containera-json", name, true), + validation.NewK8sPodForResource("containerb-json", name, true), }, }, }, @@ -521,8 +521,8 @@ func Test_CLI_Delete(t *testing.T) { validation.ValidateObjectsRunning(ctx, t, options.K8sClient, options.DynamicClient, validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ "default-kubernetes-cli-with-resources": { - validation.NewK8sPodForResource(appName, "containera-app-with-resources"), - validation.NewK8sPodForResource(appName, "containerb-app-with-resources"), + validation.NewK8sPodForResource("containera-app-with-resources", appName, true), + validation.NewK8sPodForResource("containerb-app-with-resources", appName, true), }, }, }) @@ -555,8 +555,8 @@ func Test_CLI_Delete(t *testing.T) { validation.ValidateObjectsRunning(ctx, t, options.K8sClient, options.DynamicClient, validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ "default-kubernetes-cli-with-resources": { - validation.NewK8sPodForResource(appName, "containera-app-with-resources"), - validation.NewK8sPodForResource(appName, "containerb-app-with-resources"), + validation.NewK8sPodForResource("containera-app-with-resources", appName, true), + validation.NewK8sPodForResource("containerb-app-with-resources", appName, true), }, }, }) @@ -615,8 +615,8 @@ func Test_CLI_DeploymentParameters(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ "default-kubernetes-cli-params": { - validation.NewK8sPodForResource(name, "containerc"), - validation.NewK8sPodForResource(name, "containerd"), + validation.NewK8sPodForResource("containerc", name, true), + validation.NewK8sPodForResource("containerd", name, true), }, }, }, diff --git a/test/functional/shared/mechanics/mechanics_test.go b/test/functional/shared/mechanics/mechanics_test.go index 0cb95087f41..c53e912a785 100644 --- a/test/functional/shared/mechanics/mechanics_test.go +++ b/test/functional/shared/mechanics/mechanics_test.go @@ -82,7 +82,7 @@ func Test_RedeployWithAnotherResource(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "mechanicsa"), + validation.NewK8sPodForResource("mechanicsa", name, true), }, }, }, @@ -110,8 +110,8 @@ func Test_RedeployWithAnotherResource(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "mechanicsb"), - validation.NewK8sPodForResource(name, "mechanicsc"), + validation.NewK8sPodForResource("mechanicsb", name, true), + validation.NewK8sPodForResource("mechanicsc", name, true), }, }, }, @@ -145,7 +145,7 @@ func Test_RedeployWithUpdatedResourceUpdatesResource(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "mechanicsd"), + validation.NewK8sPodForResource("mechanicsd", name, true), }, }, }, @@ -168,7 +168,7 @@ func Test_RedeployWithUpdatedResourceUpdatesResource(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "mechanicsd"), + validation.NewK8sPodForResource("mechanicsd", name, true), }, }, }, @@ -215,7 +215,7 @@ func Test_RedeployWithTwoSeparateResourcesKeepsResource(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "mechanicse"), + validation.NewK8sPodForResource("mechanicse", name, true), }, }, }, @@ -243,8 +243,8 @@ func Test_RedeployWithTwoSeparateResourcesKeepsResource(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "mechanicse"), - validation.NewK8sPodForResource(name, "mechanicsf"), + validation.NewK8sPodForResource("mechanicse", name, true), + validation.NewK8sPodForResource("mechanicsf", name, true), }, }, }, @@ -293,8 +293,8 @@ func Test_CommunicationCycle(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "mechanicsg"), - validation.NewK8sPodForResource(name, "cyclea"), + validation.NewK8sPodForResource("mechanicsg", name, true), + validation.NewK8sPodForResource("cyclea", name, true), }, }, }, diff --git a/test/functional/shared/resources/azure_connections_test.go b/test/functional/shared/resources/azure_connections_test.go index e341c7b640b..190a7592449 100644 --- a/test/functional/shared/resources/azure_connections_test.go +++ b/test/functional/shared/resources/azure_connections_test.go @@ -56,7 +56,7 @@ func Test_AzureConnections(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, containerResourceName), + validation.NewK8sPodForResource(containerResourceName, name, true), }, }, }, diff --git a/test/functional/shared/resources/container_runtimes_test.go b/test/functional/shared/resources/container_runtimes_test.go index 82f8a8b5b46..1a4cb425eac 100644 --- a/test/functional/shared/resources/container_runtimes_test.go +++ b/test/functional/shared/resources/container_runtimes_test.go @@ -60,7 +60,7 @@ func Test_Container_YAMLManifest(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "ctnr-manifest"), + validation.NewK8sPodForResource("ctnr-manifest", name, true), }, }, }, @@ -126,7 +126,7 @@ func Test_Container_YAMLManifest_SideCar(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "ctnr-sidecar"), + validation.NewK8sPodForResource("ctnr-sidecar", name, true), }, }, }, @@ -172,7 +172,7 @@ func Test_Container_pod_patching(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "ctnr-podpatch"), + validation.NewK8sPodForResource("ctnr-podpatch", name, true), }, }, }, diff --git a/test/functional/shared/resources/container_test.go b/test/functional/shared/resources/container_test.go index ccfa1af3f8e..9e9360568cc 100644 --- a/test/functional/shared/resources/container_test.go +++ b/test/functional/shared/resources/container_test.go @@ -53,7 +53,7 @@ func Test_Container(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "ctnr-ctnr"), + validation.NewK8sPodForResource("ctnr-ctnr", name, true), }, }, }, @@ -92,8 +92,8 @@ func Test_ContainerHttpRoute(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "ctnr-rte-ctnr"), - validation.NewK8sServiceForResource(name, "ctnr-rte-rte"), + validation.NewK8sPodForResource("ctnr-rte-ctnr", name, true), + validation.NewK8sServiceForResource("ctnr-rte-rte", name, true), }, }, }, @@ -132,9 +132,9 @@ func Test_ContainerDNSSD_TwoContainersDNS(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "containerad"), - validation.NewK8sPodForResource(name, "containeraf"), - validation.NewK8sServiceForResource(name, "containeraf"), + validation.NewK8sPodForResource("containerad", name, true), + validation.NewK8sPodForResource("containeraf", name, true), + validation.NewK8sServiceForResource("containeraf", name, true), }, }, }, @@ -178,12 +178,12 @@ func Test_ContainerDNSSD_OptionalPortScheme(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "containerqy"), - validation.NewK8sPodForResource(name, "containerqu"), - validation.NewK8sPodForResource(name, "containerqi"), - validation.NewK8sServiceForResource(name, "containerqy"), - validation.NewK8sServiceForResource(name, "containerqu"), - validation.NewK8sServiceForResource(name, "containerqi"), + validation.NewK8sPodForResource("containerqy", name, true), + validation.NewK8sPodForResource("containerqu", name, true), + validation.NewK8sPodForResource("containerqi", name, true), + validation.NewK8sServiceForResource("containerqy", name, true), + validation.NewK8sServiceForResource("containerqu", name, true), + validation.NewK8sServiceForResource("containerqi", name, true), }, }, }, @@ -217,7 +217,7 @@ func Test_ContainerReadinessLiveness(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "ctnr-live-ready"), + validation.NewK8sPodForResource("ctnr-live-ready", name, true), }, }, }, @@ -251,7 +251,7 @@ func Test_ContainerManualScale(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "ctnr-manualscale"), + validation.NewK8sPodForResource("ctnr-manualscale", name, true), }, }, }, @@ -285,7 +285,7 @@ func Test_ContainerWithCommandAndArgs(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "ctnr-cmd-args"), + validation.NewK8sPodForResource("ctnr-cmd-args", name, true), }, }, }, @@ -350,7 +350,7 @@ func Test_Container_FailDueToNonExistentImage(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "ctnr-cntr-badimage"), + validation.NewK8sPodForResource("ctnr-cntr-badimage", name, true), }, }, }, @@ -385,7 +385,7 @@ func Test_Container_FailDueToBadHealthProbe(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "ctnr-cntr-bad-healthprobe"), + validation.NewK8sPodForResource("ctnr-cntr-bad-healthprobe", name, true), }, }, }, diff --git a/test/functional/shared/resources/container_versioning_test.go b/test/functional/shared/resources/container_versioning_test.go index ae76cb0c943..f6dc6c9e56a 100644 --- a/test/functional/shared/resources/container_versioning_test.go +++ b/test/functional/shared/resources/container_versioning_test.go @@ -56,7 +56,7 @@ func Test_ContainerVersioning(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "friendly-ctnr"), + validation.NewK8sPodForResource("friendly-ctnr", name, true), }, }, }, @@ -88,7 +88,7 @@ func Test_ContainerVersioning(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "friendly-ctnr"), + validation.NewK8sPodForResource("friendly-ctnr", name, true), }, }, }, diff --git a/test/functional/shared/resources/extender_test.go b/test/functional/shared/resources/extender_test.go index f42fe2c36c4..03b0f013900 100644 --- a/test/functional/shared/resources/extender_test.go +++ b/test/functional/shared/resources/extender_test.go @@ -56,7 +56,7 @@ func Test_Extender_Manual(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "extr-ctnr"), + validation.NewK8sPodForResource("extr-ctnr", name, true), }, }, }, diff --git a/test/functional/shared/resources/gateway_test.go b/test/functional/shared/resources/gateway_test.go index 647a3a93171..ec3fbb9b846 100644 --- a/test/functional/shared/resources/gateway_test.go +++ b/test/functional/shared/resources/gateway_test.go @@ -92,13 +92,13 @@ func Test_Gateway(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "http-gtwy-front-ctnr"), - validation.NewK8sPodForResource(name, "http-gtwy-back-ctnr"), - validation.NewK8sHTTPProxyForResource(name, "http-gtwy-gtwy"), - validation.NewK8sHTTPProxyForResource(name, "http-gtwy-front-rte"), - validation.NewK8sServiceForResource(name, "http-gtwy-front-rte"), - validation.NewK8sHTTPProxyForResource(name, "http-gtwy-back-rte"), - validation.NewK8sServiceForResource(name, "http-gtwy-back-rte"), + validation.NewK8sPodForResource("http-gtwy-front-ctnr", name, true), + validation.NewK8sPodForResource("http-gtwy-back-ctnr", name, true), + validation.NewK8sHTTPProxyForResource("http-gtwy-gtwy", name, true), + validation.NewK8sHTTPProxyForResource("http-gtwy-front-rte", name, true), + validation.NewK8sServiceForResource("http-gtwy-front-rte", name, true), + validation.NewK8sHTTPProxyForResource("http-gtwy-back-rte", name, true), + validation.NewK8sServiceForResource("http-gtwy-back-rte", name, true), }, }, }, @@ -179,13 +179,13 @@ func Test_GatewayDNS(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "frontendcontainerdns"), - validation.NewK8sPodForResource(name, "backendcontainerdns"), - validation.NewK8sServiceForResource(name, "frontendcontainerdns"), - validation.NewK8sServiceForResource(name, "backendcontainerdns"), - validation.NewK8sHTTPProxyForResource(name, "http-gtwy-gtwy-dns"), - validation.NewK8sHTTPProxyForResource(name, "frontendcontainerdns"), - validation.NewK8sHTTPProxyForResource(name, "backendcontainerdns"), + validation.NewK8sPodForResource("frontendcontainerdns", name, true), + validation.NewK8sPodForResource("backendcontainerdns", name, true), + validation.NewK8sServiceForResource("frontendcontainerdns", name, true), + validation.NewK8sServiceForResource("backendcontainerdns", name, true), + validation.NewK8sHTTPProxyForResource("http-gtwy-gtwy-dns", name, true), + validation.NewK8sHTTPProxyForResource("frontendcontainerdns", name, true), + validation.NewK8sHTTPProxyForResource("backendcontainerdns", name, true), }, }, }, @@ -258,10 +258,10 @@ func Test_Gateway_SSLPassthrough(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "ssl-gtwy-front-ctnr"), - validation.NewK8sHTTPProxyForResource(name, "ssl-gtwy-gtwy"), - validation.NewK8sHTTPProxyForResource(name, "ssl-gtwy-front-rte"), - validation.NewK8sServiceForResource(name, "ssl-gtwy-front-rte"), + validation.NewK8sPodForResource("ssl-gtwy-front-ctnr", name, true), + validation.NewK8sHTTPProxyForResource("ssl-gtwy-gtwy", name, true), + validation.NewK8sHTTPProxyForResource("ssl-gtwy-front-rte", name, true), + validation.NewK8sServiceForResource("ssl-gtwy-front-rte", name, true), }, }, }, @@ -334,11 +334,11 @@ func Test_Gateway_TLSTermination(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "tls-gtwy-front-ctnr"), - validation.NewK8sHTTPProxyForResource(name, "tls-gtwy-gtwy"), - validation.NewK8sHTTPProxyForResource(name, "tls-gtwy-front-rte"), - validation.NewK8sServiceForResource(name, "tls-gtwy-front-rte"), - validation.NewK8sSecretForResource(name, "tls-gtwy-cert"), + validation.NewK8sPodForResource("tls-gtwy-front-ctnr", name, true), + validation.NewK8sHTTPProxyForResource("tls-gtwy-gtwy", name, true), + validation.NewK8sHTTPProxyForResource("tls-gtwy-front-rte", name, true), + validation.NewK8sServiceForResource("tls-gtwy-front-rte", name, true), + validation.NewK8sSecretForResource("tls-gtwy-cert", name, true), }, }, }, diff --git a/test/functional/shared/resources/kubemetadata_container_test.go b/test/functional/shared/resources/kubemetadata_container_test.go index 7290a9dfb3f..43cc7922ca4 100644 --- a/test/functional/shared/resources/kubemetadata_container_test.go +++ b/test/functional/shared/resources/kubemetadata_container_test.go @@ -67,7 +67,7 @@ func Test_KubeMetadataContainer(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "corerp-kmd-ctnr"), + validation.NewK8sPodForResource("corerp-kmd-ctnr", name, true), }, }, }, diff --git a/test/functional/shared/resources/kubemetadata_gateway_test.go b/test/functional/shared/resources/kubemetadata_gateway_test.go index 8e6879b7fff..4b6df44c8b8 100644 --- a/test/functional/shared/resources/kubemetadata_gateway_test.go +++ b/test/functional/shared/resources/kubemetadata_gateway_test.go @@ -75,13 +75,13 @@ func Test_Gateway_KubernetesMetadata(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "http-gtwy-front-ctnr-kme"), - validation.NewK8sPodForResource(name, "http-gtwy-back-ctnr-kme"), - validation.NewK8sHTTPProxyForResource(name, "http-gtwy-kme"), - validation.NewK8sHTTPProxyForResource(name, "http-gtwy-front-rte-kme"), - validation.NewK8sServiceForResource(name, "http-gtwy-front-rte-kme"), - validation.NewK8sHTTPProxyForResource(name, "http-gtwy-back-rte-kme"), - validation.NewK8sServiceForResource(name, "http-gtwy-back-rte-kme"), + validation.NewK8sPodForResource("http-gtwy-front-ctnr-kme", name, true), + validation.NewK8sPodForResource("http-gtwy-back-ctnr-kme", name, true), + validation.NewK8sHTTPProxyForResource("http-gtwy-kme", name, true), + validation.NewK8sHTTPProxyForResource("http-gtwy-front-rte-kme", name, true), + validation.NewK8sServiceForResource("http-gtwy-front-rte-kme", name, true), + validation.NewK8sHTTPProxyForResource("http-gtwy-back-rte-kme", name, true), + validation.NewK8sServiceForResource("http-gtwy-back-rte-kme", name, true), }, }, }, diff --git a/test/functional/shared/resources/kubemetadata_httproute_test.go b/test/functional/shared/resources/kubemetadata_httproute_test.go index 897dbe38f40..a8ff6221e15 100644 --- a/test/functional/shared/resources/kubemetadata_httproute_test.go +++ b/test/functional/shared/resources/kubemetadata_httproute_test.go @@ -73,8 +73,8 @@ func Test_KubeMetadataHTTPRoute(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "ctnr-rte-kme-ctnr"), - validation.NewK8sServiceForResource(name, "ctnr-rte-kme"), + validation.NewK8sPodForResource("ctnr-rte-kme-ctnr", name, true), + validation.NewK8sServiceForResource("ctnr-rte-kme", name, true), }, }, }, diff --git a/test/functional/shared/resources/kubmetadata_cascade_test.go b/test/functional/shared/resources/kubmetadata_cascade_test.go index 19bdb2d04a7..711d5facdb6 100644 --- a/test/functional/shared/resources/kubmetadata_cascade_test.go +++ b/test/functional/shared/resources/kubmetadata_cascade_test.go @@ -91,7 +91,7 @@ func Test_KubeMetadataCascade(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "corerp-kmd-cascade-ctnr"), + validation.NewK8sPodForResource("corerp-kmd-cascade-ctnr", name, true), }, }, }, diff --git a/test/functional/shared/resources/persistent_volume_test.go b/test/functional/shared/resources/persistent_volume_test.go index 59f2f21fb9d..6eb159c8da5 100644 --- a/test/functional/shared/resources/persistent_volume_test.go +++ b/test/functional/shared/resources/persistent_volume_test.go @@ -58,7 +58,7 @@ func Test_PersistentVolume(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "volume-azkv-ctnr"), + validation.NewK8sPodForResource("volume-azkv-ctnr", name, true), }, }, }, diff --git a/test/functional/shared/resources/recipe_terraform_test.go b/test/functional/shared/resources/recipe_terraform_test.go index e0c13cc0a98..2029b54fb33 100644 --- a/test/functional/shared/resources/recipe_terraform_test.go +++ b/test/functional/shared/resources/recipe_terraform_test.go @@ -90,12 +90,10 @@ func Test_TerraformRecipe_KubernetesRedis(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appName: { - validation.NewK8sServiceForResource(appName, redisCacheName). - ValidateLabels(false), + validation.NewK8sServiceForResource(redisCacheName, appName, true), }, secretNamespace: { - validation.NewK8sSecretForResourceWithResourceName(secretPrefix + secretSuffix). - ValidateLabels(false), + validation.NewK8sSecretForResource(secretPrefix+secretSuffix, appName, false), }, }, }, @@ -143,11 +141,10 @@ func Test_TerraformRecipe_Context(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sSecretForResource(name, name), + validation.NewK8sSecretForResource(name, name, true), }, secretNamespace: { - validation.NewK8sSecretForResourceWithResourceName(secretPrefix + secretSuffix). - ValidateLabels(false), + validation.NewK8sSecretForResource(secretPrefix+secretSuffix, name, false), }, }, }, diff --git a/test/functional/shared/resources/storage_test.go b/test/functional/shared/resources/storage_test.go index 574f93ce422..bdf28110c76 100644 --- a/test/functional/shared/resources/storage_test.go +++ b/test/functional/shared/resources/storage_test.go @@ -54,7 +54,7 @@ func Test_Storage(t *testing.T) { K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { - validation.NewK8sPodForResource(name, "azstorage-ctnr"), + validation.NewK8sPodForResource("azstorage-ctnr", name, true), }, }, }, diff --git a/test/validation/k8s.go b/test/validation/k8s.go index a75c33d1778..250a75e3ab8 100644 --- a/test/validation/k8s.go +++ b/test/validation/k8s.go @@ -59,83 +59,125 @@ type K8sObject struct { GroupVersionResource schema.GroupVersionResource Labels map[string]string Kind string - SkipLabelValidation bool ResourceName string + + // CreatedByRadius is used to indicate that the object was created by Radius. + CreatedByRadius bool } -// NewK8sPodForResource creates a new K8sObject with Kind set to "Pod" and the selector labels for the pod -// set to the given application and name. -func NewK8sPodForResource(application string, name string) K8sObject { - return K8sObject{ - // NOTE: we use the selector labels here because the selector labels are intended - // to be determininistic. We might add things to the descriptive labels that are NON deterministic. +// NewK8sPodForResource creates a new K8sObject with Kind set to "Pod" and the ResourceName set to the name provided. +// If the resource is created by Radius, the object will be labeled with the Radius specific labels. +func NewK8sPodForResource(resourceName, appName string, createdByRadius bool) K8sObject { + k8sObject := K8sObject{ GroupVersionResource: schema.GroupVersionResource{ Group: "", Version: "v1", Resource: "pods", }, - Kind: "Pod", - Labels: kuberneteskeys.MakeSelectorLabels(application, name), + Kind: "Pod", + ResourceName: resourceName, } -} -// ValidateLabels creates a copy of the K8sObject and sets the SkipLabelValidation field based on the validate parameter. -func (k K8sObject) ValidateLabels(validate bool) K8sObject { - copy := k - copy.SkipLabelValidation = !validate - return copy + if createdByRadius { + // NOTE: We use the selector labels here because the selector labels are intended to be determininistic. + // We might add things to the descriptive labels that are NON deterministic. + k8sObject.Labels = kuberneteskeys.MakeSelectorLabels(appName, resourceName) + k8sObject.CreatedByRadius = true + } + + return k8sObject } -// NewK8sHTTPProxyForResource creates a K8sObject for a HttpProxy with the Labels set to the application and name provided. -func NewK8sHTTPProxyForResource(application string, name string) K8sObject { - return K8sObject{ +// NewK8sHTTPProxyForResource creates a new K8sObject with Kind set to "HTTPProxy" and the ResourceName set to the name provided. +// If the resource is created by Radius, the object will be labeled with the Radius specific labels. +func NewK8sHTTPProxyForResource(resourceName, appName string, createdByRadius bool) K8sObject { + k8sObject := K8sObject{ GroupVersionResource: schema.GroupVersionResource{ Group: "projectcontour.io", Version: "v1", Resource: "httpproxies", }, - Kind: "HTTPProxy", - Labels: kuberneteskeys.MakeSelectorLabels(application, name), + Kind: "HTTPProxy", + ResourceName: resourceName, } + + if createdByRadius { + // NOTE: We use the selector labels here because the selector labels are intended to be determininistic. + // We might add things to the descriptive labels that are NON deterministic. + k8sObject.Labels = kuberneteskeys.MakeSelectorLabels(appName, resourceName) + k8sObject.CreatedByRadius = true + } + + return k8sObject } -// NewK8sServiceForResource creates a new K8sObject for a service with the Labels set to the application and name. -func NewK8sServiceForResource(application string, name string) K8sObject { - return K8sObject{ +// NewK8sServiceForResource creates a new K8sObject with Kind set to "Service" and the ResourceName set to the name provided. +// If the resource is created by Radius, the object will be labeled with the Radius specific labels. +func NewK8sServiceForResource(resourceName, appName string, createdByRadius bool) K8sObject { + k8sObject := K8sObject{ GroupVersionResource: schema.GroupVersionResource{ Group: "", Version: "v1", Resource: "services", }, - Kind: "Service", - Labels: kuberneteskeys.MakeSelectorLabels(application, name), + Kind: "Service", + ResourceName: resourceName, } + + if createdByRadius { + // NOTE: We use the selector labels here because the selector labels are intended to be determininistic. + // We might add things to the descriptive labels that are NON deterministic. + k8sObject.Labels = kuberneteskeys.MakeSelectorLabels(appName, resourceName) + k8sObject.CreatedByRadius = true + } + + return k8sObject } -// NewK8sSecretForResource creates a K8sObject for a secret with the Labels set to the application and name. -func NewK8sSecretForResource(application string, name string) K8sObject { - return K8sObject{ +// NewK8sSecretForResource creates a new K8sObject with Kind set to "Secret" and the ResourceName set to the name provided. +// If the resource is created by Radius, the object will be labeled with the Radius specific labels. +func NewK8sSecretForResource(resourceName, appName string, createdByRadius bool) K8sObject { + k8sObject := K8sObject{ GroupVersionResource: schema.GroupVersionResource{ Group: "", Version: "v1", Resource: "secrets", }, - Kind: "Secret", - Labels: kuberneteskeys.MakeSelectorLabels(application, name), + Kind: "Secret", + ResourceName: resourceName, + } + + if createdByRadius { + // NOTE: We use the selector labels here because the selector labels are intended to be determininistic. + // We might add things to the descriptive labels that are NON deterministic. + k8sObject.Labels = kuberneteskeys.MakeSelectorLabels(appName, resourceName) + k8sObject.CreatedByRadius = true } + + return k8sObject } -// NewK8sSecretForResourceWithResourceName creates a K8sObject for a secret with the Labels set to the application and name. -func NewK8sSecretForResourceWithResourceName(resourceName string) K8sObject { - return K8sObject{ +// NewK8sDaprComponent creates a new K8sObject with Kind set to "Component" and the ResourceName set to the name provided. +// If the resource is created by Radius, the object will be labeled with the Radius specific labels. +func NewK8sDaprComponent(resourceName, appName string, createdByRadius bool) K8sObject { + k8sObject := K8sObject{ GroupVersionResource: schema.GroupVersionResource{ - Group: "", - Version: "v1", - Resource: "secrets", + Group: "dapr.io", + Version: "v1alpha1", + Resource: "components", }, - Kind: "Secret", + Kind: "Component", ResourceName: resourceName, } + + if createdByRadius { + // NOTE: We use the selector labels here because the selector labels are intended to be determininistic. + // We might add things to the descriptive labels that are NON deterministic. + k8sObject.Labels = kuberneteskeys.MakeSelectorLabels(appName, resourceName) + k8sObject.CreatedByRadius = true + } + + return k8sObject } // ValidateDeploymentsRunning checks if the expected deployments have been created in the given namespace and logs any @@ -536,25 +578,33 @@ func matchesActualLabels(expectedResources []K8sObject, actualResources []unstru remaining := []K8sObject{} for _, expectedResource := range expectedResources { - if expectedResource.SkipLabelValidation && expectedResource.Kind != "Secret" { + if !expectedResource.CreatedByRadius && expectedResource.Kind != "Secret" { continue } + resourceExists := false + for idx, actualResource := range actualResources { - if expectedResource.SkipLabelValidation { - if actualResource.GetName() == expectedResource.ResourceName { - resourceExists = true - actualResources = append(actualResources[:idx], actualResources[idx+1:]...) - break - } - } else { - if labelsEqual(expectedResource.Labels, actualResource.GetLabels()) { - resourceExists = true - actualResources = append(actualResources[:idx], actualResources[idx+1:]...) - break - } + // If the names don't match then we can skip this resource. + if actualResource.GetName() != expectedResource.ResourceName { + continue + } + + // If the resource wasn't created by Radius then the matching names are enough. + if !expectedResource.CreatedByRadius { + resourceExists = true + actualResources = append(actualResources[:idx], actualResources[idx+1:]...) + break + } + + // If the names match then we need to check the labels if the resource was created by Radius. + if labelsEqual(expectedResource.Labels, actualResource.GetLabels()) { + resourceExists = true + actualResources = append(actualResources[:idx], actualResources[idx+1:]...) + break } } + if !resourceExists { remaining = append(remaining, expectedResource) } @@ -563,6 +613,7 @@ func matchesActualLabels(expectedResources []K8sObject, actualResources []unstru for _, remainingResource := range remaining { log.Printf("Failed to validate resource of type %s with labels %s", remainingResource.GroupVersionResource.Resource, remainingResource.Labels) } + return len(remaining) == 0 } @@ -593,16 +644,3 @@ func labelsEqual(expectedLabels map[string]string, actualLabels map[string]strin } return true } - -// NewDaprComponent creates a K8sObject for a Dapr component with the Labels set to the application and name. -func NewDaprComponent(application string, name string) K8sObject { - return K8sObject{ - GroupVersionResource: schema.GroupVersionResource{ - Group: "dapr.io", - Version: "v1alpha1", - Resource: "components", - }, - Kind: "Component", - Labels: kuberneteskeys.MakeSelectorLabels(application, name), - } -}