Skip to content

Commit

Permalink
remove legacy routing
Browse files Browse the repository at this point in the history
Signed-off-by: lakshmimsft <[email protected]>
  • Loading branch information
lakshmimsft committed Jan 9, 2025
1 parent 73ed52d commit 138974f
Show file tree
Hide file tree
Showing 17 changed files with 336 additions and 306 deletions.
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
name: Applications.Core
locations:
global:
address: "http://localhost:8080"
types:
containers:
apiVersions:
"2025-01-01-preview":
"2023-10-01-preview":
schema: {}
capabilities: []
applications:
apiVersions:
"2025-01-01-preview":
"2023-10-01-preview":
schema: {}
capabilities: []
environments:
apiVersions:
"2025-01-01-preview":
"2023-10-01-preview":
schema: {}
capabilities: []
gateways:
apiVersions:
"2025-01-01-preview":
"2023-10-01-preview":
schema: {}
capabilities: []
secretStores:
apiVersions:
"2025-01-01-preview":
"2023-10-01-preview":
schema: {}
capabilities: []
extenders:
apiVersions:
"2025-01-01-preview":
"2023-10-01-preview":
schema: {}
capabilities: ["SupportsRecipes"]
volumes:
apiVersions:
"2025-01-01-preview":
"2023-10-01-preview":
schema: {}
capabilities: []
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
name: Applications.Dapr
locations:
global:
address: "http://localhost:8080"
types:
configurationStores:
apiVersions:
"2025-01-01-preview":
"2023-10-01-preview":
schema: {}
capabilities: ["SupportsRecipes"]
pubSubBrokers:
apiVersions:
"2025-01-01-preview":
"2023-10-01-preview":
schema: {}
capabilities: ["SupportsRecipes"]
secretStores:
apiVersions:
"2025-01-01-preview":
"2023-10-01-preview":
schema: {}
capabilities: ["SupportsRecipes"]
stateStores:
apiVersions:
"2025-01-01-preview":
"2023-10-01-preview":
schema: {}
capabilities: ["SupportsRecipes"]
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
name: Applications.Datastores
locations:
global:
address: "http://localhost:8080"
types:
mongoDatabases:
apiVersions:
"2025-01-01-preview":
"2023-10-01-preview":
schema: {}
capabilities: ["SupportsRecipes"]
sqlDatabases:
apiVersions:
"2025-01-01-preview":
"2023-10-01-preview":
schema: {}
capabilities: ["SupportsRecipes"]
redisCaches:
apiVersions:
"2025-01-01-preview":
"2023-10-01-preview":
schema: {}
capabilities: ["SupportsRecipes"]
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: Applications.Messaging
locations:
global:
address: "http://localhost:8080"
types:
rabbitMQQueues:
apiVersions:
"2025-01-01-preview":
"2023-10-01-preview":
schema: {}
capabilities: ["SupportsRecipes"]
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: Microsoft.Resources
locations:
global:
address: "http://localhost:5017"
types:
deployments:
apiVersions:
"2025-01-01-preview":
"2023-10-01-preview":
schema: {}
capabilities: []

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Applications.Core
locations:
global:
address: "http://applications-rp.radius-system:5443"
types:
containers:
apiVersions:
"2023-10-01-preview":
schema: {}
capabilities: []
applications:
apiVersions:
"2023-10-01-preview":
schema: {}
capabilities: []
environments:
apiVersions:
"2023-10-01-preview":
schema: {}
capabilities: []
gateways:
apiVersions:
"2023-10-01-preview":
schema: {}
capabilities: []
secretStores:
apiVersions:
"2023-10-01-preview":
schema: {}
capabilities: []
extenders:
apiVersions:
"2023-10-01-preview":
schema: {}
capabilities: ["Recipes"]
volumes:
apiVersions:
"2023-10-01-preview":
schema: {}
capabilities: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Applications.Dapr
locations:
global:
address: "http://applications-rp.radius-system:5443"
types:
configurationStores:
apiVersions:
"2023-10-01-preview":
schema: {}
capabilities: ["Recipes"]
pubSubBrokers:
apiVersions:
"2023-10-01-preview":
schema: {}
capabilities: ["Recipes"]
secretStores:
apiVersions:
"2023-10-01-preview":
schema: {}
capabilities: ["Recipes"]
stateStores:
apiVersions:
"2023-10-01-preview":
schema: {}
capabilities: ["Recipes"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Applications.Datastores
locations:
global:
address: "http://applications-rp.radius-system:5443"
types:
mongoDatabases:
apiVersions:
"2023-10-01-preview":
schema: {}
capabilities: ["Recipes"]
sqlDatabases:
apiVersions:
"2023-10-01-preview":
schema: {}
capabilities: ["Recipes"]
redisCaches:
apiVersions:
"2023-10-01-preview":
schema: {}
capabilities: ["Recipes"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Applications.Messaging
locations:
global:
address: "http://applications-rp.radius-system:5443"
types:
rabbitMQQueues:
apiVersions:
"2023-10-01-preview":
schema: {}
capabilities: ["Recipes"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Microsoft.Resources
locations:
global:
address: "http://bicep-de.radius-system:6443"
types:
deployments:
apiVersions:
"2023-10-01-preview":
schema: {}
capabilities: []
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
v1 "github.com/radius-project/radius/pkg/armrpc/api/v1"
"github.com/radius-project/radius/pkg/armrpc/asyncoperation/controller"
"github.com/radius-project/radius/pkg/components/database"
"github.com/radius-project/radius/pkg/to"
"github.com/radius-project/radius/pkg/ucp/datamodel"
"github.com/radius-project/radius/pkg/ucp/resources"
"github.com/radius-project/radius/pkg/ucp/trackedresource"
Expand All @@ -47,19 +48,58 @@ func Test_Run(t *testing.T) {

id := resources.MustParse("/planes/test/local/resourceGroups/test-rg/providers/Applications.Test/testResources/my-resource")
trackingID := trackedresource.IDFor(id)
data := datamodel.GenericResourceFromID(id, trackingID)
data.Properties.APIVersion = "2025-01-01"

resourceTypeID, err := datamodel.ResourceTypeIDFromResourceID(id)
require.NoError(t, err)

locationID, err := datamodel.ResourceProviderLocationIDFromResourceID(id, "global")
require.NoError(t, err)

plane := datamodel.RadiusPlane{
Properties: datamodel.RadiusPlaneProperties{
ResourceProviders: map[string]string{
"Applications.Test": "https://localhost:1234",
},
},
}
resourceGroup := datamodel.ResourceGroup{}
data := datamodel.GenericResourceFromID(id, trackingID)
resourceGroup := &datamodel.ResourceGroup{
BaseResource: v1.BaseResource{
TrackedResource: v1.TrackedResource{
ID: id.RootScope(),
},
},
}

resourceTypeResource := &datamodel.ResourceType{
BaseResource: v1.BaseResource{
TrackedResource: v1.TrackedResource{
Name: "testResources",
ID: resourceTypeID.String(),
},
},
Properties: datamodel.ResourceTypeProperties{},
}

locationResource := &datamodel.Location{
BaseResource: v1.BaseResource{
TrackedResource: v1.TrackedResource{
Name: "global",
ID: locationID.String(),
},
},
Properties: datamodel.LocationProperties{
Address: to.Ptr("https://localhost:1234"),
ResourceTypes: map[string]datamodel.LocationResourceTypeConfiguration{
"testResources": {
APIVersions: map[string]datamodel.LocationAPIVersionConfiguration{
"2025-01-01": {},
},
},
},
},
}

// Most of the heavy lifting is done by the updater. We just need to test that we're calling it correctly.
t.Run("Success", func(t *testing.T) {
Expand All @@ -70,17 +110,21 @@ func Test_Run(t *testing.T) {
Return(&database.Object{Data: data}, nil).Times(1)

databaseClient.EXPECT().
Get(gomock.Any(), "/planes/"+trackingID.PlaneNamespace(), gomock.Any()).
Get(gomock.Any(), trackingID.PlaneScope(), gomock.Any()).
Return(&database.Object{Data: plane}, nil).Times(1)

databaseClient.EXPECT().
Get(gomock.Any(), resourceTypeID.String(), gomock.Any()).
Return(nil, &database.ErrNotFound{}).Times(1)
Return(&database.Object{Data: resourceTypeResource}, nil).Times(1)

databaseClient.EXPECT().
Get(gomock.Any(), trackingID.RootScope(), gomock.Any()).
Return(&database.Object{Data: resourceGroup}, nil).Times(1)

databaseClient.EXPECT().
Get(gomock.Any(), locationResource.ID).
Return(&database.Object{Data: locationResource}, nil).Times(1)

result, err := pc.Run(testcontext.New(t), &controller.Request{ResourceID: trackingID.String()})
require.Equal(t, controller.Result{}, result)
require.NoError(t, err)
Expand All @@ -94,17 +138,21 @@ func Test_Run(t *testing.T) {
Return(&database.Object{Data: data}, nil).Times(1)

databaseClient.EXPECT().
Get(gomock.Any(), "/planes/"+trackingID.PlaneNamespace(), gomock.Any()).
Get(gomock.Any(), trackingID.PlaneScope(), gomock.Any()).
Return(&database.Object{Data: plane}, nil).Times(1)

databaseClient.EXPECT().
Get(gomock.Any(), resourceTypeID.String(), gomock.Any()).
Return(nil, &database.ErrNotFound{}).Times(1)
Return(&database.Object{Data: resourceTypeResource}, nil).Times(1)

databaseClient.EXPECT().
Get(gomock.Any(), trackingID.RootScope(), gomock.Any()).
Return(&database.Object{Data: resourceGroup}, nil).Times(1)

databaseClient.EXPECT().
Get(gomock.Any(), locationResource.ID).
Return(&database.Object{Data: locationResource}, nil).Times(1)

// Force a retry.
updater.Result = &trackedresource.InProgressErr{}

Expand Down Expand Up @@ -155,6 +203,7 @@ func Test_Run(t *testing.T) {
require.Equal(t, expected, result)
require.NoError(t, err)
})

}

type mockUpdater struct {
Expand Down
14 changes: 0 additions & 14 deletions pkg/ucp/datamodel/radiusplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package datamodel

import (
"strings"

v1 "github.com/radius-project/radius/pkg/armrpc/api/v1"
)

Expand Down Expand Up @@ -46,15 +44,3 @@ type RadiusPlane struct {
func (p RadiusPlane) ResourceTypeName() string {
return p.Type
}

// LookupResourceProvider checks if the input provider is in the list of configured providers.
func (plane RadiusPlane) LookupResourceProvider(key string) string {
var value string
for k, v := range plane.Properties.ResourceProviders {
if strings.EqualFold(k, key) {
value = v
break
}
}
return value
}
Loading

0 comments on commit 138974f

Please sign in to comment.