-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functional test for resourceprovider registration (UDT) (#8079)
# Description -Update to Typespec for ResourceType, ResourceProviderSummary to update defaultApiVersion to be optional field. -Added test for resourceprovider registration which includes calls to create, list and show resource provider. ## Type of change - This pull request adds or changes features of Radius and has an approved issue (#6688 ). Fixes: Part of #6688 ## Contributor checklist Please verify that the PR meets the following requirements, where applicable: - [ ] An overview of proposed schema changes is included in a linked GitHub issue. - [ ] A design document PR is created in the [design-notes repository](https://github.com/radius-project/design-notes/), if new APIs are being introduced. - [ ] If applicable, design document has been reviewed and approved by Radius maintainers/approvers. - [ ] A PR for the [samples repository](https://github.com/radius-project/samples) is created, if existing samples are affected by the changes in this PR. - [ ] A PR for the [documentation repository](https://github.com/radius-project/docs) is created, if the changes in this PR affect the documentation or any user facing updates are made. - [ ] A PR for the [recipes repository](https://github.com/radius-project/recipes) is created, if existing recipes are affected by the changes in this PR. Signed-off-by: lakshmimsft <[email protected]>
- Loading branch information
1 parent
ca08b9b
commit 0aa2d6e
Showing
5 changed files
with
88 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
test/functional-portable/ucp/noncloud/resourceprovider_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
Copyright 2023 The Radius Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package ucp | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/radius-project/radius/test/radcli" | ||
"github.com/radius-project/radius/test/rp" | ||
"github.com/radius-project/radius/test/testcontext" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_ResourceProviderRegistration(t *testing.T) { | ||
ctx, cancel := testcontext.NewWithCancel(t) | ||
t.Cleanup(cancel) | ||
|
||
options := rp.NewTestOptions(t) | ||
cli := radcli.NewCLI(t, options.ConfigFilePath) | ||
|
||
// Setup test data. | ||
const ( | ||
manifestPath = "testdata/resourceprovider.yaml" | ||
resourceProviderName = "MyCompany.Resources" | ||
expectedResourceTypeName = "testResources" | ||
expectedApiVersion = "2025-01-01-preview" | ||
) | ||
|
||
expectedData := map[string]any{ | ||
"name": resourceProviderName, | ||
"locations": map[string]any{ | ||
"global": map[string]any{}, | ||
}, | ||
"resourceTypes": map[string]any{ | ||
expectedResourceTypeName: map[string]any{ | ||
"apiVersions": map[string]any{ | ||
expectedApiVersion: map[string]any{}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
// Create the resource provider using the manifest. | ||
_, err := cli.RunCommand(ctx, []string{"resource-provider", "create", "--from-file", manifestPath}) | ||
require.NoError(t, err) | ||
|
||
// List resource providers. | ||
output, err := cli.RunCommand(ctx, []string{"resource-provider", "list"}) | ||
require.NoError(t, err) | ||
require.Contains(t, output, resourceProviderName) | ||
|
||
// Show details of the resource provider. | ||
output, err = cli.RunCommand(ctx, []string{"resource-provider", "show", resourceProviderName, "--output", "json"}) | ||
require.NoError(t, err) | ||
|
||
var data map[string]any | ||
err = json.Unmarshal([]byte(output), &data) | ||
require.NoError(t, err) | ||
require.Equal(t, expectedData, data) | ||
} |
7 changes: 7 additions & 0 deletions
7
test/functional-portable/ucp/noncloud/testdata/resourceprovider.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name: MyCompany.Resources | ||
types: | ||
testResources: | ||
apiVersions: | ||
"2025-01-01-preview": | ||
schema: {} | ||
capabilities: ["Recipes"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters