Skip to content

Commit

Permalink
Cleanup SQL databases tests (#7974)
Browse files Browse the repository at this point in the history
# Description

Cleaning up some resource IDs in the sql processor test and deleting the
cloud sql DB functional test since this use case is already covered in a
locally-hosted scenario here:
https://github.com/radius-project/radius/blob/38fcc3e5b705df25d77bee4242948d1ec49013d3/test/functional-portable/datastoresrp/noncloud/resources/sql_test.go#L29

## Type of change

<!--

Please select **one** of the following options that describes your
change and delete the others. Clearly identifying the type of change you
are making will help us review your PR faster, and is used in authoring
release notes.

If you are making a bug fix or functionality change to Radius and do not
have an associated issue link please create one now.

-->

- 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: #7851

Signed-off-by: sk593 <[email protected]>
  • Loading branch information
sk593 authored Oct 16, 2024
1 parent 7918871 commit 0e38ebc
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 186 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/functional-test-cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest-m]
name: [corerp-cloud, ucp-cloud, datastoresrp-cloud]
name: [corerp-cloud, ucp-cloud]
runs-on: ${{ matrix.os }}
env:
UNIQUE_ID: ${{ needs.build.outputs.UNIQUE_ID }}
Expand Down
2 changes: 1 addition & 1 deletion pkg/datastoresrp/processors/sqldatabases/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
func Test_Process(t *testing.T) {
processor := Processor{}

const azureSqlResourceID = "/subscriptions/85716382-7362-45c3-ae03-2126e459a123/resourceGroups/RadiusFunctionalTest/providers/Microsoft.Sql/servers/mssql-radiustest/databases/database-radiustest"
const azureSqlResourceID = "/subscriptions/0000/resourceGroups/test-group/providers/Microsoft.Sql/servers/sql.server/databases/database-radiustest"
const server = "sql.server"
const database = "database-radiustest"
const port = 1433
Expand Down
32 changes: 0 additions & 32 deletions test/createAzureTestResources.bicep
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
param location string = resourceGroup().location

@description('Specifies the SQL username.')
param adminUsername string

@secure()
param adminPassword string

resource account 'Microsoft.DocumentDB/databaseAccounts@2020-04-01' = {
name: 'account-radiustest'
location: location
Expand All @@ -28,30 +22,4 @@ resource account 'Microsoft.DocumentDB/databaseAccounts@2020-04-01' = {
}
}

resource server 'Microsoft.Sql/servers@2021-02-01-preview' = {
name: 'mssql-radiustest'
location: location
tags: {
radiustest: 'corerp-resources-microsoft-sql'
}
properties: {
administratorLogin: adminUsername
administratorLoginPassword: adminPassword
}

resource db 'databases' = {
name: 'database-radiustest'
location: location
}

resource firewall 'firewallRules' = {
name: 'allow'
properties: {
startIpAddress: '0.0.0.0'
endIpAddress: '0.0.0.0'
}
}
}

output sqlServerId string = server::db.id
output cosmosMongoAccountID string = account.id
10 changes: 3 additions & 7 deletions test/executeFunctionalTest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,10 @@ fi

resourcegroup=$1
echo $resourcegroup
# set the username and password for msqlDB to be passed as parameters to the bicep template
adminUser='coolUser'
adminPassword=$(uuidgen)
resp=$(az deployment group create --resource-group $resourcegroup --template-file createAzureTestResources.bicep --parameters 'adminUsername=$adminUser' --parameters 'adminPassword=$adminPassword')

resp=$(az deployment group create --resource-group $resourcegroup --template-file createAzureTestResources.bicep)
cat resp
export AZURE_MSSQL_RESOURCE_ID=$(jq -r '.properties.outputs.sqlServerId.value' <<<"${resp}")
export AZURE_MSSQL_USERNAME=$adminUser
export AZURE_MSSQL_PASSWORD=$adminPassword

export AZURE_COSMOS_MONGODB_ACCOUNT_ID=$(jq -r '.properties.outputs.cosmosMongoAccountID.value' <<<"${resp}")
make test-functional-corerp
make test-functional-msgrp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,66 +16,4 @@ limitations under the License.

package resource_test

import (
"os"
"testing"

"github.com/radius-project/radius/test/rp"
"github.com/radius-project/radius/test/step"
"github.com/radius-project/radius/test/testutil"
"github.com/radius-project/radius/test/validation"
)

func Test_MicrosoftSQL_Manual(t *testing.T) {
template := "testdata/datastoresrp-resources-microsoft-sql.bicep"
name := "dsrp-resources-microsoft-sql"

var adminUsername, adminPassword string

if os.Getenv("AZURE_MSSQL_RESOURCE_ID") == "" {
t.Error("AZURE_MSSQL_RESOURCE_ID environment variable must be set to run this test.")
}
if os.Getenv("AZURE_MSSQL_DATABASE") == "" || os.Getenv("AZURE_MSSQL_SERVER") == "" {
t.Error("AZURE_MSSQL_DATABASE and AZURE_MSSQL_SERVER environment variable must be set to run this test.")
}
if os.Getenv("AZURE_MSSQL_USERNAME") != "" && os.Getenv("AZURE_MSSQL_PASSWORD") != "" {
adminUsername = "adminUsername=" + os.Getenv("AZURE_MSSQL_USERNAME")
adminPassword = "adminPassword=" + os.Getenv("AZURE_MSSQL_PASSWORD")
} else {
t.Error("AZURE_MSSQL_USERNAME and AZURE_MSSQL_PASSWORD environment variable must be set to run this test.")
}

mssqlresourceid := "mssqlresourceid=" + os.Getenv("AZURE_MSSQL_RESOURCE_ID")
sqlDatabse := "database=" + os.Getenv("AZURE_MSSQL_DATABASE")
sqlServer := "server=" + os.Getenv("AZURE_MSSQL_SERVER")
appNamespace := "default-dsrp-resources-microsoft-sql"

test := rp.NewRPTest(t, name, []rp.TestStep{
{
Executor: step.NewDeployExecutor(template, testutil.GetMagpieImage(), mssqlresourceid, adminUsername, adminPassword, sqlDatabse, sqlServer),
RPResources: &validation.RPResourceSet{
Resources: []validation.RPResource{
{
Name: name,
Type: validation.ApplicationsResource,
},
{
Name: "mssql-app-ctnr",
Type: validation.ContainersResource,
App: name,
},
},
},
K8sObjects: &validation.K8sObjectSet{
Namespaces: map[string][]validation.K8sObject{
appNamespace: {
validation.NewK8sPodForResource(name, "mssql-app-ctnr"),
},
},
},
},
})

test.RequiredFeatures = []rp.RequiredFeature{rp.FeatureAzure}
test.Test(t)
}
// TODO: This test will be deleted in a followup PR

This file was deleted.

0 comments on commit 0e38ebc

Please sign in to comment.