Skip to content

Commit 2a8d96d

Browse files
authored
add sdk/resourcemanager/postgresql/armpostgresql live test (#20685)
* add sdk/resourcemanager/postgresql/armpostgresql live test * update assets.json * set subscriptionId default value * format
1 parent b2cddab commit 2a8d96d

File tree

4 files changed

+492
-98
lines changed

4 files changed

+492
-98
lines changed

sdk/resourcemanager/postgresql/armpostgresql/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "go",
44
"TagPrefix": "go/resourcemanager/postgresql/armpostgresql",
5-
"Tag": "go/resourcemanager/postgresql/armpostgresql_d9bc2d0da1"
5+
"Tag": "go/resourcemanager/postgresql/armpostgresql_2a306718c0"
66
}

sdk/resourcemanager/postgresql/armpostgresql/postgresql_live_test.go

Lines changed: 94 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
1515
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
1616
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
17+
"github.com/Azure/azure-sdk-for-go/sdk/internal/recording"
1718
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/testutil"
1819
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/postgresql/armpostgresql"
1920
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
@@ -35,14 +36,14 @@ type PostgresqlTestSuite struct {
3536

3637
func (testsuite *PostgresqlTestSuite) SetupSuite() {
3738
testutil.StartRecording(testsuite.T(), "sdk/resourcemanager/postgresql/armpostgresql/testdata")
39+
3840
testsuite.ctx = context.Background()
3941
testsuite.cred, testsuite.options = testutil.GetCredAndClientOptions(testsuite.T())
40-
testsuite.serverName = testutil.GenerateAlphaNumericID(testsuite.T(), "pgservers", 6)
41-
testsuite.adminPassword = testutil.GetEnv("ADMIN_PASSWORD", "000000000000")
42-
testsuite.location = testutil.GetEnv("LOCATION", "eastus")
42+
testsuite.serverName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "serverna", 14, true)
43+
testsuite.adminPassword = testutil.GetEnv("ADMIN_PASSWORD", "")
44+
testsuite.location = testutil.GetEnv("LOCATION", "westus")
4345
testsuite.resourceGroupName = testutil.GetEnv("RESOURCE_GROUP_NAME", "scenarioTestTempGroup")
4446
testsuite.subscriptionId = testutil.GetEnv("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000")
45-
4647
resourceGroup, _, err := testutil.CreateResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.location)
4748
testsuite.Require().NoError(err)
4849
testsuite.resourceGroupName = *resourceGroup.Name
@@ -81,8 +82,8 @@ func (testsuite *PostgresqlTestSuite) Prepare() {
8182
AdministratorLoginPassword: to.Ptr(testsuite.adminPassword),
8283
},
8384
SKU: &armpostgresql.SKU{
84-
Family: to.Ptr("Gen5"),
8585
Name: to.Ptr("GP_Gen5_8"),
86+
Family: to.Ptr("Gen5"),
8687
Tier: to.Ptr(armpostgresql.SKUTierGeneralPurpose),
8788
},
8889
Tags: map[string]*string{
@@ -94,7 +95,7 @@ func (testsuite *PostgresqlTestSuite) Prepare() {
9495
testsuite.Require().NoError(err)
9596
}
9697

97-
// Microsoft.DBforPostgreSQL/servers
98+
// Microsoft.DBforPostgreSQL/servers/{serverName}
9899
func (testsuite *PostgresqlTestSuite) TestServers() {
99100
var err error
100101
// From step Servers_List
@@ -143,23 +144,8 @@ func (testsuite *PostgresqlTestSuite) TestServers() {
143144
testsuite.Require().NoError(err)
144145
}
145146

146-
// Microsoft.DBforPostgreSQL/servers/replicas
147-
func (testsuite *PostgresqlTestSuite) TestReplicas() {
148-
var err error
149-
// From step Replicas_ListByServer
150-
fmt.Println("Call operation: Replicas_ListByServer")
151-
replicasClient, err := armpostgresql.NewReplicasClient(testsuite.subscriptionId, testsuite.cred, testsuite.options)
152-
testsuite.Require().NoError(err)
153-
replicasClientNewListByServerPager := replicasClient.NewListByServerPager(testsuite.resourceGroupName, testsuite.serverName, nil)
154-
for replicasClientNewListByServerPager.More() {
155-
_, err := replicasClientNewListByServerPager.NextPage(testsuite.ctx)
156-
testsuite.Require().NoError(err)
157-
break
158-
}
159-
}
160-
161-
// Microsoft.DBforPostgreSQL/servers/firewallRules
162-
func (testsuite *PostgresqlTestSuite) TestFirewallrules() {
147+
// Microsoft.DBforPostgreSQL/servers/{serverName}/firewallRules/{firewallRuleName}
148+
func (testsuite *PostgresqlTestSuite) TestFirewallRules() {
163149
var err error
164150
// From step FirewallRules_CreateOrUpdate
165151
fmt.Println("Call operation: FirewallRules_CreateOrUpdate")
@@ -197,67 +183,63 @@ func (testsuite *PostgresqlTestSuite) TestFirewallrules() {
197183
testsuite.Require().NoError(err)
198184
}
199185

200-
// Microsoft.DBforPostgreSQL/servers/virtualNetworkRules
201-
func (testsuite *PostgresqlTestSuite) TestVirtualnetworkrules() {
186+
// Microsoft.DBforPostgreSQL/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName}
187+
func (testsuite *PostgresqlTestSuite) TestVirtualNetworkRules() {
202188
var subnetId string
203189
var err error
204190
// From step VirtualNetwork_Create
205-
template := map[string]interface{}{
191+
template := map[string]any{
206192
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
207193
"contentVersion": "1.0.0.0",
208-
"outputs": map[string]interface{}{
209-
"subnetId": map[string]interface{}{
194+
"outputs": map[string]any{
195+
"subnetId": map[string]any{
210196
"type": "string",
211197
"value": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworksName'), parameters('subnetName'))]",
212198
},
213199
},
214-
"parameters": map[string]interface{}{
215-
"location": map[string]interface{}{
200+
"parameters": map[string]any{
201+
"location": map[string]any{
216202
"type": "string",
217-
"defaultValue": "$(location)",
203+
"defaultValue": testsuite.location,
218204
},
219-
"subnetName": map[string]interface{}{
205+
"subnetName": map[string]any{
220206
"type": "string",
221207
"defaultValue": "pgsubnet",
222208
},
223-
"virtualNetworksName": map[string]interface{}{
209+
"virtualNetworksName": map[string]any{
224210
"type": "string",
225211
"defaultValue": "pgvnet",
226212
},
227213
},
228-
"resources": []interface{}{
229-
map[string]interface{}{
214+
"resources": []any{
215+
map[string]any{
230216
"name": "[parameters('virtualNetworksName')]",
231217
"type": "Microsoft.Network/virtualNetworks",
232218
"apiVersion": "2021-05-01",
233219
"location": "[parameters('location')]",
234-
"properties": map[string]interface{}{
235-
"addressSpace": map[string]interface{}{
236-
"addressPrefixes": []interface{}{
220+
"properties": map[string]any{
221+
"addressSpace": map[string]any{
222+
"addressPrefixes": []any{
237223
"10.0.0.0/16",
238224
},
239225
},
240-
"subnets": []interface{}{
241-
map[string]interface{}{
226+
"subnets": []any{
227+
map[string]any{
242228
"name": "[parameters('subnetName')]",
243-
"properties": map[string]interface{}{
229+
"properties": map[string]any{
244230
"addressPrefix": "10.0.0.0/24",
245231
},
246232
},
247233
},
248234
},
249-
"tags": map[string]interface{}{},
235+
"tags": map[string]any{},
250236
},
251237
},
252238
}
253-
params := map[string]interface{}{
254-
"location": map[string]interface{}{"value": testsuite.location},
255-
}
256239
deployment := armresources.Deployment{
257240
Properties: &armresources.DeploymentProperties{
258-
Template: template,
259-
Parameters: params,
260-
Mode: to.Ptr(armresources.DeploymentModeIncremental),
241+
Template: template,
242+
Mode: to.Ptr(armresources.DeploymentModeIncremental),
261243
},
262244
}
263245
deploymentExtend, err := testutil.CreateDeployment(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.resourceGroupName, "VirtualNetwork_Create", &deployment)
@@ -300,7 +282,7 @@ func (testsuite *PostgresqlTestSuite) TestVirtualnetworkrules() {
300282
testsuite.Require().NoError(err)
301283
}
302284

303-
// Microsoft.DBforPostgreSQL/servers/databases
285+
// Microsoft.DBforPostgreSQL/servers/{serverName}/databases/{databaseName}
304286
func (testsuite *PostgresqlTestSuite) TestDatabases() {
305287
var err error
306288
// From step Databases_CreateOrUpdate
@@ -339,7 +321,7 @@ func (testsuite *PostgresqlTestSuite) TestDatabases() {
339321
testsuite.Require().NoError(err)
340322
}
341323

342-
// Microsoft.DBforPostgreSQL/servers/configurations
324+
// Microsoft.DBforPostgreSQL/servers/{serverName}/configurations/{configurationName}
343325
func (testsuite *PostgresqlTestSuite) TestConfigurations() {
344326
var err error
345327
// From step Configurations_CreateOrUpdate
@@ -371,8 +353,64 @@ func (testsuite *PostgresqlTestSuite) TestConfigurations() {
371353
testsuite.Require().NoError(err)
372354
}
373355

356+
// Microsoft.DBforPostgreSQL/servers/{serverName}/administrators/activeDirectory
357+
func (testsuite *PostgresqlTestSuite) TestServerAdministrators() {
358+
var err error
359+
// From step ServerAdministrators_CreateOrUpdate
360+
fmt.Println("Call operation: ServerAdministrators_CreateOrUpdate")
361+
serverAdministratorsClient, err := armpostgresql.NewServerAdministratorsClient(testsuite.subscriptionId, testsuite.cred, testsuite.options)
362+
testsuite.Require().NoError(err)
363+
serverAdministratorsClientCreateOrUpdateResponsePoller, err := serverAdministratorsClient.BeginCreateOrUpdate(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, armpostgresql.ServerAdministratorResource{
364+
Properties: &armpostgresql.ServerAdministratorProperties{
365+
AdministratorType: to.Ptr("ActiveDirectory"),
366+
Login: to.Ptr("[email protected]"),
367+
Sid: to.Ptr("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"),
368+
TenantID: to.Ptr("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"),
369+
},
370+
}, nil)
371+
testsuite.Require().NoError(err)
372+
_, err = testutil.PollForTest(testsuite.ctx, serverAdministratorsClientCreateOrUpdateResponsePoller)
373+
testsuite.Require().NoError(err)
374+
375+
// From step ServerAdministrators_List
376+
fmt.Println("Call operation: ServerAdministrators_List")
377+
serverAdministratorsClientNewListPager := serverAdministratorsClient.NewListPager(testsuite.resourceGroupName, testsuite.serverName, nil)
378+
for serverAdministratorsClientNewListPager.More() {
379+
_, err := serverAdministratorsClientNewListPager.NextPage(testsuite.ctx)
380+
testsuite.Require().NoError(err)
381+
break
382+
}
383+
384+
// From step ServerAdministrators_Get
385+
fmt.Println("Call operation: ServerAdministrators_Get")
386+
_, err = serverAdministratorsClient.Get(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, nil)
387+
testsuite.Require().NoError(err)
388+
389+
// From step ServerAdministrators_Delete
390+
fmt.Println("Call operation: ServerAdministrators_Delete")
391+
serverAdministratorsClientDeleteResponsePoller, err := serverAdministratorsClient.BeginDelete(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, nil)
392+
testsuite.Require().NoError(err)
393+
_, err = testutil.PollForTest(testsuite.ctx, serverAdministratorsClientDeleteResponsePoller)
394+
testsuite.Require().NoError(err)
395+
}
396+
397+
// Microsoft.DBforPostgreSQL/servers/replicas
398+
func (testsuite *PostgresqlTestSuite) TestReplicas() {
399+
var err error
400+
// From step Replicas_ListByServer
401+
fmt.Println("Call operation: Replicas_ListByServer")
402+
replicasClient, err := armpostgresql.NewReplicasClient(testsuite.subscriptionId, testsuite.cred, testsuite.options)
403+
testsuite.Require().NoError(err)
404+
replicasClientNewListByServerPager := replicasClient.NewListByServerPager(testsuite.resourceGroupName, testsuite.serverName, nil)
405+
for replicasClientNewListByServerPager.More() {
406+
_, err := replicasClientNewListByServerPager.NextPage(testsuite.ctx)
407+
testsuite.Require().NoError(err)
408+
break
409+
}
410+
}
411+
374412
// Microsoft.DBforPostgreSQL/servers/updateConfigurations
375-
func (testsuite *PostgresqlTestSuite) TestServerparameters() {
413+
func (testsuite *PostgresqlTestSuite) TestServerParameters() {
376414
var err error
377415
// From step ServerParameters_ListUpdateConfigurations
378416
fmt.Println("Call operation: ServerParameters_ListUpdateConfigurations")
@@ -399,7 +437,7 @@ func (testsuite *PostgresqlTestSuite) TestServerparameters() {
399437
}
400438

401439
// Microsoft.DBforPostgreSQL/servers/logFiles
402-
func (testsuite *PostgresqlTestSuite) TestLogfiles() {
440+
func (testsuite *PostgresqlTestSuite) TestLogFiles() {
403441
var err error
404442
// From step LogFiles_ListByServer
405443
fmt.Println("Call operation: LogFiles_ListByServer")
@@ -413,49 +451,8 @@ func (testsuite *PostgresqlTestSuite) TestLogfiles() {
413451
}
414452
}
415453

416-
// Microsoft.DBforPostgreSQL/servers/administrators/activeDirectory
417-
func (testsuite *PostgresqlTestSuite) TestServeradministrators() {
418-
var err error
419-
// From step ServerAdministrators_CreateOrUpdate
420-
fmt.Println("Call operation: ServerAdministrators_CreateOrUpdate")
421-
serverAdministratorsClient, err := armpostgresql.NewServerAdministratorsClient(testsuite.subscriptionId, testsuite.cred, testsuite.options)
422-
testsuite.Require().NoError(err)
423-
serverAdministratorsClientCreateOrUpdateResponsePoller, err := serverAdministratorsClient.BeginCreateOrUpdate(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, armpostgresql.ServerAdministratorResource{
424-
Properties: &armpostgresql.ServerAdministratorProperties{
425-
AdministratorType: to.Ptr("ActiveDirectory"),
426-
Login: to.Ptr("[email protected]"),
427-
Sid: to.Ptr("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"),
428-
TenantID: to.Ptr("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"),
429-
},
430-
}, nil)
431-
testsuite.Require().NoError(err)
432-
_, err = testutil.PollForTest(testsuite.ctx, serverAdministratorsClientCreateOrUpdateResponsePoller)
433-
testsuite.Require().NoError(err)
434-
435-
// From step ServerAdministrators_List
436-
fmt.Println("Call operation: ServerAdministrators_List")
437-
serverAdministratorsClientNewListPager := serverAdministratorsClient.NewListPager(testsuite.resourceGroupName, testsuite.serverName, nil)
438-
for serverAdministratorsClientNewListPager.More() {
439-
_, err := serverAdministratorsClientNewListPager.NextPage(testsuite.ctx)
440-
testsuite.Require().NoError(err)
441-
break
442-
}
443-
444-
// From step ServerAdministrators_Get
445-
fmt.Println("Call operation: ServerAdministrators_Get")
446-
_, err = serverAdministratorsClient.Get(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, nil)
447-
testsuite.Require().NoError(err)
448-
449-
// From step ServerAdministrators_Delete
450-
fmt.Println("Call operation: ServerAdministrators_Delete")
451-
serverAdministratorsClientDeleteResponsePoller, err := serverAdministratorsClient.BeginDelete(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, nil)
452-
testsuite.Require().NoError(err)
453-
_, err = testutil.PollForTest(testsuite.ctx, serverAdministratorsClientDeleteResponsePoller)
454-
testsuite.Require().NoError(err)
455-
}
456-
457454
// Microsoft.DBforPostgreSQL/servers/recoverableServers
458-
func (testsuite *PostgresqlTestSuite) TestRecoverableservers() {
455+
func (testsuite *PostgresqlTestSuite) TestRecoverableServers() {
459456
var err error
460457
// From step RecoverableServers_Get
461458
fmt.Println("Call operation: RecoverableServers_Get")
@@ -466,7 +463,7 @@ func (testsuite *PostgresqlTestSuite) TestRecoverableservers() {
466463
}
467464

468465
// Microsoft.DBforPostgreSQL/servers/performanceTiers
469-
func (testsuite *PostgresqlTestSuite) TestServerbasedperformancetier() {
466+
func (testsuite *PostgresqlTestSuite) TestServerBasedPerformanceTier() {
470467
var err error
471468
// From step ServerBasedPerformanceTier_List
472469
fmt.Println("Call operation: ServerBasedPerformanceTier_List")
@@ -481,7 +478,7 @@ func (testsuite *PostgresqlTestSuite) TestServerbasedperformancetier() {
481478
}
482479

483480
// Microsoft.DBforPostgreSQL/locations/performanceTiers
484-
func (testsuite *PostgresqlTestSuite) TestLocationbasedperformancetier() {
481+
func (testsuite *PostgresqlTestSuite) TestLocationBasedPerformanceTier() {
485482
var err error
486483
// From step LocationBasedPerformanceTier_List
487484
fmt.Println("Call operation: LocationBasedPerformanceTier_List")
@@ -496,7 +493,7 @@ func (testsuite *PostgresqlTestSuite) TestLocationbasedperformancetier() {
496493
}
497494

498495
// Microsoft.DBforPostgreSQL/checkNameAvailability
499-
func (testsuite *PostgresqlTestSuite) TestChecknameavailability() {
496+
func (testsuite *PostgresqlTestSuite) TestCheckNameAvailability() {
500497
var err error
501498
// From step CheckNameAvailability_Execute
502499
fmt.Println("Call operation: CheckNameAvailability_Execute")

0 commit comments

Comments
 (0)