Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwahiremat committed Sep 18, 2023
1 parent a62b384 commit b8f9d40
Show file tree
Hide file tree
Showing 20 changed files with 412 additions and 177 deletions.
48 changes: 37 additions & 11 deletions pkg/corerp/processors/extenders/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"github.com/radius-project/radius/pkg/portableresources/processors"
"github.com/radius-project/radius/pkg/recipes"
rpv1 "github.com/radius-project/radius/pkg/rp/v1"
"github.com/radius-project/radius/pkg/to"
"github.com/radius-project/radius/pkg/ucp/resources"
"github.com/stretchr/testify/require"
)

Expand All @@ -37,11 +39,19 @@ func Test_Process(t *testing.T) {
processor := Processor{}
t.Run("success - recipe", func(t *testing.T) {
resource := &datamodel.Extender{}
outputResources := []rpv1.OutputResource{}
for _, resource := range []string{extenderResourceID1} {
id, err := resources.ParseResource(resource)
require.NoError(t, err)
result := rpv1.OutputResource{
ID: id,
RadiusManaged: to.Ptr(true),
}
outputResources = append(outputResources, result)
}
options := processors.Options{
RecipeOutput: &recipes.RecipeOutput{
Resources: []string{
extenderResourceID1,
},
OutputResources: outputResources,
Values: map[string]any{
"bucketName": "myBucket",
"region": "westus",
Expand Down Expand Up @@ -74,7 +84,7 @@ func Test_Process(t *testing.T) {
},
}

expectedOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput)
expectedOutputResources := options.RecipeOutput.OutputResources
require.NoError(t, err)

require.Equal(t, expectedValues, resource.ComputedValues)
Expand Down Expand Up @@ -123,11 +133,19 @@ func Test_Process(t *testing.T) {
},
},
}
outputResources := []rpv1.OutputResource{}
for _, resource := range []string{extenderResourceID2} {
id, err := resources.ParseResource(resource)
require.NoError(t, err)
result := rpv1.OutputResource{
ID: id,
RadiusManaged: to.Ptr(true),
}
outputResources = append(outputResources, result)
}
options := processors.Options{
RecipeOutput: &recipes.RecipeOutput{
Resources: []string{
extenderResourceID2,
},
OutputResources: outputResources,
// Values and secrets will be overridden by the resource.
Values: map[string]any{
"bucketName": "myBucket2",
Expand Down Expand Up @@ -155,7 +173,7 @@ func Test_Process(t *testing.T) {

expectedOutputResources := []rpv1.OutputResource{}

recipeOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput)
recipeOutputResources := options.RecipeOutput.OutputResources
require.NoError(t, err)
expectedOutputResources = append(expectedOutputResources, recipeOutputResources...)

Expand Down Expand Up @@ -196,11 +214,19 @@ func Test_MergeOutputValues(t *testing.T) {
secretsMap := mergeOutputValues(resource.Properties.Secrets, nil, true)
require.Equal(t, resource.Properties.Secrets, secretsMap)

outputResources := []rpv1.OutputResource{}
for _, resource := range []string{extenderResourceID1} {
id, err := resources.ParseResource(resource)
require.NoError(t, err)
result := rpv1.OutputResource{
ID: id,
RadiusManaged: to.Ptr(true),
}
outputResources = append(outputResources, result)
}
options := processors.Options{
RecipeOutput: &recipes.RecipeOutput{
Resources: []string{
extenderResourceID1,
},
OutputResources: outputResources,
Values: map[string]any{
"region": "westus",
},
Expand Down
40 changes: 27 additions & 13 deletions pkg/daprrp/processors/pubsubbrokers/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/radius-project/radius/pkg/recipes"
rpv1 "github.com/radius-project/radius/pkg/rp/v1"
"github.com/radius-project/radius/pkg/to"
"github.com/radius-project/radius/pkg/ucp/resources"
"github.com/radius-project/radius/test/k8sutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -67,6 +68,16 @@ func Test_Process(t *testing.T) {
},
},
}
outputResources := []rpv1.OutputResource{}
for _, resource := range []string{externalResourceID1, kubernetesResource} {
id, err := resources.ParseResource(resource)
require.NoError(t, err)
result := rpv1.OutputResource{
ID: id,
RadiusManaged: to.Ptr(true),
}
outputResources = append(outputResources, result)
}

options := processors.Options{
RuntimeConfiguration: recipes.RuntimeConfiguration{
Expand All @@ -75,12 +86,9 @@ func Test_Process(t *testing.T) {
},
},
RecipeOutput: &recipes.RecipeOutput{
Resources: []string{
externalResourceID1,
kubernetesResource,
},
Values: map[string]any{}, // Component name will be computed for resource name.
Secrets: map[string]any{},
OutputResources: outputResources,
Values: map[string]any{}, // Component name will be computed for resource name.
Secrets: map[string]any{},
},
}

Expand All @@ -94,7 +102,7 @@ func Test_Process(t *testing.T) {
}
expectedSecrets := map[string]rpv1.SecretValueReference{}

expectedOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput)
expectedOutputResources := options.RecipeOutput.OutputResources
require.NoError(t, err)

require.Equal(t, expectedValues, resource.ComputedValues)
Expand Down Expand Up @@ -222,18 +230,24 @@ func Test_Process(t *testing.T) {
},
},
}

outputResources := []rpv1.OutputResource{}
for _, resource := range []string{externalResourceID1, kubernetesResource} {
id, err := resources.ParseResource(resource)
require.NoError(t, err)
result := rpv1.OutputResource{
ID: id,
RadiusManaged: to.Ptr(true),
}
outputResources = append(outputResources, result)
}
options := processors.Options{
RuntimeConfiguration: recipes.RuntimeConfiguration{
Kubernetes: &recipes.KubernetesRuntime{
Namespace: "test-namespace",
},
},
RecipeOutput: &recipes.RecipeOutput{
Resources: []string{
externalResourceID2,
kubernetesResource,
},
OutputResources: outputResources,

// Values and secrets will be overridden by the resource.
Values: map[string]any{
Expand All @@ -254,7 +268,7 @@ func Test_Process(t *testing.T) {
expectedSecrets := map[string]rpv1.SecretValueReference{}
expectedOutputResources := []rpv1.OutputResource{}

recipeOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput)
recipeOutputResources := options.RecipeOutput.OutputResources
require.NoError(t, err)
expectedOutputResources = append(expectedOutputResources, recipeOutputResources...)

Expand Down
37 changes: 27 additions & 10 deletions pkg/daprrp/processors/secretstores/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/radius-project/radius/pkg/recipes"
rpv1 "github.com/radius-project/radius/pkg/rp/v1"
"github.com/radius-project/radius/pkg/to"
"github.com/radius-project/radius/pkg/ucp/resources"
"github.com/radius-project/radius/test/k8sutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -64,18 +65,26 @@ func Test_Process(t *testing.T) {
},
},
}
outputResources := []rpv1.OutputResource{}
for _, resource := range []string{kubernetesResource} {
id, err := resources.ParseResource(resource)
require.NoError(t, err)
result := rpv1.OutputResource{
ID: id,
RadiusManaged: to.Ptr(true),
}
outputResources = append(outputResources, result)
}
options := processors.Options{
RuntimeConfiguration: recipes.RuntimeConfiguration{
Kubernetes: &recipes.KubernetesRuntime{
Namespace: "test-namespace",
},
},
RecipeOutput: &recipes.RecipeOutput{
Resources: []string{
kubernetesResource,
},
Values: map[string]any{}, // Component name will be computed for resource name.
Secrets: map[string]any{},
OutputResources: outputResources,
Values: map[string]any{}, // Component name will be computed for resource name.
Secrets: map[string]any{},
},
}

Expand All @@ -89,7 +98,7 @@ func Test_Process(t *testing.T) {
}
expectedSecrets := map[string]rpv1.SecretValueReference{}

expectedOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput)
expectedOutputResources := options.RecipeOutput.OutputResources
require.NoError(t, err)

require.Equal(t, expectedValues, resource.ComputedValues)
Expand Down Expand Up @@ -206,16 +215,24 @@ func Test_Process(t *testing.T) {
},
},
}
outputResources := []rpv1.OutputResource{}
for _, resource := range []string{kubernetesResource} {
id, err := resources.ParseResource(resource)
require.NoError(t, err)
result := rpv1.OutputResource{
ID: id,
RadiusManaged: to.Ptr(true),
}
outputResources = append(outputResources, result)
}
options := processors.Options{
RuntimeConfiguration: recipes.RuntimeConfiguration{
Kubernetes: &recipes.KubernetesRuntime{
Namespace: "test-namespace",
},
},
RecipeOutput: &recipes.RecipeOutput{
Resources: []string{
kubernetesResource,
},
OutputResources: outputResources,

// Values and secrets will be overridden by the resource.
Values: map[string]any{
Expand All @@ -237,7 +254,7 @@ func Test_Process(t *testing.T) {

expectedOutputResources := []rpv1.OutputResource{}

recipeOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput)
recipeOutputResources := options.RecipeOutput.OutputResources
require.NoError(t, err)
expectedOutputResources = append(expectedOutputResources, recipeOutputResources...)
require.Equal(t, expectedValues, resource.ComputedValues)
Expand Down
39 changes: 27 additions & 12 deletions pkg/daprrp/processors/statestores/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/radius-project/radius/pkg/recipes"
rpv1 "github.com/radius-project/radius/pkg/rp/v1"
"github.com/radius-project/radius/pkg/to"
"github.com/radius-project/radius/pkg/ucp/resources"
"github.com/radius-project/radius/test/k8sutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -67,19 +68,26 @@ func Test_Process(t *testing.T) {
},
},
}
outputResources := []rpv1.OutputResource{}
for _, resource := range []string{externalResourceID1, kubernetesResource} {
id, err := resources.ParseResource(resource)
require.NoError(t, err)
result := rpv1.OutputResource{
ID: id,
RadiusManaged: to.Ptr(true),
}
outputResources = append(outputResources, result)
}
options := processors.Options{
RuntimeConfiguration: recipes.RuntimeConfiguration{
Kubernetes: &recipes.KubernetesRuntime{
Namespace: "test-namespace",
},
},
RecipeOutput: &recipes.RecipeOutput{
Resources: []string{
externalResourceID1,
kubernetesResource,
},
Values: map[string]any{}, // Component name will be computed for resource name.
Secrets: map[string]any{},
OutputResources: outputResources,
Values: map[string]any{}, // Component name will be computed for resource name.
Secrets: map[string]any{},
},
}

Expand All @@ -93,7 +101,7 @@ func Test_Process(t *testing.T) {
}
expectedSecrets := map[string]rpv1.SecretValueReference{}

expectedOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput)
expectedOutputResources := options.RecipeOutput.OutputResources
require.NoError(t, err)

require.Equal(t, expectedValues, resource.ComputedValues)
Expand Down Expand Up @@ -214,17 +222,24 @@ func Test_Process(t *testing.T) {
},
},
}
outputResources := []rpv1.OutputResource{}
for _, resource := range []string{externalResourceID1, kubernetesResource} {
id, err := resources.ParseResource(resource)
require.NoError(t, err)
result := rpv1.OutputResource{
ID: id,
RadiusManaged: to.Ptr(true),
}
outputResources = append(outputResources, result)
}
options := processors.Options{
RuntimeConfiguration: recipes.RuntimeConfiguration{
Kubernetes: &recipes.KubernetesRuntime{
Namespace: "test-namespace",
},
},
RecipeOutput: &recipes.RecipeOutput{
Resources: []string{
externalResourceID2,
kubernetesResource,
},
OutputResources: outputResources,

// Values and secrets will be overridden by the resource.
Values: map[string]any{
Expand All @@ -246,7 +261,7 @@ func Test_Process(t *testing.T) {

expectedOutputResources := []rpv1.OutputResource{}

recipeOutputResources, err := processors.GetOutputResourcesFromRecipe(options.RecipeOutput)
recipeOutputResources := options.RecipeOutput.OutputResources
require.NoError(t, err)
expectedOutputResources = append(expectedOutputResources, recipeOutputResources...)

Expand Down
Loading

0 comments on commit b8f9d40

Please sign in to comment.