Skip to content

Commit

Permalink
Validating labels of k8s resources in functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Yetkin Timocin authored and Yetkin Timocin committed Sep 21, 2023
1 parent 1e8b6d9 commit ba1a043
Show file tree
Hide file tree
Showing 26 changed files with 264 additions and 195 deletions.
20 changes: 7 additions & 13 deletions test/functional/daprrp/resources/dapr_pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,11 @@ 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").
AddRadiusLabels(name, "dpsb-manual-app-ctnr"),
validation.NewK8sPodForResource("dpsb-manual-redis"),
validation.NewK8sServiceForResource("dpsb-manual-redis"),
validation.NewDaprComponent("dpsb-manual"),
},
},
},
Expand Down Expand Up @@ -113,11 +110,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"),
validation.NewDaprComponent("dpsb-recipe"),
},
},
},
Expand Down
14 changes: 5 additions & 9 deletions test/functional/daprrp/resources/dapr_secretstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ func Test_DaprSecretStore_Manual(t *testing.T) {
K8sObjects: &validation.K8sObjectSet{
Namespaces: map[string][]validation.K8sObject{
appNamespace: {
validation.NewK8sPodForResource(name, "gnrc-scs-ctnr"),
validation.NewK8sPodForResource("gnrc-scs-ctnr").
AddRadiusLabels(name, "gnrc-scs-ctnr"),

// Not sure why we skip validating the labels
validation.NewDaprComponent(name, "gnrc-scs-manual").
ValidateLabels(false),
validation.NewDaprComponent("gnrc-scs-manual"),
},
},
},
Expand Down Expand Up @@ -104,11 +103,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"),
validation.NewDaprComponent("gnrc-scs-recipe"),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ 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").
AddRadiusLabels(name, "dapr-frontend"),
validation.NewK8sPodForResource("dapr-backend").
AddRadiusLabels(name, "dapr-backend"),
},
},
},
Expand Down
20 changes: 7 additions & 13 deletions test/functional/daprrp/resources/dapr_statestore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,13 @@ 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").
AddRadiusLabels(name, "dapr-sts-manual-ctnr"),

// 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"),
validation.NewK8sServiceForResource("dapr-sts-manual-redis"),
validation.NewDaprComponent("dapr-sts-manual"),
},
},
},
Expand Down Expand Up @@ -115,11 +112,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"),
validation.NewDaprComponent("dapr-sts-recipe"),
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion test/functional/datastoresrp/resources/microsoftsql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ 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").
AddRadiusLabels(name, "mssql-app-ctnr"),
},
},
},
Expand Down
12 changes: 6 additions & 6 deletions test/functional/datastoresrp/resources/mongodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
validation.NewK8sPodForResource("mdb-us-ctnr"),
validation.NewK8sServiceForResource("mdb-us-rte"),
},
},
},
Expand Down Expand Up @@ -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"),
},
},
},
Expand Down Expand Up @@ -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"),
},
},
},
Expand Down Expand Up @@ -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"),
},
},
},
Expand Down
9 changes: 6 additions & 3 deletions test/functional/datastoresrp/resources/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ 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").
AddRadiusLabels(name, "rds-app-ctnr"),
validation.NewK8sPodForResource("rds-ctnr").
AddRadiusLabels(name, "rds-ctnr"),
validation.NewK8sServiceForResource("rds-rte").
AddRadiusLabels(name, "rds-rte"),
},
},
},
Expand Down
13 changes: 8 additions & 5 deletions test/functional/datastoresrp/resources/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ 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").
AddRadiusLabels(name, "sql-app-ctnr"),
validation.NewK8sPodForResource("sql-ctnr").
AddRadiusLabels(name, "sql-ctnr"),
validation.NewK8sServiceForResource("sql-rte").
AddRadiusLabels(name, "sql-rte"),
},
},
},
Expand Down Expand Up @@ -112,8 +115,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"),
validation.NewK8sPodForResource("sql-recipe-resource"),
},
},
},
Expand Down
13 changes: 8 additions & 5 deletions test/functional/messagingrp/resources/rabbitmq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ 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").
AddRadiusLabels(name, "rmq-app-ctnr"),
validation.NewK8sPodForResource("rmq-ctnr").
AddRadiusLabels(name, "rmq-ctnr"),
validation.NewK8sServiceForResource("rmq-rte").
AddRadiusLabels(name, "rmq-rte"),
},
},
},
Expand Down Expand Up @@ -104,8 +107,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"),
validation.NewK8sPodForResource("rmq-recipe-resource"),
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion test/functional/samples/tutorial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ func Test_FirstApplicationSample(t *testing.T) {
K8sObjects: &validation.K8sObjectSet{
Namespaces: map[string][]validation.K8sObject{
appNamespace: {
validation.NewK8sPodForResource(appName, "demo"),
validation.NewK8sPodForResource("demo").
AddRadiusLabels(appName, "demo"),
},
},
},
Expand Down
30 changes: 20 additions & 10 deletions test/functional/shared/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,10 @@ 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").
AddRadiusLabels(name, "containera"),
validation.NewK8sPodForResource("containerb").
AddRadiusLabels(name, "containerb"),
},
},
},
Expand Down Expand Up @@ -481,8 +483,10 @@ 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").
AddRadiusLabels(name, "containera-json"),
validation.NewK8sPodForResource("containerb-json").
AddRadiusLabels(name, "containerb-json"),
},
},
},
Expand Down Expand Up @@ -521,8 +525,10 @@ 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").
AddRadiusLabels(appName, "containera-app-with-resources"),
validation.NewK8sPodForResource("containerb-app-with-resources").
AddRadiusLabels(appName, "containerb-app-with-resources"),
},
},
})
Expand Down Expand Up @@ -555,8 +561,10 @@ 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").
AddRadiusLabels(appName, "containera-app-with-resources"),
validation.NewK8sPodForResource("containerb-app-with-resources").
AddRadiusLabels(appName, "containerb-app-with-resources"),
},
},
})
Expand Down Expand Up @@ -615,8 +623,10 @@ 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").
AddRadiusLabels(name, "containerc"),
validation.NewK8sPodForResource("containerd").
AddRadiusLabels(name, "containerd"),
},
},
},
Expand Down
30 changes: 20 additions & 10 deletions test/functional/shared/mechanics/mechanics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ func Test_RedeployWithAnotherResource(t *testing.T) {
K8sObjects: &validation.K8sObjectSet{
Namespaces: map[string][]validation.K8sObject{
appNamespace: {
validation.NewK8sPodForResource(name, "mechanicsa"),
validation.NewK8sPodForResource("mechanicsa").
AddRadiusLabels(name, "mechanicsa"),
},
},
},
Expand Down Expand Up @@ -110,8 +111,10 @@ 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").
AddRadiusLabels(name, "mechanicsb"),
validation.NewK8sPodForResource("mechanicsc").
AddRadiusLabels(name, "mechanicsc"),
},
},
},
Expand Down Expand Up @@ -145,7 +148,8 @@ func Test_RedeployWithUpdatedResourceUpdatesResource(t *testing.T) {
K8sObjects: &validation.K8sObjectSet{
Namespaces: map[string][]validation.K8sObject{
appNamespace: {
validation.NewK8sPodForResource(name, "mechanicsd"),
validation.NewK8sPodForResource("mechanicsd").
AddRadiusLabels(name, "mechanicsd"),
},
},
},
Expand All @@ -168,7 +172,8 @@ func Test_RedeployWithUpdatedResourceUpdatesResource(t *testing.T) {
K8sObjects: &validation.K8sObjectSet{
Namespaces: map[string][]validation.K8sObject{
appNamespace: {
validation.NewK8sPodForResource(name, "mechanicsd"),
validation.NewK8sPodForResource("mechanicsd").
AddRadiusLabels(name, "mechanicsd"),
},
},
},
Expand Down Expand Up @@ -215,7 +220,8 @@ func Test_RedeployWithTwoSeparateResourcesKeepsResource(t *testing.T) {
K8sObjects: &validation.K8sObjectSet{
Namespaces: map[string][]validation.K8sObject{
appNamespace: {
validation.NewK8sPodForResource(name, "mechanicse"),
validation.NewK8sPodForResource("mechanicse").
AddRadiusLabels(name, "mechanicse"),
},
},
},
Expand Down Expand Up @@ -243,8 +249,10 @@ 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").
AddRadiusLabels(name, "mechanicse"),
validation.NewK8sPodForResource("mechanicsf").
AddRadiusLabels(name, "mechanicsf"),
},
},
},
Expand Down Expand Up @@ -293,8 +301,10 @@ 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").
AddRadiusLabels(name, "mechanicsg"),
validation.NewK8sPodForResource("cyclea").
AddRadiusLabels(name, "cyclea"),
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion test/functional/shared/resources/azure_connections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ func Test_AzureConnections(t *testing.T) {
K8sObjects: &validation.K8sObjectSet{
Namespaces: map[string][]validation.K8sObject{
appNamespace: {
validation.NewK8sPodForResource(name, containerResourceName),
validation.NewK8sPodForResource(containerResourceName).
AddRadiusLabels(name, containerResourceName),
},
},
},
Expand Down
Loading

0 comments on commit ba1a043

Please sign in to comment.