Skip to content

Commit

Permalink
Update tests to remove httpRoutes since services can now be deployed …
Browse files Browse the repository at this point in the history
…as part of container rendering. (#6241)

# Description

We now have the ability to deploy k8s services as part of container
rendering (ref #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).

<!--

Please update the following to link the associated issue. This is
required for some kinds of changes (see above).

-->

Fixes: #6099 

## Auto-generated summary

<!--
GitHub Copilot for docs will auto-generate a summary of the PR
-->

<!--
copilot:all
-->
### <samp>🤖 Generated by Copilot at e22a126</samp>

### Summary
🌐🛠️🗑️

<!--
1. 🌐 - This emoji represents the DNS service generation feature, which
allows users to create services with different port and target port
values for containers. It also implies networking and communication
between containers and other resources.
2. 🛠️ - This emoji represents the simplification and refactoring of the
container renderer code, which improves the readability and
maintainability of the code. It also implies fixing a typo and using a
more appropriate data structure for the container ports.
3. 🗑️ - This emoji represents the removal of unnecessary and unused
resources and fields from the test cases, which reduces the complexity
and clutter of the test code. It also implies cleaning up and
simplifying the test scenarios.
-->
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))
  • Loading branch information
nithyatsu authored Nov 10, 2023
1 parent 51fe742 commit c07fa0e
Show file tree
Hide file tree
Showing 23 changed files with 70 additions and 532 deletions.
6 changes: 0 additions & 6 deletions test/functional/datastoresrp/resources/mongodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
},
},
},
Expand Down
6 changes: 0 additions & 6 deletions test/functional/datastoresrp/resources/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"),
},
},
},
Expand Down
6 changes: 0 additions & 6 deletions test/functional/datastoresrp/resources/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,25 @@ resource redisContainer 'Applications.Core/containers@2023-10-01-preview' = {
ports: {
redis: {
containerPort: 6379
provides: redisRoute.id
port: 80
}
}
}
connections: {}
}
}

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'
properties: {
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: ''
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,17 @@ 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
}
}
}

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
Expand All @@ -98,7 +89,6 @@ resource sqlContainer 'Applications.Core/containers@2023-10-01-preview' = {
ports: {
sql: {
containerPort: sqlPort
provides: sqlRoute.id
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,36 +52,26 @@ resource mongoContainer 'Applications.Core/containers@2023-10-01-preview' = {
ports: {
mongo: {
containerPort: 27017
provides: mongoRoute.id
}
}
}
connections: {}
}
}

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'
properties: {
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
}
}
Expand Down
7 changes: 1 addition & 6 deletions test/functional/messagingrp/resources/rabbitmq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"),
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
16 changes: 3 additions & 13 deletions test/functional/shared/mechanics/mechanics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -333,16 +323,16 @@ 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",
},
},
},
})

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{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,60 +17,42 @@ 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
properties: {
application: app.id
connections: {
b: {
source: routeb.id
source: 'http://cyclea:3000'
}
}
container: {
image: magpieimage
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
properties: {
application: app.id
connections: {
a: {
source: routea.id
source: 'http://mechanicsg:3000'
}
}
container: {
image: magpieimage
ports: {
web: {
containerPort: 3000
provides: routeb.id
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
}
}

Expand Down
Loading

0 comments on commit c07fa0e

Please sign in to comment.