From a258714763c4b143e3474acbc3bd820b0ee25f57 Mon Sep 17 00:00:00 2001 From: Peng Jiahui <46921893+Alancere@users.noreply.github.com> Date: Mon, 4 Sep 2023 10:45:42 +0800 Subject: [PATCH] sdk/resourcemanager/mariadb/armmariadb live test (#21473) * sdk/resourcemanager/mariadb/armmariadb live test * fix --- .../mariadb/armmariadb/assets.json | 6 + sdk/resourcemanager/mariadb/armmariadb/go.mod | 10 +- sdk/resourcemanager/mariadb/armmariadb/go.sum | 17 + .../mariadb/armmariadb/mariadb_live_test.go | 508 ++++++++++++++++++ .../performancerecommendations_live_test.go | 147 +++++ .../privateendpointconnections_live_test.go | 283 ++++++++++ .../serversecurityalertpolicies_live_test.go | 130 +++++ 7 files changed, 1100 insertions(+), 1 deletion(-) create mode 100644 sdk/resourcemanager/mariadb/armmariadb/assets.json create mode 100644 sdk/resourcemanager/mariadb/armmariadb/mariadb_live_test.go create mode 100644 sdk/resourcemanager/mariadb/armmariadb/performancerecommendations_live_test.go create mode 100644 sdk/resourcemanager/mariadb/armmariadb/privateendpointconnections_live_test.go create mode 100644 sdk/resourcemanager/mariadb/armmariadb/serversecurityalertpolicies_live_test.go diff --git a/sdk/resourcemanager/mariadb/armmariadb/assets.json b/sdk/resourcemanager/mariadb/armmariadb/assets.json new file mode 100644 index 000000000000..ecbdbf5f8e39 --- /dev/null +++ b/sdk/resourcemanager/mariadb/armmariadb/assets.json @@ -0,0 +1,6 @@ +{ + "AssetsRepo": "Azure/azure-sdk-assets", + "AssetsRepoPrefixPath": "go", + "TagPrefix": "go/resourcemanager/mariadb/armmariadb", + "Tag": "go/resourcemanager/mariadb/armmariadb_54b684234a" +} diff --git a/sdk/resourcemanager/mariadb/armmariadb/go.mod b/sdk/resourcemanager/mariadb/armmariadb/go.mod index 333e2f057db3..0fe39d2bdad5 100644 --- a/sdk/resourcemanager/mariadb/armmariadb/go.mod +++ b/sdk/resourcemanager/mariadb/armmariadb/go.mod @@ -5,17 +5,25 @@ go 1.18 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 + github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 + github.com/stretchr/testify v1.7.0 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dnaeon/go-vcr v1.1.0 // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect github.com/google/uuid v1.3.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/crypto v0.6.0 // indirect golang.org/x/net v0.7.0 // indirect golang.org/x/sys v0.5.0 // indirect golang.org/x/text v0.7.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/sdk/resourcemanager/mariadb/armmariadb/go.sum b/sdk/resourcemanager/mariadb/armmariadb/go.sum index 8ba445a8c4da..6e2c77825a2c 100644 --- a/sdk/resourcemanager/mariadb/armmariadb/go.sum +++ b/sdk/resourcemanager/mariadb/armmariadb/go.sum @@ -4,20 +4,31 @@ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 h1:mLY+pNLjCUeKhgnAJWAKhEUQM+RJQo2H1fuGSw1Ky1E= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2/go.mod h1:FbdwsQ2EzwvXxOPcMFYO8ogEc9uMMIj3YkmCdXdAFmk= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 h1:ECsQtyERDVz3NP3kvDOTLvbQhqWp/x9EsGKtb4ogUr8= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0/go.mod h1:s1tW/At+xHqjNFvWU4G0c0Qv33KOhvbGNj0RCTQDV8s= github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= @@ -27,5 +38,11 @@ golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/mariadb/armmariadb/mariadb_live_test.go b/sdk/resourcemanager/mariadb/armmariadb/mariadb_live_test.go new file mode 100644 index 000000000000..6b03a40c6d16 --- /dev/null +++ b/sdk/resourcemanager/mariadb/armmariadb/mariadb_live_test.go @@ -0,0 +1,508 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmariadb_test + +import ( + "context" + "fmt" + "testing" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/testutil" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mariadb/armmariadb" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" + "github.com/stretchr/testify/suite" +) + +type MariadbTestSuite struct { + suite.Suite + + ctx context.Context + cred azcore.TokenCredential + options *arm.ClientOptions + armEndpoint string + databaseName string + firewallRuleName string + serverName string + virtualNetworkRuleName string + adminPassword string + location string + resourceGroupName string + subscriptionId string +} + +func (testsuite *MariadbTestSuite) SetupSuite() { + testutil.StartRecording(testsuite.T(), "sdk/resourcemanager/mariadb/armmariadb/testdata") + + testsuite.ctx = context.Background() + testsuite.cred, testsuite.options = testutil.GetCredAndClientOptions(testsuite.T()) + testsuite.armEndpoint = "https://management.azure.com" + testsuite.databaseName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "database", 14, false) + testsuite.firewallRuleName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "firewall", 14, false) + testsuite.serverName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "serverna", 14, false) + testsuite.virtualNetworkRuleName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "virtualn", 14, false) + testsuite.adminPassword = recording.GetEnvVariable("ADMIN_PASSWORD", "") + testsuite.location = recording.GetEnvVariable("LOCATION", "westus") + testsuite.resourceGroupName = recording.GetEnvVariable("RESOURCE_GROUP_NAME", "scenarioTestTempGroup") + testsuite.subscriptionId = recording.GetEnvVariable("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + resourceGroup, _, err := testutil.CreateResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.location) + testsuite.Require().NoError(err) + testsuite.resourceGroupName = *resourceGroup.Name + testsuite.Prepare() +} + +func (testsuite *MariadbTestSuite) TearDownSuite() { + testsuite.Cleanup() + _, err := testutil.DeleteResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.resourceGroupName) + testsuite.Require().NoError(err) + testutil.StopRecording(testsuite.T()) +} + +func TestMariadbTestSuite(t *testing.T) { + suite.Run(t, new(MariadbTestSuite)) +} + +func (testsuite *MariadbTestSuite) Prepare() { + var err error + // From step Servers_Create + fmt.Println("Call operation: Servers_Create") + serversClient, err := armmariadb.NewServersClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + serversClientCreateResponsePoller, err := serversClient.BeginCreate(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, armmariadb.ServerForCreate{ + Location: to.Ptr(testsuite.location), + Properties: &armmariadb.ServerPropertiesForDefaultCreate{ + CreateMode: to.Ptr(armmariadb.CreateModeDefault), + MinimalTLSVersion: to.Ptr(armmariadb.MinimalTLSVersionEnumTLS12), + SSLEnforcement: to.Ptr(armmariadb.SSLEnforcementEnumEnabled), + StorageProfile: &armmariadb.StorageProfile{ + BackupRetentionDays: to.Ptr[int32](7), + GeoRedundantBackup: to.Ptr(armmariadb.GeoRedundantBackupEnabled), + StorageMB: to.Ptr[int32](128000), + }, + AdministratorLogin: to.Ptr("cloudsa"), + AdministratorLoginPassword: to.Ptr(testsuite.adminPassword), + }, + SKU: &armmariadb.SKU{ + Name: to.Ptr("GP_Gen5_2"), + Capacity: to.Ptr[int32](2), + Family: to.Ptr("Gen5"), + Tier: to.Ptr(armmariadb.SKUTierGeneralPurpose), + }, + Tags: map[string]*string{ + "ElasticServer": to.Ptr("1"), + }, + }, nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, serversClientCreateResponsePoller) + testsuite.Require().NoError(err) +} + +// Microsoft.DBforMariaDB/servers/{serverName} +func (testsuite *MariadbTestSuite) TestServers() { + var err error + // From step Servers_List + fmt.Println("Call operation: Servers_List") + serversClient, err := armmariadb.NewServersClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + serversClientNewListPager := serversClient.NewListPager(nil) + for serversClientNewListPager.More() { + _, err := serversClientNewListPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } + + // From step Servers_ListByResourceGroup + fmt.Println("Call operation: Servers_ListByResourceGroup") + serversClientNewListByResourceGroupPager := serversClient.NewListByResourceGroupPager(testsuite.resourceGroupName, nil) + for serversClientNewListByResourceGroupPager.More() { + _, err := serversClientNewListByResourceGroupPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } + + // From step Servers_Get + fmt.Println("Call operation: Servers_Get") + _, err = serversClient.Get(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, nil) + testsuite.Require().NoError(err) + + // From step Servers_Update + fmt.Println("Call operation: Servers_Update") + serversClientUpdateResponsePoller, err := serversClient.BeginUpdate(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, armmariadb.ServerUpdateParameters{ + Properties: &armmariadb.ServerUpdateParametersProperties{ + AdministratorLoginPassword: to.Ptr(""), + SSLEnforcement: to.Ptr(armmariadb.SSLEnforcementEnumDisabled), + }, + }, nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, serversClientUpdateResponsePoller) + testsuite.Require().NoError(err) + + // From step Servers_Restart + fmt.Println("Call operation: Servers_Restart") + serversClientRestartResponsePoller, err := serversClient.BeginRestart(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, serversClientRestartResponsePoller) + testsuite.Require().NoError(err) + + // From step Servers_Stop + fmt.Println("Call operation: Servers_Stop") + serversClientStopResponsePoller, err := serversClient.BeginStop(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, serversClientStopResponsePoller) + testsuite.Require().NoError(err) + + // From step Servers_Start + fmt.Println("Call operation: Servers_Start") + serversClientStartResponsePoller, err := serversClient.BeginStart(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, serversClientStartResponsePoller) + testsuite.Require().NoError(err) +} + +// Microsoft.DBforMariaDB/servers/{serverName}/replicas +func (testsuite *MariadbTestSuite) TestReplicas() { + var err error + // From step Replicas_ListByServer + fmt.Println("Call operation: Replicas_ListByServer") + replicasClient, err := armmariadb.NewReplicasClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + replicasClientNewListByServerPager := replicasClient.NewListByServerPager(testsuite.resourceGroupName, testsuite.serverName, nil) + for replicasClientNewListByServerPager.More() { + _, err := replicasClientNewListByServerPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } +} + +// Microsoft.DBforMariaDB/servers/{serverName}/firewallRules/{firewallRuleName} +func (testsuite *MariadbTestSuite) TestFirewallRules() { + var err error + // From step FirewallRules_CreateOrUpdate + fmt.Println("Call operation: FirewallRules_CreateOrUpdate") + firewallRulesClient, err := armmariadb.NewFirewallRulesClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + firewallRulesClientCreateOrUpdateResponsePoller, err := firewallRulesClient.BeginCreateOrUpdate(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, testsuite.firewallRuleName, armmariadb.FirewallRule{ + Properties: &armmariadb.FirewallRuleProperties{ + EndIPAddress: to.Ptr("255.255.255.255"), + StartIPAddress: to.Ptr("0.0.0.0"), + }, + }, nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, firewallRulesClientCreateOrUpdateResponsePoller) + testsuite.Require().NoError(err) + + // From step FirewallRules_ListByServer + fmt.Println("Call operation: FirewallRules_ListByServer") + firewallRulesClientNewListByServerPager := firewallRulesClient.NewListByServerPager(testsuite.resourceGroupName, testsuite.serverName, nil) + for firewallRulesClientNewListByServerPager.More() { + _, err := firewallRulesClientNewListByServerPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } + + // From step FirewallRules_Get + fmt.Println("Call operation: FirewallRules_Get") + _, err = firewallRulesClient.Get(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, testsuite.firewallRuleName, nil) + testsuite.Require().NoError(err) + + // From step FirewallRules_Delete + fmt.Println("Call operation: FirewallRules_Delete") + firewallRulesClientDeleteResponsePoller, err := firewallRulesClient.BeginDelete(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, testsuite.firewallRuleName, nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, firewallRulesClientDeleteResponsePoller) + testsuite.Require().NoError(err) +} + +// Microsoft.DBforMariaDB/servers/{serverName}/virtualNetworkRules/{virtualNetworkRuleName} +func (testsuite *MariadbTestSuite) TestVirtualNetworkRules() { + var subnetId string + var err error + // From step Create_Subnet + template := map[string]any{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "outputs": map[string]any{ + "subnetId": map[string]any{ + "type": "string", + "value": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworksName'), 'default')]", + }, + }, + "parameters": map[string]any{ + "location": map[string]any{ + "type": "string", + "defaultValue": testsuite.location, + }, + "virtualNetworksName": map[string]any{ + "type": "string", + "defaultValue": "mariadbvnet", + }, + }, + "resources": []any{ + map[string]any{ + "name": "[parameters('virtualNetworksName')]", + "type": "Microsoft.Network/virtualNetworks", + "apiVersion": "2021-05-01", + "location": "[parameters('location')]", + "properties": map[string]any{ + "addressSpace": map[string]any{ + "addressPrefixes": []any{ + "10.0.0.0/16", + }, + }, + "subnets": []any{ + map[string]any{ + "name": "default", + "properties": map[string]any{ + "addressPrefix": "10.0.0.0/24", + "serviceEndpoints": []any{ + map[string]any{ + "service": "Microsoft.Sql", + }, + }, + }, + }, + }, + }, + "tags": map[string]any{}, + }, + }, + } + deployment := armresources.Deployment{ + Properties: &armresources.DeploymentProperties{ + Template: template, + Mode: to.Ptr(armresources.DeploymentModeIncremental), + }, + } + deploymentExtend, err := testutil.CreateDeployment(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.resourceGroupName, "Create_Subnet", &deployment) + testsuite.Require().NoError(err) + subnetId = deploymentExtend.Properties.Outputs.(map[string]interface{})["subnetId"].(map[string]interface{})["value"].(string) + + // From step VirtualNetworkRules_CreateOrUpdate + fmt.Println("Call operation: VirtualNetworkRules_CreateOrUpdate") + virtualNetworkRulesClient, err := armmariadb.NewVirtualNetworkRulesClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + virtualNetworkRulesClientCreateOrUpdateResponsePoller, err := virtualNetworkRulesClient.BeginCreateOrUpdate(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, testsuite.virtualNetworkRuleName, armmariadb.VirtualNetworkRule{ + Properties: &armmariadb.VirtualNetworkRuleProperties{ + IgnoreMissingVnetServiceEndpoint: to.Ptr(false), + VirtualNetworkSubnetID: to.Ptr(subnetId), + }, + }, nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, virtualNetworkRulesClientCreateOrUpdateResponsePoller) + testsuite.Require().NoError(err) + + // From step VirtualNetworkRules_ListByServer + fmt.Println("Call operation: VirtualNetworkRules_ListByServer") + virtualNetworkRulesClientNewListByServerPager := virtualNetworkRulesClient.NewListByServerPager(testsuite.resourceGroupName, testsuite.serverName, nil) + for virtualNetworkRulesClientNewListByServerPager.More() { + _, err := virtualNetworkRulesClientNewListByServerPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } + + // From step VirtualNetworkRules_Get + fmt.Println("Call operation: VirtualNetworkRules_Get") + _, err = virtualNetworkRulesClient.Get(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, testsuite.virtualNetworkRuleName, nil) + testsuite.Require().NoError(err) + + // From step VirtualNetworkRules_Delete + fmt.Println("Call operation: VirtualNetworkRules_Delete") + virtualNetworkRulesClientDeleteResponsePoller, err := virtualNetworkRulesClient.BeginDelete(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, testsuite.virtualNetworkRuleName, nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, virtualNetworkRulesClientDeleteResponsePoller) + testsuite.Require().NoError(err) +} + +// Microsoft.DBforMariaDB/servers/{serverName}/databases/{databaseName} +func (testsuite *MariadbTestSuite) TestDatabases() { + var err error + // From step Databases_CreateOrUpdate + fmt.Println("Call operation: Databases_CreateOrUpdate") + databasesClient, err := armmariadb.NewDatabasesClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + databasesClientCreateOrUpdateResponsePoller, err := databasesClient.BeginCreateOrUpdate(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, testsuite.databaseName, armmariadb.Database{ + Properties: &armmariadb.DatabaseProperties{ + Charset: to.Ptr("utf8"), + Collation: to.Ptr("utf8_general_ci"), + }, + }, nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, databasesClientCreateOrUpdateResponsePoller) + testsuite.Require().NoError(err) + + // From step Databases_ListByServer + fmt.Println("Call operation: Databases_ListByServer") + databasesClientNewListByServerPager := databasesClient.NewListByServerPager(testsuite.resourceGroupName, testsuite.serverName, nil) + for databasesClientNewListByServerPager.More() { + _, err := databasesClientNewListByServerPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } + + // From step Databases_Get + fmt.Println("Call operation: Databases_Get") + _, err = databasesClient.Get(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, testsuite.databaseName, nil) + testsuite.Require().NoError(err) + + // From step Databases_Delete + fmt.Println("Call operation: Databases_Delete") + databasesClientDeleteResponsePoller, err := databasesClient.BeginDelete(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, testsuite.databaseName, nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, databasesClientDeleteResponsePoller) + testsuite.Require().NoError(err) +} + +// Microsoft.DBforMariaDB/servers/{serverName}/configurations/{configurationName} +func (testsuite *MariadbTestSuite) TestConfigurations() { + var err error + // From step Configurations_CreateOrUpdate + fmt.Println("Call operation: Configurations_CreateOrUpdate") + configurationsClient, err := armmariadb.NewConfigurationsClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + configurationsClientCreateOrUpdateResponsePoller, err := configurationsClient.BeginCreateOrUpdate(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, "event_scheduler", armmariadb.Configuration{ + Properties: &armmariadb.ConfigurationProperties{ + Source: to.Ptr("user-override"), + Value: to.Ptr("off"), + }, + }, nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, configurationsClientCreateOrUpdateResponsePoller) + testsuite.Require().NoError(err) + + // From step Configurations_ListByServer + fmt.Println("Call operation: Configurations_ListByServer") + configurationsClientNewListByServerPager := configurationsClient.NewListByServerPager(testsuite.resourceGroupName, testsuite.serverName, nil) + for configurationsClientNewListByServerPager.More() { + _, err := configurationsClientNewListByServerPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } + + // From step Configurations_Get + fmt.Println("Call operation: Configurations_Get") + _, err = configurationsClient.Get(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, "event_scheduler", nil) + testsuite.Require().NoError(err) +} + +// Microsoft.DBforMariaDB/servers/{serverName}/updateConfigurations +func (testsuite *MariadbTestSuite) TestServerParameters() { + var err error + // From step ServerParameters_ListUpdateConfigurations + fmt.Println("Call operation: ServerParameters_ListUpdateConfigurations") + serverParametersClient, err := armmariadb.NewServerParametersClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + serverParametersClientListUpdateConfigurationsResponsePoller, err := serverParametersClient.BeginListUpdateConfigurations(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, armmariadb.ConfigurationListResult{ + Value: []*armmariadb.Configuration{ + { + Name: to.Ptr("event_scheduler"), + Properties: &armmariadb.ConfigurationProperties{ + Value: to.Ptr("OFF"), + }, + }}, + }, nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, serverParametersClientListUpdateConfigurationsResponsePoller) + testsuite.Require().NoError(err) +} + +// Microsoft.DBforMariaDB/servers/{serverName}/logFiles +func (testsuite *MariadbTestSuite) TestLogFiles() { + var err error + // From step LogFiles_ListByServer + fmt.Println("Call operation: LogFiles_ListByServer") + logFilesClient, err := armmariadb.NewLogFilesClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + logFilesClientNewListByServerPager := logFilesClient.NewListByServerPager(testsuite.resourceGroupName, testsuite.serverName, nil) + for logFilesClientNewListByServerPager.More() { + _, err := logFilesClientNewListByServerPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } +} + +// Microsoft.DBforMariaDB/servers/{serverName}/recoverableServers +func (testsuite *MariadbTestSuite) TestRecoverableServers() { + var err error + // From step RecoverableServers_Get + fmt.Println("Call operation: RecoverableServers_Get") + recoverableServersClient, err := armmariadb.NewRecoverableServersClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + _, err = recoverableServersClient.Get(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, nil) + testsuite.Require().NoError(err) +} + +// Microsoft.DBforMariaDB/servers/{serverName}/performanceTiers +func (testsuite *MariadbTestSuite) TestServerBasedPerformanceTier() { + var err error + // From step ServerBasedPerformanceTier_List + fmt.Println("Call operation: ServerBasedPerformanceTier_List") + serverBasedPerformanceTierClient, err := armmariadb.NewServerBasedPerformanceTierClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + serverBasedPerformanceTierClientNewListPager := serverBasedPerformanceTierClient.NewListPager(testsuite.resourceGroupName, testsuite.serverName, nil) + for serverBasedPerformanceTierClientNewListPager.More() { + _, err := serverBasedPerformanceTierClientNewListPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } +} + +// Microsoft.DBforMariaDB/locations/{locationName}/performanceTiers +func (testsuite *MariadbTestSuite) TestLocationBasedPerformanceTier() { + var err error + // From step LocationBasedPerformanceTier_List + fmt.Println("Call operation: LocationBasedPerformanceTier_List") + locationBasedPerformanceTierClient, err := armmariadb.NewLocationBasedPerformanceTierClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + locationBasedPerformanceTierClientNewListPager := locationBasedPerformanceTierClient.NewListPager("WestUS", nil) + for locationBasedPerformanceTierClientNewListPager.More() { + _, err := locationBasedPerformanceTierClientNewListPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } +} + +// Microsoft.DBforMariaDB/checkNameAvailability +func (testsuite *MariadbTestSuite) TestCheckNameAvailability() { + var err error + // From step CheckNameAvailability_Execute + fmt.Println("Call operation: CheckNameAvailability_Execute") + checkNameAvailabilityClient, err := armmariadb.NewCheckNameAvailabilityClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + _, err = checkNameAvailabilityClient.Execute(testsuite.ctx, armmariadb.NameAvailabilityRequest{ + Name: to.Ptr("name1"), + Type: to.Ptr("Microsoft.DBforMariaDB"), + }, nil) + testsuite.Require().NoError(err) +} + +// Microsoft.DBforMariaDB/operations +func (testsuite *MariadbTestSuite) TestOperations() { + var err error + // From step Operations_List + fmt.Println("Call operation: Operations_List") + operationsClient, err := armmariadb.NewOperationsClient(testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + _, err = operationsClient.List(testsuite.ctx, nil) + testsuite.Require().NoError(err) +} + +func (testsuite *MariadbTestSuite) Cleanup() { + var err error + // From step Servers_Delete + fmt.Println("Call operation: Servers_Delete") + serversClient, err := armmariadb.NewServersClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + serversClientDeleteResponsePoller, err := serversClient.BeginDelete(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, serversClientDeleteResponsePoller) + testsuite.Require().NoError(err) +} diff --git a/sdk/resourcemanager/mariadb/armmariadb/performancerecommendations_live_test.go b/sdk/resourcemanager/mariadb/armmariadb/performancerecommendations_live_test.go new file mode 100644 index 000000000000..11a5c3df13e1 --- /dev/null +++ b/sdk/resourcemanager/mariadb/armmariadb/performancerecommendations_live_test.go @@ -0,0 +1,147 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmariadb_test + +import ( + "context" + "fmt" + "testing" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/testutil" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mariadb/armmariadb" + "github.com/stretchr/testify/suite" +) + +type PerformanceRecommendationsTestSuite struct { + suite.Suite + + ctx context.Context + cred azcore.TokenCredential + options *arm.ClientOptions + armEndpoint string + serverName string + adminPassword string + location string + resourceGroupName string + subscriptionId string +} + +func (testsuite *PerformanceRecommendationsTestSuite) SetupSuite() { + testutil.StartRecording(testsuite.T(), "sdk/resourcemanager/mariadb/armmariadb/testdata") + + testsuite.ctx = context.Background() + testsuite.cred, testsuite.options = testutil.GetCredAndClientOptions(testsuite.T()) + testsuite.armEndpoint = "https://management.azure.com" + testsuite.serverName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "serverna", 14, false) + testsuite.adminPassword = recording.GetEnvVariable("ADMIN_PASSWORD", "") + testsuite.location = recording.GetEnvVariable("LOCATION", "westus") + testsuite.resourceGroupName = recording.GetEnvVariable("RESOURCE_GROUP_NAME", "scenarioTestTempGroup") + testsuite.subscriptionId = recording.GetEnvVariable("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + resourceGroup, _, err := testutil.CreateResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.location) + testsuite.Require().NoError(err) + testsuite.resourceGroupName = *resourceGroup.Name + testsuite.Prepare() +} + +func (testsuite *PerformanceRecommendationsTestSuite) TearDownSuite() { + _, err := testutil.DeleteResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.resourceGroupName) + testsuite.Require().NoError(err) + testutil.StopRecording(testsuite.T()) +} + +func TestPerformanceRecommendationsTestSuite(t *testing.T) { + suite.Run(t, new(PerformanceRecommendationsTestSuite)) +} + +func (testsuite *PerformanceRecommendationsTestSuite) Prepare() { + var err error + // From step Servers_Create + fmt.Println("Call operation: Servers_Create") + serversClient, err := armmariadb.NewServersClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + serversClientCreateResponsePoller, err := serversClient.BeginCreate(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, armmariadb.ServerForCreate{ + Location: to.Ptr(testsuite.location), + Properties: &armmariadb.ServerPropertiesForDefaultCreate{ + CreateMode: to.Ptr(armmariadb.CreateModeDefault), + MinimalTLSVersion: to.Ptr(armmariadb.MinimalTLSVersionEnumTLS12), + SSLEnforcement: to.Ptr(armmariadb.SSLEnforcementEnumEnabled), + StorageProfile: &armmariadb.StorageProfile{ + BackupRetentionDays: to.Ptr[int32](7), + GeoRedundantBackup: to.Ptr(armmariadb.GeoRedundantBackupEnabled), + StorageMB: to.Ptr[int32](128000), + }, + AdministratorLogin: to.Ptr("cloudsa"), + AdministratorLoginPassword: to.Ptr(testsuite.adminPassword), + }, + SKU: &armmariadb.SKU{ + Name: to.Ptr("GP_Gen5_2"), + Capacity: to.Ptr[int32](2), + Family: to.Ptr("Gen5"), + Tier: to.Ptr(armmariadb.SKUTierGeneralPurpose), + }, + Tags: map[string]*string{ + "ElasticServer": to.Ptr("1"), + }, + }, nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, serversClientCreateResponsePoller) + testsuite.Require().NoError(err) +} + +// Microsoft.DBforMariaDB/servers/{serverName}/advisors/{advisorName} +func (testsuite *PerformanceRecommendationsTestSuite) TestAdvisors() { + var err error + // From step Advisors_ListByServer + fmt.Println("Call operation: Advisors_ListByServer") + advisorsClient, err := armmariadb.NewAdvisorsClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + advisorsClientNewListByServerPager := advisorsClient.NewListByServerPager(testsuite.resourceGroupName, testsuite.serverName, nil) + for advisorsClientNewListByServerPager.More() { + _, err := advisorsClientNewListByServerPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } + + // From step Advisors_Get + fmt.Println("Call operation: Advisors_Get") + _, err = advisorsClient.Get(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, "Index", nil) + testsuite.Require().NoError(err) +} + +// Microsoft.DBforMariaDB/servers/{serverName}/advisors/{advisorName}/createRecommendedActionSession +func (testsuite *PerformanceRecommendationsTestSuite) TestCreateRecommendedActionSession() { + var err error + // From step CreateRecommendedActionSession + fmt.Println("Call operation: CreateRecommendedActionSession") + managementClient, err := armmariadb.NewManagementClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + managementClientCreateRecommendedActionSessionResponsePoller, err := managementClient.BeginCreateRecommendedActionSession(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, "Index", "someDatabaseName", nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, managementClientCreateRecommendedActionSessionResponsePoller) + testsuite.Require().NoError(err) +} + +// Microsoft.DBforMariaDB/servers/{serverName}/advisors/{advisorName}/recommendedActions/{recommendedActionName} +func (testsuite *PerformanceRecommendationsTestSuite) TestRecommendedActions() { + var err error + // From step RecommendedActions_ListByServer + fmt.Println("Call operation: RecommendedActions_ListByServer") + recommendedActionsClient, err := armmariadb.NewRecommendedActionsClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + recommendedActionsClientNewListByServerPager := recommendedActionsClient.NewListByServerPager(testsuite.resourceGroupName, testsuite.serverName, "Index", &armmariadb.RecommendedActionsClientListByServerOptions{SessionID: nil}) + for recommendedActionsClientNewListByServerPager.More() { + _, err := recommendedActionsClientNewListByServerPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } +} diff --git a/sdk/resourcemanager/mariadb/armmariadb/privateendpointconnections_live_test.go b/sdk/resourcemanager/mariadb/armmariadb/privateendpointconnections_live_test.go new file mode 100644 index 000000000000..29975a479bc1 --- /dev/null +++ b/sdk/resourcemanager/mariadb/armmariadb/privateendpointconnections_live_test.go @@ -0,0 +1,283 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmariadb_test + +import ( + "context" + "fmt" + "testing" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/testutil" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mariadb/armmariadb" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" + "github.com/stretchr/testify/suite" +) + +type PrivateEndpointConnectionsTestSuite struct { + suite.Suite + + ctx context.Context + cred azcore.TokenCredential + options *arm.ClientOptions + armEndpoint string + mariadbId string + serverName string + adminPassword string + location string + resourceGroupName string + subscriptionId string +} + +func (testsuite *PrivateEndpointConnectionsTestSuite) SetupSuite() { + testutil.StartRecording(testsuite.T(), "sdk/resourcemanager/mariadb/armmariadb/testdata") + + testsuite.ctx = context.Background() + testsuite.cred, testsuite.options = testutil.GetCredAndClientOptions(testsuite.T()) + testsuite.armEndpoint = "https://management.azure.com" + testsuite.serverName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "serverna", 14, false) + testsuite.adminPassword = recording.GetEnvVariable("ADMIN_PASSWORD", "") + testsuite.location = recording.GetEnvVariable("LOCATION", "westus") + testsuite.resourceGroupName = recording.GetEnvVariable("RESOURCE_GROUP_NAME", "scenarioTestTempGroup") + testsuite.subscriptionId = recording.GetEnvVariable("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + resourceGroup, _, err := testutil.CreateResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.location) + testsuite.Require().NoError(err) + testsuite.resourceGroupName = *resourceGroup.Name + testsuite.Prepare() +} + +func (testsuite *PrivateEndpointConnectionsTestSuite) TearDownSuite() { + _, err := testutil.DeleteResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.resourceGroupName) + testsuite.Require().NoError(err) + testutil.StopRecording(testsuite.T()) +} + +func TestPrivateEndpointConnectionsTestSuite(t *testing.T) { + suite.Run(t, new(PrivateEndpointConnectionsTestSuite)) +} + +func (testsuite *PrivateEndpointConnectionsTestSuite) Prepare() { + var err error + // From step Servers_Create + fmt.Println("Call operation: Servers_Create") + serversClient, err := armmariadb.NewServersClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + serversClientCreateResponsePoller, err := serversClient.BeginCreate(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, armmariadb.ServerForCreate{ + Location: to.Ptr(testsuite.location), + Properties: &armmariadb.ServerPropertiesForDefaultCreate{ + CreateMode: to.Ptr(armmariadb.CreateModeDefault), + MinimalTLSVersion: to.Ptr(armmariadb.MinimalTLSVersionEnumTLS12), + SSLEnforcement: to.Ptr(armmariadb.SSLEnforcementEnumEnabled), + StorageProfile: &armmariadb.StorageProfile{ + BackupRetentionDays: to.Ptr[int32](7), + GeoRedundantBackup: to.Ptr(armmariadb.GeoRedundantBackupEnabled), + StorageMB: to.Ptr[int32](128000), + }, + AdministratorLogin: to.Ptr("cloudsa"), + AdministratorLoginPassword: to.Ptr(testsuite.adminPassword), + }, + SKU: &armmariadb.SKU{ + Name: to.Ptr("GP_Gen5_2"), + Capacity: to.Ptr[int32](2), + Family: to.Ptr("Gen5"), + Tier: to.Ptr(armmariadb.SKUTierGeneralPurpose), + }, + Tags: map[string]*string{ + "ElasticServer": to.Ptr("1"), + }, + }, nil) + testsuite.Require().NoError(err) + var serversClientCreateResponse *armmariadb.ServersClientCreateResponse + serversClientCreateResponse, err = testutil.PollForTest(testsuite.ctx, serversClientCreateResponsePoller) + testsuite.Require().NoError(err) + testsuite.mariadbId = *serversClientCreateResponse.ID + + // From step Create_PrivateEndpoint + template := map[string]any{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": map[string]any{ + "location": map[string]any{ + "type": "string", + "defaultValue": testsuite.location, + }, + "mariadbId": map[string]any{ + "type": "string", + "defaultValue": testsuite.mariadbId, + }, + "networkInterfaceName": map[string]any{ + "type": "string", + "defaultValue": "epmariadb-nic", + }, + "privateEndpointName": map[string]any{ + "type": "string", + "defaultValue": "epmariadb", + }, + "virtualNetworksName": map[string]any{ + "type": "string", + "defaultValue": "epmariadbvnet", + }, + }, + "resources": []any{ + map[string]any{ + "name": "[parameters('virtualNetworksName')]", + "type": "Microsoft.Network/virtualNetworks", + "apiVersion": "2020-11-01", + "location": "[parameters('location')]", + "properties": map[string]any{ + "addressSpace": map[string]any{ + "addressPrefixes": []any{ + "10.0.0.0/16", + }, + }, + "enableDdosProtection": false, + "subnets": []any{ + map[string]any{ + "name": "default", + "properties": map[string]any{ + "addressPrefix": "10.0.0.0/24", + "delegations": []any{}, + "privateEndpointNetworkPolicies": "Disabled", + "privateLinkServiceNetworkPolicies": "Enabled", + }, + }, + }, + "virtualNetworkPeerings": []any{}, + }, + }, + map[string]any{ + "name": "[parameters('networkInterfaceName')]", + "type": "Microsoft.Network/networkInterfaces", + "apiVersion": "2020-11-01", + "dependsOn": []any{ + "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworksName'), 'default')]", + }, + "location": "[parameters('location')]", + "properties": map[string]any{ + "dnsSettings": map[string]any{ + "dnsServers": []any{}, + }, + "enableIPForwarding": false, + "ipConfigurations": []any{ + map[string]any{ + "name": "privateEndpointIpConfig", + "properties": map[string]any{ + "primary": true, + "privateIPAddress": "10.0.0.4", + "privateIPAddressVersion": "IPv4", + "privateIPAllocationMethod": "Dynamic", + "subnet": map[string]any{ + "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworksName'), 'default')]", + }, + }, + }, + }, + }, + }, + map[string]any{ + "name": "[parameters('privateEndpointName')]", + "type": "Microsoft.Network/privateEndpoints", + "apiVersion": "2020-11-01", + "dependsOn": []any{ + "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworksName'), 'default')]", + }, + "location": "[parameters('location')]", + "properties": map[string]any{ + "customDnsConfigs": []any{}, + "manualPrivateLinkServiceConnections": []any{}, + "privateLinkServiceConnections": []any{ + map[string]any{ + "name": "[parameters('privateEndpointName')]", + "properties": map[string]any{ + "groupIds": []any{ + "mariadbServer", + }, + "privateLinkServiceConnectionState": map[string]any{ + "description": "Auto-Approved", + "actionsRequired": "None", + "status": "Approved", + }, + "privateLinkServiceId": "[parameters('mariadbId')]", + }, + }, + }, + "subnet": map[string]any{ + "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('virtualNetworksName'), 'default')]", + }, + }, + }, + map[string]any{ + "name": "[concat(parameters('virtualNetworksName'), '/default')]", + "type": "Microsoft.Network/virtualNetworks/subnets", + "apiVersion": "2020-11-01", + "dependsOn": []any{ + "[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworksName'))]", + }, + "properties": map[string]any{ + "addressPrefix": "10.0.0.0/24", + "delegations": []any{}, + "privateEndpointNetworkPolicies": "Disabled", + "privateLinkServiceNetworkPolicies": "Enabled", + }, + }, + }, + "variables": map[string]any{}, + } + deployment := armresources.Deployment{ + Properties: &armresources.DeploymentProperties{ + Template: template, + Mode: to.Ptr(armresources.DeploymentModeIncremental), + }, + } + _, err = testutil.CreateDeployment(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.resourceGroupName, "Create_PrivateEndpoint", &deployment) + testsuite.Require().NoError(err) +} + +// Microsoft.DBforMariaDB/servers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName} +func (testsuite *PrivateEndpointConnectionsTestSuite) TestPrivateEndpointConnections() { + var err error + var privateEndpointConnectionName string + // From step PrivateEndpointConnections_ListByServer + fmt.Println("Call operation: PrivateEndpointConnections_ListByServer") + privateEndpointConnectionsClient, err := armmariadb.NewPrivateEndpointConnectionsClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + privateEndpointConnectionsClientNewListByServerPager := privateEndpointConnectionsClient.NewListByServerPager(testsuite.resourceGroupName, testsuite.serverName, nil) + for privateEndpointConnectionsClientNewListByServerPager.More() { + result, err := privateEndpointConnectionsClientNewListByServerPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + privateEndpointConnectionName = *result.Value[0].Name + break + } + + // From step PrivateEndpointConnections_Get + fmt.Println("Call operation: PrivateEndpointConnections_Get") + _, err = privateEndpointConnectionsClient.Get(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, privateEndpointConnectionName, nil) + testsuite.Require().NoError(err) + + // From step PrivateLinkResources_ListByServer + fmt.Println("Call operation: PrivateLinkResources_ListByServer") + privateLinkResourcesClient, err := armmariadb.NewPrivateLinkResourcesClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + privateLinkResourcesClientNewListByServerPager := privateLinkResourcesClient.NewListByServerPager(testsuite.resourceGroupName, testsuite.serverName, nil) + for privateLinkResourcesClientNewListByServerPager.More() { + _, err := privateLinkResourcesClientNewListByServerPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } + + // From step PrivateEndpointConnections_Delete + fmt.Println("Call operation: PrivateEndpointConnections_Delete") + privateEndpointConnectionsClientDeleteResponsePoller, err := privateEndpointConnectionsClient.BeginDelete(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, privateEndpointConnectionName, nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, privateEndpointConnectionsClientDeleteResponsePoller) + testsuite.Require().NoError(err) +} diff --git a/sdk/resourcemanager/mariadb/armmariadb/serversecurityalertpolicies_live_test.go b/sdk/resourcemanager/mariadb/armmariadb/serversecurityalertpolicies_live_test.go new file mode 100644 index 000000000000..638533ae5147 --- /dev/null +++ b/sdk/resourcemanager/mariadb/armmariadb/serversecurityalertpolicies_live_test.go @@ -0,0 +1,130 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armmariadb_test + +import ( + "context" + "fmt" + "testing" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/testutil" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/mariadb/armmariadb" + "github.com/stretchr/testify/suite" +) + +type ServerSecurityAlertPoliciesTestSuite struct { + suite.Suite + + ctx context.Context + cred azcore.TokenCredential + options *arm.ClientOptions + armEndpoint string + serverName string + adminPassword string + location string + resourceGroupName string + subscriptionId string +} + +func (testsuite *ServerSecurityAlertPoliciesTestSuite) SetupSuite() { + testutil.StartRecording(testsuite.T(), "sdk/resourcemanager/mariadb/armmariadb/testdata") + + testsuite.ctx = context.Background() + testsuite.cred, testsuite.options = testutil.GetCredAndClientOptions(testsuite.T()) + testsuite.armEndpoint = "https://management.azure.com" + testsuite.serverName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "serverna", 14, false) + testsuite.adminPassword = recording.GetEnvVariable("ADMIN_PASSWORD", "") + testsuite.location = recording.GetEnvVariable("LOCATION", "westus") + testsuite.resourceGroupName = recording.GetEnvVariable("RESOURCE_GROUP_NAME", "scenarioTestTempGroup") + testsuite.subscriptionId = recording.GetEnvVariable("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + resourceGroup, _, err := testutil.CreateResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.location) + testsuite.Require().NoError(err) + testsuite.resourceGroupName = *resourceGroup.Name + testsuite.Prepare() +} + +func (testsuite *ServerSecurityAlertPoliciesTestSuite) TearDownSuite() { + _, err := testutil.DeleteResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.resourceGroupName) + testsuite.Require().NoError(err) + testutil.StopRecording(testsuite.T()) +} + +func TestServerSecurityAlertPoliciesTestSuite(t *testing.T) { + suite.Run(t, new(ServerSecurityAlertPoliciesTestSuite)) +} + +func (testsuite *ServerSecurityAlertPoliciesTestSuite) Prepare() { + var err error + // From step Servers_Create + fmt.Println("Call operation: Servers_Create") + serversClient, err := armmariadb.NewServersClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + serversClientCreateResponsePoller, err := serversClient.BeginCreate(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, armmariadb.ServerForCreate{ + Location: to.Ptr(testsuite.location), + Properties: &armmariadb.ServerPropertiesForDefaultCreate{ + CreateMode: to.Ptr(armmariadb.CreateModeDefault), + MinimalTLSVersion: to.Ptr(armmariadb.MinimalTLSVersionEnumTLS12), + SSLEnforcement: to.Ptr(armmariadb.SSLEnforcementEnumEnabled), + StorageProfile: &armmariadb.StorageProfile{ + BackupRetentionDays: to.Ptr[int32](7), + GeoRedundantBackup: to.Ptr(armmariadb.GeoRedundantBackupEnabled), + StorageMB: to.Ptr[int32](128000), + }, + AdministratorLogin: to.Ptr("cloudsa"), + AdministratorLoginPassword: to.Ptr(testsuite.adminPassword), + }, + SKU: &armmariadb.SKU{ + Name: to.Ptr("GP_Gen5_2"), + Capacity: to.Ptr[int32](2), + Family: to.Ptr("Gen5"), + Tier: to.Ptr(armmariadb.SKUTierGeneralPurpose), + }, + Tags: map[string]*string{ + "ElasticServer": to.Ptr("1"), + }, + }, nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, serversClientCreateResponsePoller) + testsuite.Require().NoError(err) +} + +// Microsoft.DBforMariaDB/servers/{serverName}/securityAlertPolicies/{securityAlertPolicyName} +func (testsuite *ServerSecurityAlertPoliciesTestSuite) TestServerSecurityAlertPolicies() { + var err error + // From step ServerSecurityAlertPolicies_CreateOrUpdate + fmt.Println("Call operation: ServerSecurityAlertPolicies_CreateOrUpdate") + serverSecurityAlertPoliciesClient, err := armmariadb.NewServerSecurityAlertPoliciesClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) + testsuite.Require().NoError(err) + serverSecurityAlertPoliciesClientCreateOrUpdateResponsePoller, err := serverSecurityAlertPoliciesClient.BeginCreateOrUpdate(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, armmariadb.SecurityAlertPolicyNameDefault, armmariadb.ServerSecurityAlertPolicy{ + Properties: &armmariadb.SecurityAlertPolicyProperties{ + State: to.Ptr(armmariadb.ServerSecurityAlertPolicyStateEnabled), + }, + }, nil) + testsuite.Require().NoError(err) + _, err = testutil.PollForTest(testsuite.ctx, serverSecurityAlertPoliciesClientCreateOrUpdateResponsePoller) + testsuite.Require().NoError(err) + + // From step ServerSecurityAlertPolicies_ListByServer + fmt.Println("Call operation: ServerSecurityAlertPolicies_ListByServer") + serverSecurityAlertPoliciesClientNewListByServerPager := serverSecurityAlertPoliciesClient.NewListByServerPager(testsuite.resourceGroupName, testsuite.serverName, nil) + for serverSecurityAlertPoliciesClientNewListByServerPager.More() { + _, err := serverSecurityAlertPoliciesClientNewListByServerPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } + + // From step ServerSecurityAlertPolicies_Get + fmt.Println("Call operation: ServerSecurityAlertPolicies_Get") + _, err = serverSecurityAlertPoliciesClient.Get(testsuite.ctx, testsuite.resourceGroupName, testsuite.serverName, armmariadb.SecurityAlertPolicyNameDefault, nil) + testsuite.Require().NoError(err) +}