From c07fa0eb261302520f34afa20f38830923accd5b Mon Sep 17 00:00:00 2001 From: Nithya Subramanian <98416062+nithyatsu@users.noreply.github.com> Date: Fri, 10 Nov 2023 12:29:57 -0800 Subject: [PATCH] Update tests to remove httpRoutes since services can now be deployed as part of container rendering. (#6241) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description We now have the ability to deploy k8s services as part of container rendering (ref https://github.com/radius-project/radius/issues/6375) This PR updates all the radius repo tests and samples - to remove the httproute constructs from bicep - update service names to match the service generation logic (service name = name of the container providing a service, which is inferred from the presence of port construct. "connections" have url as desitination.) ## Type of change - This pull request is a minor refactor, code cleanup, test improvement, or other maintenance task and doesn't change the functionality of Radius (issue link optional). Fixes: radius-project/radius#6099 ## Auto-generated summary ### 🤖 Generated by Copilot at e22a126 ### Summary 🌐🛠️🗑️ This pull request simplifies the service generation logic for datastores and containers in the radius project. It removes the dependency on httpRoutes resources for datastores, and allows specifying different port and target port values for containers. It updates the renderers, test cases, and test data files accordingly. > _This pull request makes some changes_ > _To how container rendering ranges_ > _It removes httpRoutes_ > _And simplifies routes_ > _For datastores and their exchanges_ ### Walkthrough * Refactor containerPorts struct to use corev1.ServicePort slice and assign port field if missing ([link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-3da981bf20df07918a646eafcd867d6c95abac1f3aef1ed1b50a29f3f4cc8636L242-R267), [link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-3da981bf20df07918a646eafcd867d6c95abac1f3aef1ed1b50a29f3f4cc8636L274-R280), [link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-3da981bf20df07918a646eafcd867d6c95abac1f3aef1ed1b50a29f3f4cc8636L287-R288)) * Update test case for DNS service generation in `render_test.go` to use different container and service port numbers and add port field to container port definition ([link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-6f1219f263ab06a1493ac76960e2ab8cbe647e83e926bff7d13988f393334f94L1541-R1542), [link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-6f1219f263ab06a1493ac76960e2ab8cbe647e83e926bff7d13988f393334f94R1553), [link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-6f1219f263ab06a1493ac76960e2ab8cbe647e83e926bff7d13988f393334f94L1568-R1571)) * Fix typo in error message for invalid ports definition in `render.go` ([link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-3da981bf20df07918a646eafcd867d6c95abac1f3aef1ed1b50a29f3f4cc8636L186-R197)) * Remove httpRoutes resource definition and validation for MongoDB, Redis, and SQL test cases in `mongodb_test.go`, `redis_test.go`, and `sql_test.go` ([link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-3537a95d4323706fe81435869ceaee11338952061d8f3c4d4c0dd526d761b440L55-L59), [link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-3537a95d4323706fe81435869ceaee11338952061d8f3c4d4c0dd526d761b440L71), [link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-9d52e2b8eb6c0350242880d948ab606e69c8f49b293bc6ad92597aaeaafd26b6L53-L57), [link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-9d52e2b8eb6c0350242880d948ab606e69c8f49b293bc6ad92597aaeaafd26b6L69), [link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-61544cabd23b93b06160db8c149184ecef9601bfc914d7c095e623243cce34ecL58-L62), [link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-61544cabd23b93b06160db8c149184ecef9601bfc914d7c095e623243cce34ecL74)) * Remove provides field from container port definition for MongoDB and SQL test cases in `datastoresrp-rs-mongodb-manual.bicep` and `datastoresrp-resources-sqldb-manual.bicep` ([link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-43654e758afeecffd627e6a77947c820172d7650475573e5c241138c54a8a740L55), [link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-bc362702cbffa6fe723a2b733164d41b24270dd76dbe9e775ad40fa2ee04202fL101)) * Add port field to container port definition for Redis test case in `datastoresrp-resources-redis-manual.bicep` ([link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-ec82efbd13c3858a4502bc3c0cab33f23a8edddd7f8e71eccc1d7593c952cf8cL48-R48)) * Update host, port, and connectionString fields for MongoDB, Redis, and SQL test cases in `datastoresrp-rs-mongodb-manual.bicep`, `datastoresrp-resources-redis-manual.bicep`, and `datastoresrp-resources-sqldb-manual.bicep` to use container name and port instead of httpRoutes hostname and port ([link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-ec82efbd13c3858a4502bc3c0cab33f23a8edddd7f8e71eccc1d7593c952cf8cL71-R68), [link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-bc362702cbffa6fe723a2b733164d41b24270dd76dbe9e775ad40fa2ee04202fL66-R69), [link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-43654e758afeecffd627e6a77947c820172d7650475573e5c241138c54a8a740L84-R75)) * Remove httpRoutes resource definition for MongoDB, Redis, and SQL test cases in `datastoresrp-rs-mongodb-manual.bicep`, `datastoresrp-resources-redis-manual.bicep`, and `datastoresrp-resources-sqldb-manual.bicep` ([link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-ec82efbd13c3858a4502bc3c0cab33f23a8edddd7f8e71eccc1d7593c952cf8cL56-R57), [link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-bc362702cbffa6fe723a2b733164d41b24270dd76dbe9e775ad40fa2ee04202fL77-L85), [link](https://github.com/radius-project/radius/pull/6241/files?diff=unified&w=0#diff-43654e758afeecffd627e6a77947c820172d7650475573e5c241138c54a8a740L63-L70)) --- .../datastoresrp/resources/mongodb_test.go | 6 - .../datastoresrp/resources/redis_test.go | 6 - .../datastoresrp/resources/sql_test.go | 6 - .../datastoresrp-resources-redis-manual.bicep | 16 +-- .../datastoresrp-resources-sqldb-manual.bicep | 14 +-- .../datastoresrp-rs-mongodb-manual.bicep | 16 +-- .../messagingrp/resources/rabbitmq_test.go | 7 +- .../testdata/msgrp-resources-rabbitmq.bicep | 12 +- .../shared/mechanics/mechanics_test.go | 16 +-- ...corerp-mechanics-communication-cycle.bicep | 24 +--- ...corerp-mechanics-invalid-resourceids.bicep | 29 ++++- .../shared/resources/container_test.go | 40 ------ .../shared/resources/gateway_test.go | 115 +----------------- .../resources/kubemetadata_gateway_test.go | 16 +-- .../resources/kubemetadata_httproute_test.go | 15 +-- ...sources-friendly-container-version-1.bicep | 15 +-- ...corerp-resources-container-httproute.bicep | 57 --------- .../corerp-resources-gateway-failure.bicep | 9 +- ...resources-gateway-kubernetesmetadata.bicep | 28 +---- ...erp-resources-gateway-sslpassthrough.bicep | 15 +-- ...erp-resources-gateway-tlstermination.bicep | 12 +- .../testdata/corerp-resources-gateway.bicep | 115 ------------------ ...sources-httproute-kubernetesmetadata.bicep | 13 -- 23 files changed, 70 insertions(+), 532 deletions(-) delete mode 100644 test/functional/shared/resources/testdata/corerp-resources-container-httproute.bicep delete mode 100644 test/functional/shared/resources/testdata/corerp-resources-gateway.bicep diff --git a/test/functional/datastoresrp/resources/mongodb_test.go b/test/functional/datastoresrp/resources/mongodb_test.go index f46369ad1e..a4144dbe0b 100644 --- a/test/functional/datastoresrp/resources/mongodb_test.go +++ b/test/functional/datastoresrp/resources/mongodb_test.go @@ -51,11 +51,6 @@ func Test_MongoDB_Manual(t *testing.T) { Type: validation.ContainersResource, App: name, }, - { - Name: "mdb-us-rte", - Type: validation.HttpRoutesResource, - App: name, - }, { Name: "mdb-us-db", Type: validation.MongoDatabasesResource, @@ -68,7 +63,6 @@ func Test_MongoDB_Manual(t *testing.T) { 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), }, }, }, diff --git a/test/functional/datastoresrp/resources/redis_test.go b/test/functional/datastoresrp/resources/redis_test.go index 6bf98383a9..2fc64ffa26 100644 --- a/test/functional/datastoresrp/resources/redis_test.go +++ b/test/functional/datastoresrp/resources/redis_test.go @@ -52,11 +52,6 @@ func Test_Redis_Manual(t *testing.T) { Type: validation.ContainersResource, App: name, }, - { - Name: "rds-rte", - Type: validation.HttpRoutesResource, - App: name, - }, { Name: "rds-rds", Type: validation.RedisCachesResource, @@ -69,7 +64,6 @@ func Test_Redis_Manual(t *testing.T) { appNamespace: { validation.NewK8sPodForResource(name, "rds-app-ctnr"), validation.NewK8sPodForResource(name, "rds-ctnr"), - validation.NewK8sServiceForResource(name, "rds-rte"), }, }, }, diff --git a/test/functional/datastoresrp/resources/sql_test.go b/test/functional/datastoresrp/resources/sql_test.go index 1f93e3e40b..57e628107e 100644 --- a/test/functional/datastoresrp/resources/sql_test.go +++ b/test/functional/datastoresrp/resources/sql_test.go @@ -54,11 +54,6 @@ func Test_SQLDatabase_Manual(t *testing.T) { Type: validation.SQLDatabasesResource, App: name, }, - { - Name: "sql-rte", - Type: validation.HttpRoutesResource, - App: name, - }, { Name: "sql-ctnr", Type: validation.ContainersResource, @@ -71,7 +66,6 @@ func Test_SQLDatabase_Manual(t *testing.T) { appNamespace: { validation.NewK8sPodForResource(name, "sql-app-ctnr"), validation.NewK8sPodForResource(name, "sql-ctnr"), - validation.NewK8sServiceForResource(name, "sql-rte"), }, }, }, diff --git a/test/functional/datastoresrp/resources/testdata/datastoresrp-resources-redis-manual.bicep b/test/functional/datastoresrp/resources/testdata/datastoresrp-resources-redis-manual.bicep index 16c7280570..dd4846f7ef 100644 --- a/test/functional/datastoresrp/resources/testdata/datastoresrp-resources-redis-manual.bicep +++ b/test/functional/datastoresrp/resources/testdata/datastoresrp-resources-redis-manual.bicep @@ -45,7 +45,7 @@ resource redisContainer 'Applications.Core/containers@2023-10-01-preview' = { ports: { redis: { containerPort: 6379 - provides: redisRoute.id + port: 80 } } } @@ -53,14 +53,6 @@ resource redisContainer 'Applications.Core/containers@2023-10-01-preview' = { } } -resource redisRoute 'Applications.Core/httproutes@2023-10-01-preview' = { - name: 'rds-rte' - location: 'global' - properties: { - application: app.id - } -} - resource redis 'Applications.Datastores/redisCaches@2023-10-01-preview' = { name: 'rds-rds' location: 'global' @@ -68,10 +60,10 @@ resource redis 'Applications.Datastores/redisCaches@2023-10-01-preview' = { environment: environment application: app.id resourceProvisioning: 'manual' - host: redisRoute.properties.hostname - port: redisRoute.properties.port + host: 'rds-ctnr' + port: 80 secrets: { - connectionString: '${redisRoute.properties.hostname}:${redisRoute.properties.port}' + connectionString: 'rds-ctnr:6379' password: '' } } diff --git a/test/functional/datastoresrp/resources/testdata/datastoresrp-resources-sqldb-manual.bicep b/test/functional/datastoresrp/resources/testdata/datastoresrp-resources-sqldb-manual.bicep index 424c3f4253..e02020b0d8 100644 --- a/test/functional/datastoresrp/resources/testdata/datastoresrp-resources-sqldb-manual.bicep +++ b/test/functional/datastoresrp/resources/testdata/datastoresrp-resources-sqldb-manual.bicep @@ -63,10 +63,10 @@ resource db 'Applications.Datastores/sqlDatabases@2023-10-01-preview' = { properties: { application: app.id environment: environment - server: sqlRoute.properties.hostname + server: 'sql-ctnr' database: 'master' resourceProvisioning: 'manual' - port: sqlRoute.properties.port + port: sqlPort username: username secrets:{ password: password @@ -74,15 +74,6 @@ resource db 'Applications.Datastores/sqlDatabases@2023-10-01-preview' = { } } -resource sqlRoute 'Applications.Core/httpRoutes@2023-10-01-preview' = { - name: 'sql-rte' - location: location - properties: { - application: app.id - port: sqlPort - } -} - resource sqlContainer 'Applications.Core/containers@2023-10-01-preview' = { name: 'sql-ctnr' location: location @@ -98,7 +89,6 @@ resource sqlContainer 'Applications.Core/containers@2023-10-01-preview' = { ports: { sql: { containerPort: sqlPort - provides: sqlRoute.id } } } diff --git a/test/functional/datastoresrp/resources/testdata/datastoresrp-rs-mongodb-manual.bicep b/test/functional/datastoresrp/resources/testdata/datastoresrp-rs-mongodb-manual.bicep index 6e35380e0a..22fb3af9b8 100644 --- a/test/functional/datastoresrp/resources/testdata/datastoresrp-rs-mongodb-manual.bicep +++ b/test/functional/datastoresrp/resources/testdata/datastoresrp-rs-mongodb-manual.bicep @@ -52,7 +52,6 @@ resource mongoContainer 'Applications.Core/containers@2023-10-01-preview' = { ports: { mongo: { containerPort: 27017 - provides: mongoRoute.id } } } @@ -60,15 +59,6 @@ resource mongoContainer 'Applications.Core/containers@2023-10-01-preview' = { } } -resource mongoRoute 'Applications.Core/httproutes@2023-10-01-preview' = { - name: 'mdb-us-rte' - location: 'global' - properties: { - application: app.id - port: 27017 - } -} - resource mongo 'Applications.Datastores/mongoDatabases@2023-10-01-preview' = { name: 'mdb-us-db' location: 'global' @@ -76,12 +66,12 @@ resource mongo 'Applications.Datastores/mongoDatabases@2023-10-01-preview' = { application: app.id environment: environment resourceProvisioning: 'manual' - host: mongoRoute.properties.hostname - port: mongoRoute.properties.port + host: 'mdb-us-ctnr' + port: 27017 database: 'mongodb-${app.name}' username: username secrets: { - connectionString: 'mongodb://${username}:${password}@${mongoRoute.properties.hostname}:${mongoRoute.properties.port}/mongodb-${app.name}' + connectionString: 'mongodb://${username}:${password}@mdb-us-ctnr:27017/mongodb-${app.name}' password: password } } diff --git a/test/functional/messagingrp/resources/rabbitmq_test.go b/test/functional/messagingrp/resources/rabbitmq_test.go index 23e35122ea..7ad64d73b1 100644 --- a/test/functional/messagingrp/resources/rabbitmq_test.go +++ b/test/functional/messagingrp/resources/rabbitmq_test.go @@ -49,11 +49,6 @@ func Test_RabbitMQ_Manual(t *testing.T) { Type: validation.ContainersResource, App: name, }, - { - Name: "rmq-rte", - Type: validation.HttpRoutesResource, - App: name, - }, { Name: "msg-rmq-rmq", Type: validation.RabbitMQQueuesResource, @@ -66,7 +61,7 @@ func Test_RabbitMQ_Manual(t *testing.T) { appNamespace: { validation.NewK8sPodForResource(name, "rmq-app-ctnr"), validation.NewK8sPodForResource(name, "rmq-ctnr"), - validation.NewK8sServiceForResource(name, "rmq-rte"), + validation.NewK8sServiceForResource(name, "rmq-ctnr"), }, }, }, diff --git a/test/functional/messagingrp/resources/testdata/msgrp-resources-rabbitmq.bicep b/test/functional/messagingrp/resources/testdata/msgrp-resources-rabbitmq.bicep index 276eb1b250..c9fc83a343 100644 --- a/test/functional/messagingrp/resources/testdata/msgrp-resources-rabbitmq.bicep +++ b/test/functional/messagingrp/resources/testdata/msgrp-resources-rabbitmq.bicep @@ -64,20 +64,12 @@ resource rabbitmqContainer 'Applications.Core/containers@2023-10-01-preview' = { ports: { rabbitmq: { containerPort: rabbitmqPort - provides: rabbitmqRoute.id } } } } } -resource rabbitmqRoute 'Applications.Core/httpRoutes@2023-10-01-preview' = { - name: 'rmq-rte' - properties: { - application: app.id - port: rabbitmqPort - } -} resource rabbitmq 'Applications.Messaging/rabbitMQQueues@2023-10-01-preview' = { name: 'msg-rmq-rmq' @@ -86,8 +78,8 @@ resource rabbitmq 'Applications.Messaging/rabbitMQQueues@2023-10-01-preview' = { environment: environment resourceProvisioning: 'manual' queue: 'queue' - host: rabbitmqRoute.properties.hostname - port:rabbitmqRoute.properties.port + host: 'rmq-ctnr' + port: rabbitmqPort username:username secrets: { password: password diff --git a/test/functional/shared/mechanics/mechanics_test.go b/test/functional/shared/mechanics/mechanics_test.go index 0cb95087f4..bccbd829ad 100644 --- a/test/functional/shared/mechanics/mechanics_test.go +++ b/test/functional/shared/mechanics/mechanics_test.go @@ -268,21 +268,11 @@ func Test_CommunicationCycle(t *testing.T) { Name: name, Type: validation.ApplicationsResource, }, - { - Name: "routea", - Type: validation.HttpRoutesResource, - App: name, - }, { Name: "mechanicsg", Type: validation.ContainersResource, App: "corerp-mechanics-communication-cycle", }, - { - Name: "routeb", - Type: validation.HttpRoutesResource, - App: name, - }, { Name: "cyclea", Type: validation.ContainersResource, @@ -333,8 +323,8 @@ func Test_InvalidResourceIDs(t *testing.T) { Code: "ResourceDeploymentFailure", Details: []step.DeploymentErrorDetail{ { - Code: "BadRequest", - MessageContains: "application ID \"global\" for the resource", + Code: "Internal", + MessageContains: "'global' is not a valid resource id", }, }, }, @@ -342,7 +332,7 @@ func Test_InvalidResourceIDs(t *testing.T) { test := shared.NewRPTest(t, name, []shared.TestStep{ { - Executor: step.NewDeployErrorExecutor(template, validate, functional.GetMagpieImage()), + Executor: step.NewDeployErrorExecutor(template, validate, functional.GetMagpieImage(), functional.GetBicepRecipeRegistry(), functional.GetBicepRecipeVersion()), RPResources: &validation.RPResourceSet{ Resources: []validation.RPResource{ { diff --git a/test/functional/shared/mechanics/testdata/corerp-mechanics-communication-cycle.bicep b/test/functional/shared/mechanics/testdata/corerp-mechanics-communication-cycle.bicep index 4ccf44ef0a..67fe42378e 100644 --- a/test/functional/shared/mechanics/testdata/corerp-mechanics-communication-cycle.bicep +++ b/test/functional/shared/mechanics/testdata/corerp-mechanics-communication-cycle.bicep @@ -17,14 +17,6 @@ resource app 'Applications.Core/applications@2023-10-01-preview' = { } } -resource routea 'Applications.Core/httpRoutes@2023-10-01-preview' = { - name: 'routea' - location: location - properties: { - application: app.id - } -} - resource mechanicsg 'Applications.Core/containers@2023-10-01-preview' = { name: 'mechanicsg' location: location @@ -32,7 +24,7 @@ resource mechanicsg 'Applications.Core/containers@2023-10-01-preview' = { application: app.id connections: { b: { - source: routeb.id + source: 'http://cyclea:3000' } } container: { @@ -40,21 +32,12 @@ resource mechanicsg 'Applications.Core/containers@2023-10-01-preview' = { ports: { web: { containerPort: 3000 - provides: routea.id - } + } } } } } -resource routeb 'Applications.Core/httpRoutes@2023-10-01-preview' = { - name: 'routeb' - location: location - properties: { - application: app.id - } -} - resource cyclea 'Applications.Core/containers@2023-10-01-preview' = { name: 'cyclea' location: location @@ -62,7 +45,7 @@ resource cyclea 'Applications.Core/containers@2023-10-01-preview' = { application: app.id connections: { a: { - source: routea.id + source: 'http://mechanicsg:3000' } } container: { @@ -70,7 +53,6 @@ resource cyclea 'Applications.Core/containers@2023-10-01-preview' = { ports: { web: { containerPort: 3000 - provides: routeb.id } } } diff --git a/test/functional/shared/mechanics/testdata/corerp-mechanics-invalid-resourceids.bicep b/test/functional/shared/mechanics/testdata/corerp-mechanics-invalid-resourceids.bicep index fc3d230c72..2a23f3a6e0 100644 --- a/test/functional/shared/mechanics/testdata/corerp-mechanics-invalid-resourceids.bicep +++ b/test/functional/shared/mechanics/testdata/corerp-mechanics-invalid-resourceids.bicep @@ -9,6 +9,9 @@ param environment string = 'test' @description('Specifies the image to be deployed.') param magpieimage string +param registry string +param version string + resource app 'Applications.Core/applications@2023-10-01-preview' = { name: 'corerp-mechanics-invalid-resourceids' location: location @@ -17,11 +20,31 @@ resource app 'Applications.Core/applications@2023-10-01-preview' = { } } -resource httpRoute 'Applications.Core/httpRoutes@2023-10-01-preview' = { - name: 'invalid-rte' - location: location +resource env 'Applications.Core/environments@2023-10-01-preview' = { + name: 'invalid-env' + properties: { + compute: { + kind: 'kubernetes' + resourceId: 'self' + namespace: 'invalid-env' + } + recipes: { + 'Applications.Dapr/pubSubBrokers': { + default: { + templateKind: 'bicep' + templatePath: '${registry}/test/functional/shared/recipes/dapr-pubsub-broker:${version}' + } + } + } + } +} + +resource extender 'Applications.Core/extenders@2023-10-01-preview' = { + name: 'invalid-extndr' properties: { application: app.location + environment: env.id + resourceProvisioning: 'manual' } } diff --git a/test/functional/shared/resources/container_test.go b/test/functional/shared/resources/container_test.go index 789e324186..851f332fa6 100644 --- a/test/functional/shared/resources/container_test.go +++ b/test/functional/shared/resources/container_test.go @@ -63,46 +63,6 @@ func Test_Container(t *testing.T) { test.Test(t) } -func Test_ContainerHttpRoute(t *testing.T) { - template := "testdata/corerp-resources-container-httproute.bicep" - name := "corerp-resources-container-httproute" - appNamespace := "corerp-resources-container-httproute-app" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "ctnr-rte-ctnr", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "ctnr-rte-rte", - Type: validation.HttpRoutesResource, - App: name, - }, - }, - }, - K8sObjects: &validation.K8sObjectSet{ - Namespaces: map[string][]validation.K8sObject{ - appNamespace: { - validation.NewK8sPodForResource(name, "ctnr-rte-ctnr"), - validation.NewK8sServiceForResource(name, "ctnr-rte-rte"), - }, - }, - }, - }, - }) - - test.Test(t) -} - func Test_ContainerDNSSD_TwoContainersDNS(t *testing.T) { template := "testdata/corerp-resources-container-two-containers-dns.bicep" name := "corerp-resources-container-two-containers-dns" diff --git a/test/functional/shared/resources/gateway_test.go b/test/functional/shared/resources/gateway_test.go index 05caa21ae6..e9f7113f53 100644 --- a/test/functional/shared/resources/gateway_test.go +++ b/test/functional/shared/resources/gateway_test.go @@ -46,103 +46,6 @@ type GatewayTestConfig struct { ExpectedStatusCode int } -func Test_Gateway(t *testing.T) { - template := "testdata/corerp-resources-gateway.bicep" - name := "corerp-resources-gateway" - appNamespace := "default-corerp-resources-gateway" - - test := shared.NewRPTest(t, name, []shared.TestStep{ - { - Executor: step.NewDeployExecutor(template, functional.GetMagpieImage()), - RPResources: &validation.RPResourceSet{ - Resources: []validation.RPResource{ - { - Name: name, - Type: validation.ApplicationsResource, - }, - { - Name: "http-gtwy-gtwy", - Type: validation.GatewaysResource, - App: name, - }, - { - Name: "http-gtwy-front-rte", - Type: validation.HttpRoutesResource, - App: name, - }, - { - Name: "http-gtwy-front-ctnr", - Type: validation.ContainersResource, - App: name, - }, - { - Name: "http-gtwy-back-rte", - Type: validation.HttpRoutesResource, - App: name, - }, - { - Name: "http-gtwy-back-ctnr", - Type: validation.ContainersResource, - App: name, - }, - }, - }, - 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"), - }, - }, - }, - PostStepVerify: func(ctx context.Context, t *testing.T, ct shared.RPTest) { - // Get hostname from root HTTPProxy in application namespace - metadata, err := functional.GetHTTPProxyMetadata(ctx, ct.Options.Client, appNamespace, name) - require.NoError(t, err) - t.Logf("found root proxy with hostname: {%s} and status: {%s}", metadata.Hostname, metadata.Status) - - require.Equal(t, "Valid HTTPProxy", metadata.Status) - - // Set up pod port-forwarding for contour-envoy - t.Logf("Setting up portforward") - - err = testGatewayWithPortForward(t, ctx, ct, metadata.Hostname, httpRemotePort, false, []GatewayTestConfig{ - // /healthz is exposed on frontend container - { - Path: "healthz", - ExpectedStatusCode: http.StatusOK, - }, - // /backend2 uses 'replacePrefix', so it can access /healthz on backend container - { - Path: "backend2/healthz", - ExpectedStatusCode: http.StatusOK, - }, - // since /backend1/healthz is not exposed on frontend container, it should return 404 - { - Path: "backend1/healthz", - ExpectedStatusCode: http.StatusNotFound, - }, - }) - if err != nil { - t.Logf("Failed to test Gateway via portforward with error: %s", err) - } else { - // Successfully ran tests - return - } - - require.Fail(t, "Gateway tests failed") - }, - }, - }) - - test.Test(t) -} - func Test_GatewayDNS(t *testing.T) { template := "testdata/corerp-resources-gateway-dns.bicep" name := "corerp-resources-gateway-dns" @@ -241,11 +144,6 @@ func Test_Gateway_SSLPassthrough(t *testing.T) { Type: validation.GatewaysResource, App: name, }, - { - Name: "ssl-gtwy-front-rte", - Type: validation.HttpRoutesResource, - App: name, - }, { Name: "ssl-gtwy-front-ctnr", Type: validation.ContainersResource, @@ -257,9 +155,9 @@ func Test_Gateway_SSLPassthrough(t *testing.T) { Namespaces: map[string][]validation.K8sObject{ appNamespace: { validation.NewK8sPodForResource(name, "ssl-gtwy-front-ctnr"), + validation.NewK8sHTTPProxyForResource(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.NewK8sServiceForResource(name, "ssl-gtwy-front-ctnr"), }, }, }, @@ -317,11 +215,6 @@ func Test_Gateway_TLSTermination(t *testing.T) { Type: validation.SecretStoresResource, App: name, }, - { - Name: "tls-gtwy-front-rte", - Type: validation.HttpRoutesResource, - App: name, - }, { Name: "tls-gtwy-front-ctnr", Type: validation.ContainersResource, @@ -334,8 +227,8 @@ func Test_Gateway_TLSTermination(t *testing.T) { 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.NewK8sHTTPProxyForResource(name, "tls-gtwy-front-ctnr"), + validation.NewK8sServiceForResource(name, "tls-gtwy-front-ctnr"), validation.NewK8sSecretForResource(name, "tls-gtwy-cert"), }, }, diff --git a/test/functional/shared/resources/kubemetadata_gateway_test.go b/test/functional/shared/resources/kubemetadata_gateway_test.go index 0c4211aa01..9d444238f7 100644 --- a/test/functional/shared/resources/kubemetadata_gateway_test.go +++ b/test/functional/shared/resources/kubemetadata_gateway_test.go @@ -50,21 +50,11 @@ func Test_Gateway_KubernetesMetadata(t *testing.T) { Type: validation.GatewaysResource, App: name, }, - { - Name: "http-gtwy-front-rte-kme", - Type: validation.HttpRoutesResource, - App: name, - }, { Name: "http-gtwy-front-ctnr-kme", Type: validation.ContainersResource, App: name, }, - { - Name: "http-gtwy-back-rte-kme", - Type: validation.HttpRoutesResource, - App: name, - }, { Name: "http-gtwy-back-ctnr-kme", Type: validation.ContainersResource, @@ -78,10 +68,8 @@ func Test_Gateway_KubernetesMetadata(t *testing.T) { 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.NewK8sServiceForResource(name, "http-gtwy-front-ctnr-kme"), + validation.NewK8sServiceForResource(name, "http-gtwy-back-ctnr-kme"), }, }, }, diff --git a/test/functional/shared/resources/kubemetadata_httproute_test.go b/test/functional/shared/resources/kubemetadata_httproute_test.go index 03f0ed0c79..c954ccb337 100644 --- a/test/functional/shared/resources/kubemetadata_httproute_test.go +++ b/test/functional/shared/resources/kubemetadata_httproute_test.go @@ -40,11 +40,11 @@ func Test_KubeMetadataHTTPRoute(t *testing.T) { expectedLabels := map[string]string{ "app.kubernetes.io/managed-by": "radius-rp", - "app.kubernetes.io/name": "ctnr-rte-kme", + "app.kubernetes.io/name": "ctnr-rte-kme-ctnr", "app.kubernetes.io/part-of": "corerp-app-rte-kme", "radapp.io/application": "corerp-app-rte-kme", - "radapp.io/resource": "ctnr-rte-kme", - "radapp.io/resource-type": "applications.core-httproutes", + "radapp.io/resource": "ctnr-rte-kme-ctnr", + "radapp.io/resource-type": "applications.core-containers", "user.lbl.1": "user.lbl.val.1", "user.lbl.2": "user.lbl.val.2", } @@ -63,25 +63,20 @@ func Test_KubeMetadataHTTPRoute(t *testing.T) { Type: validation.ContainersResource, App: name, }, - { - Name: "ctnr-rte-kme", - Type: validation.HttpRoutesResource, - App: name, - }, }, }, K8sObjects: &validation.K8sObjectSet{ Namespaces: map[string][]validation.K8sObject{ appNamespace: { validation.NewK8sPodForResource(name, "ctnr-rte-kme-ctnr"), - validation.NewK8sServiceForResource(name, "ctnr-rte-kme"), + validation.NewK8sServiceForResource(name, "ctnr-rte-kme-ctnr"), }, }, }, PostStepVerify: func(ctx context.Context, t *testing.T, test shared.RPTest) { // Verify service labels and annotations - service, err := test.Options.K8sClient.CoreV1().Services(appNamespace).Get(ctx, "ctnr-rte-kme", metav1.GetOptions{}) + service, err := test.Options.K8sClient.CoreV1().Services(appNamespace).Get(ctx, "ctnr-rte-kme-ctnr", metav1.GetOptions{}) require.NoError(t, err) require.NotNil(t, service) diff --git a/test/functional/shared/resources/testdata/containers/corerp-resources-friendly-container-version-1.bicep b/test/functional/shared/resources/testdata/containers/corerp-resources-friendly-container-version-1.bicep index 7fa7b58f50..021b571013 100644 --- a/test/functional/shared/resources/testdata/containers/corerp-resources-friendly-container-version-1.bicep +++ b/test/functional/shared/resources/testdata/containers/corerp-resources-friendly-container-version-1.bicep @@ -45,7 +45,6 @@ resource redisContainer 'Applications.Core/containers@2023-10-01-preview' = { ports: { redis: { containerPort: 6379 - provides: redisRoute.id } } } @@ -53,14 +52,6 @@ resource redisContainer 'Applications.Core/containers@2023-10-01-preview' = { } } -resource redisRoute 'Applications.Core/httproutes@2023-10-01-preview' = { - name: 'friendly-rds-rte' - location: 'global' - properties: { - application: app.id - } -} - resource redis 'Applications.Datastores/redisCaches@2023-10-01-preview' = { name: 'friendly-rds-rds' location: 'global' @@ -68,10 +59,10 @@ resource redis 'Applications.Datastores/redisCaches@2023-10-01-preview' = { environment: environment application: app.id resourceProvisioning: 'manual' - host: redisRoute.properties.hostname - port: redisRoute.properties.port + host: 'friendly-rds-ctnr' + port: 6379 secrets: { - connectionString: '${redisRoute.properties.hostname}:${redisRoute.properties.port}' + connectionString: 'friendly-rds-ctnr:6379' password: '' } } diff --git a/test/functional/shared/resources/testdata/corerp-resources-container-httproute.bicep b/test/functional/shared/resources/testdata/corerp-resources-container-httproute.bicep deleted file mode 100644 index d2d717e383..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-container-httproute.bicep +++ /dev/null @@ -1,57 +0,0 @@ -import radius as radius - -@description('Specifies the location for resources.') -param location string = 'global' - -@description('Specifies the image of the container resource.') -param magpieimage string - -@description('Specifies the port of the container resource.') -param port int = 3000 - -@description('Specifies the environment for resources.') -param environment string - -resource app 'Applications.Core/applications@2023-10-01-preview' = { - name: 'corerp-resources-container-httproute' - location: location - properties: { - environment: environment - extensions: [ - { - kind: 'kubernetesNamespace' - namespace: 'corerp-resources-container-httproute-app' - } - ] - } -} - -resource container 'Applications.Core/containers@2023-10-01-preview' = { - name: 'ctnr-rte-ctnr' - location: location - properties: { - application: app.id - container: { - image: magpieimage - env: { - rteUrl: httproute.properties.url - } - ports: { - web: { - containerPort: port - provides: httproute.id - } - } - } - connections: {} - } -} - -resource httproute 'Applications.Core/httpRoutes@2023-10-01-preview' = { - name: 'ctnr-rte-rte' - location: location - properties: { - application: app.id - port: port - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-gateway-failure.bicep b/test/functional/shared/resources/testdata/corerp-resources-gateway-failure.bicep index b6cc6e368f..8fbecadc0e 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-gateway-failure.bicep +++ b/test/functional/shared/resources/testdata/corerp-resources-gateway-failure.bicep @@ -36,7 +36,7 @@ resource demoGateway 'Applications.Core/gateways@2023-10-01-preview' = { routes: [ { path: '/' - destination: demoRoute.id + destination: 'http://demo-container:3000' } ] tls: { @@ -45,10 +45,3 @@ resource demoGateway 'Applications.Core/gateways@2023-10-01-preview' = { } } } - -resource demoRoute 'Applications.Core/httpRoutes@2023-10-01-preview' = { - name: 'corerp-resources-gateway-failure-route' - properties: { - application: demoApplication.id - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-gateway-kubernetesmetadata.bicep b/test/functional/shared/resources/testdata/corerp-resources-gateway-kubernetesmetadata.bicep index 5941b50e6c..0f21d82eb5 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-gateway-kubernetesmetadata.bicep +++ b/test/functional/shared/resources/testdata/corerp-resources-gateway-kubernetesmetadata.bicep @@ -41,32 +41,23 @@ resource gateway 'Applications.Core/gateways@2023-10-01-preview' = { routes: [ { path: '/' - destination: frontendRoute.id + destination: 'http://http-gtwy-front-ctnr-kme:81' } { path: '/backend1' - destination: backendRoute.id + destination: 'http://http-gtwy-back-ctnr-kme:3000' } { // Route /backend2 requests to the backend, and // transform the request to / path: '/backend2' - destination: backendRoute.id + destination: 'http://http-gtwy-back-ctnr-kme:3000' replacePrefix: '/' } ] } } -resource frontendRoute 'Applications.Core/httpRoutes@2023-10-01-preview' = { - name: 'http-gtwy-front-rte-kme' - location: location - properties: { - application: app.id - port: 81 - } -} - resource frontendContainer 'Applications.Core/containers@2023-10-01-preview' = { name: 'http-gtwy-front-ctnr-kme' location: location @@ -77,7 +68,7 @@ resource frontendContainer 'Applications.Core/containers@2023-10-01-preview' = { ports: { web: { containerPort: port - provides: frontendRoute.id + port: 81 } } readinessProbe: { @@ -88,20 +79,12 @@ resource frontendContainer 'Applications.Core/containers@2023-10-01-preview' = { } connections: { backend: { - source: backendRoute.id + source: 'http://http-gtwy-back-ctnr-kme:3000' } } } } -resource backendRoute 'Applications.Core/httpRoutes@2023-10-01-preview' = { - name: 'http-gtwy-back-rte-kme' - location: location - properties: { - application: app.id - } -} - resource backendContainer 'Applications.Core/containers@2023-10-01-preview' = { name: 'http-gtwy-back-ctnr-kme' location: location @@ -115,7 +98,6 @@ resource backendContainer 'Applications.Core/containers@2023-10-01-preview' = { ports: { web: { containerPort: port - provides: backendRoute.id } } readinessProbe: { diff --git a/test/functional/shared/resources/testdata/corerp-resources-gateway-sslpassthrough.bicep b/test/functional/shared/resources/testdata/corerp-resources-gateway-sslpassthrough.bicep index a332b0a6d4..b922160e34 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-gateway-sslpassthrough.bicep +++ b/test/functional/shared/resources/testdata/corerp-resources-gateway-sslpassthrough.bicep @@ -40,21 +40,12 @@ resource gateway 'Applications.Core/gateways@2023-10-01-preview' = { } routes: [ { - destination: frontendRoute.id + destination: 'https://${frontendContainer.name}:${frontendContainer.properties.container.ports.web.port}' } ] } } -resource frontendRoute 'Applications.Core/httpRoutes@2023-10-01-preview' = { - name: 'ssl-gtwy-front-rte' - location: location - properties: { - application: app.id - port: 443 - } -} - resource frontendContainer 'Applications.Core/containers@2023-10-01-preview' = { name: 'ssl-gtwy-front-ctnr' location: location @@ -69,7 +60,7 @@ resource frontendContainer 'Applications.Core/containers@2023-10-01-preview' = { ports: { web: { containerPort: port - provides: frontendRoute.id + port: 443 } } readinessProbe: { @@ -79,3 +70,5 @@ resource frontendContainer 'Applications.Core/containers@2023-10-01-preview' = { } } } + + diff --git a/test/functional/shared/resources/testdata/corerp-resources-gateway-tlstermination.bicep b/test/functional/shared/resources/testdata/corerp-resources-gateway-tlstermination.bicep index 1f95b50233..4bb2b4f1dd 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-gateway-tlstermination.bicep +++ b/test/functional/shared/resources/testdata/corerp-resources-gateway-tlstermination.bicep @@ -32,7 +32,7 @@ resource gateway 'Applications.Core/gateways@2023-10-01-preview' = { routes: [ { path: '/' - destination: frontendRoute.id + destination: 'http://tls-gtwy-front-ctnr:443' } ] } @@ -54,14 +54,6 @@ resource certificate 'Applications.Core/secretStores@2023-10-01-preview' = { } } -resource frontendRoute 'Applications.Core/httpRoutes@2023-10-01-preview' = { - name: 'tls-gtwy-front-rte' - properties: { - application: app.id - port: 443 - } -} - resource frontendContainer 'Applications.Core/containers@2023-10-01-preview' = { name: 'tls-gtwy-front-ctnr' properties: { @@ -71,7 +63,7 @@ resource frontendContainer 'Applications.Core/containers@2023-10-01-preview' = { ports: { web: { containerPort: port - provides: frontendRoute.id + port: 443 } } readinessProbe: { diff --git a/test/functional/shared/resources/testdata/corerp-resources-gateway.bicep b/test/functional/shared/resources/testdata/corerp-resources-gateway.bicep deleted file mode 100644 index 40ba1a537f..0000000000 --- a/test/functional/shared/resources/testdata/corerp-resources-gateway.bicep +++ /dev/null @@ -1,115 +0,0 @@ -import radius as radius - -@description('Specifies the location for resources.') -param location string = 'local' - -@description('Specifies the environment for resources.') -param environment string - -@description('Specifies the port for the container resource.') -param port int = 3000 - -@description('Specifies the image for the container resource.') -param magpieimage string - -resource app 'Applications.Core/applications@2023-10-01-preview' = { - name: 'corerp-resources-gateway' - location: location - properties: { - environment: environment - } -} - -resource gateway 'Applications.Core/gateways@2023-10-01-preview' = { - name: 'http-gtwy-gtwy' - location: location - properties: { - application: app.id - routes: [ - { - path: '/' - destination: frontendRoute.id - } - { - path: '/backend1' - destination: backendRoute.id - } - { - // Route /backend2 requests to the backend, and - // transform the request to / - path: '/backend2' - destination: backendRoute.id - replacePrefix: '/' - } - ] - } -} - -resource frontendRoute 'Applications.Core/httpRoutes@2023-10-01-preview' = { - name: 'http-gtwy-front-rte' - location: location - properties: { - application: app.id - port: 81 - } -} - -resource frontendContainer 'Applications.Core/containers@2023-10-01-preview' = { - name: 'http-gtwy-front-ctnr' - location: location - properties: { - application: app.id - container: { - image: magpieimage - ports: { - web: { - containerPort: port - provides: frontendRoute.id - } - } - readinessProbe: { - kind: 'httpGet' - containerPort: port - path: '/healthz' - } - } - connections: { - backend: { - source: backendRoute.id - } - } - } -} - -resource backendRoute 'Applications.Core/httpRoutes@2023-10-01-preview' = { - name: 'http-gtwy-back-rte' - location: location - properties: { - application: app.id - } -} - -resource backendContainer 'Applications.Core/containers@2023-10-01-preview' = { - name: 'http-gtwy-back-ctnr' - location: location - properties: { - application: app.id - container: { - image: magpieimage - env: { - gatewayUrl: gateway.properties.url - } - ports: { - web: { - containerPort: port - provides: backendRoute.id - } - } - readinessProbe: { - kind: 'httpGet' - containerPort: port - path: '/healthz' - } - } - } -} diff --git a/test/functional/shared/resources/testdata/corerp-resources-httproute-kubernetesmetadata.bicep b/test/functional/shared/resources/testdata/corerp-resources-httproute-kubernetesmetadata.bicep index 68eeb49211..d09bc68513 100644 --- a/test/functional/shared/resources/testdata/corerp-resources-httproute-kubernetesmetadata.bicep +++ b/test/functional/shared/resources/testdata/corerp-resources-httproute-kubernetesmetadata.bicep @@ -44,25 +44,12 @@ resource container 'Applications.Core/containers@2023-10-01-preview' = { application: app.id container: { image: magpieimage - env: { - rteUrl: httproute.properties.url - } ports: { web: { containerPort: port - provides: httproute.id } } } connections: {} } } - -resource httproute 'Applications.Core/httpRoutes@2023-10-01-preview' = { - name: 'ctnr-rte-kme' - location: location - properties: { - application: app.id - port: port - } -}