Skip to content

Commit

Permalink
neonpostgres add live test (#23809)
Browse files Browse the repository at this point in the history
* add live test
  • Loading branch information
jliusan authored Dec 3, 2024
1 parent b43463f commit 590fc96
Show file tree
Hide file tree
Showing 6 changed files with 235 additions and 2 deletions.
6 changes: 6 additions & 0 deletions sdk/resourcemanager/neonpostgres/armneonpostgres/assets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "go",
"TagPrefix": "go/resourcemanager/neonpostgres/armneonpostgres",
"Tag": "go/resourcemanager/neonpostgres/armneonpostgres_9ffad5f62a"
}
1 change: 1 addition & 0 deletions sdk/resourcemanager/neonpostgres/armneonpostgres/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ extends:
parameters:
IncludeRelease: true
ServiceDirectory: 'resourcemanager/neonpostgres/armneonpostgres'
UsePipelineProxy: false
11 changes: 10 additions & 1 deletion sdk/resourcemanager/neonpostgres/armneonpostgres/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,24 @@ go 1.18
require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0
)

require (
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

require (
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/stretchr/testify v1.10.0
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sys v0.25.0 // indirect
Expand Down
17 changes: 16 additions & 1 deletion sdk/resourcemanager/neonpostgres/armneonpostgres/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,31 @@ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY=
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 h1:PTFGRSlMKCQelWwxUyYVEUqseBJVemLyqWJjvMyt0do=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0 h1:2qsIIvxVT+uE6yrNldntJKlLRgxGbZ85kgtz5SNBhMw=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3 v3.1.0/go.mod h1:AW8VEadnhw9xox+VaVd9sP7NjzOAnaZBLRH6Tq3cJ38=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups v1.0.0 h1:pPvTJ1dY0sA35JOeFq6TsY2xj6Z85Yo23Pj4wCCvu4o=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0 h1:Dd+RhdJn0OTtVGaeDLZpcumkIVCtA/3/Fo42+eoYvVM=
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.2.0/go.mod h1:5kakwfW5CjC9KK+Q4wjXAg+ShuIm2mBMua0ZFj2C8PE=
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU=
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI=
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/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
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/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
Expand All @@ -26,4 +38,7 @@ golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
//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.

package armneonpostgres_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/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/internal/recording"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/neonpostgres/armneonpostgres"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources"
"github.com/stretchr/testify/suite"
)

const (
ResourceLocation = "eastus2"
)

type NeonpostgresTestSuite struct {
suite.Suite
ctx context.Context
cred azcore.TokenCredential
options *arm.ClientOptions
armEndpoint string
location string
resourceGroupName string
subscriptionId string
organizationName string
}

func (testsuite *NeonpostgresTestSuite) SetupSuite() {
testutil.StartRecording(testsuite.T(), pathToPackage)
testsuite.ctx = context.Background()
testsuite.armEndpoint = "https://management.azure.com"
testsuite.cred, testsuite.options = testutil.GetCredAndClientOptions(testsuite.T())
testsuite.location = recording.GetEnvVariable("LOCATION", ResourceLocation)
testsuite.resourceGroupName = recording.GetEnvVariable("RESOURCE_GROUP_NAME", "scenarioTestTempGroup")
testsuite.subscriptionId = recording.GetEnvVariable("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000")
testsuite.organizationName = "testogname"
resourceGroup, _, err := testutil.CreateResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.location)
testsuite.Require().NoError(err)
testsuite.resourceGroupName = *resourceGroup.Name
fmt.Println("testsuite.resourceGroupName:", testsuite.resourceGroupName)
testsuite.Prepare()
}

func (testsuite *NeonpostgresTestSuite) 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 TestNeonpostgresTestSuite(t *testing.T) {
suite.Run(t, new(NeonpostgresTestSuite))
}

func (testsuite *NeonpostgresTestSuite) TestOperationsList() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
testsuite.Require().NoError(err)
ctx := context.Background()
clientFactory, err := armneonpostgres.NewClientFactory(testsuite.subscriptionId, cred, testsuite.options)
testsuite.Require().NoError(err)
pager := clientFactory.NewOperationsClient().NewListPager(nil)
for pager.More() {
_, err := pager.NextPage(ctx)
testsuite.Require().NoError(err)
}
}

func (testsuite *NeonpostgresTestSuite) TestOrganizationsCreateOrUpdate() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
testsuite.Require().NoError(err)
clientFactory, err := armneonpostgres.NewClientFactory(testsuite.subscriptionId, cred, testsuite.options)
testsuite.Require().NoError(err)
_, err = clientFactory.NewOrganizationsClient().BeginCreateOrUpdate(testsuite.ctx, testsuite.resourceGroupName, testsuite.organizationName, armneonpostgres.OrganizationResource{
Properties: &armneonpostgres.OrganizationProperties{
MarketplaceDetails: &armneonpostgres.MarketplaceDetails{
SubscriptionID: to.Ptr(testsuite.subscriptionId),
SubscriptionStatus: to.Ptr(armneonpostgres.MarketplaceSubscriptionStatusPendingFulfillmentStart),
OfferDetails: &armneonpostgres.OfferDetails{
PublisherID: to.Ptr("hporaxnopmolttlnkbarw"),
OfferID: to.Ptr("bunyeeupoedueofwrzej"),
PlanID: to.Ptr("nlbfiwtslenfwek"),
PlanName: to.Ptr("ljbmgpkfqklaufacbpml"),
TermUnit: to.Ptr("qbcq"),
TermID: to.Ptr("aedlchikwqckuploswthvshe"),
},
},
UserDetails: &armneonpostgres.UserDetails{
FirstName: to.Ptr("buwwe"),
LastName: to.Ptr("escynjpynkoox"),
EmailAddress: to.Ptr("3i_%@w8-y.H-p.tvj.dG"),
Upn: to.Ptr("fwedjamgwwrotcjaucuzdwycfjdqn"),
PhoneNumber: to.Ptr("dlrqoowumy"),
},
CompanyDetails: &armneonpostgres.CompanyDetails{
CompanyName: to.Ptr("uxn"),
Country: to.Ptr("lpajqzptqchuko"),
OfficeAddress: to.Ptr("chpkrlpmfslmawgunjxdllzcrctykq"),
BusinessPhone: to.Ptr("hbeb"),
Domain: to.Ptr("krjldeakhwiepvs"),
NumberOfEmployees: to.Ptr[int64](23),
},
PartnerOrganizationProperties: &armneonpostgres.PartnerOrganizationProperties{
OrganizationID: to.Ptr("nrhvoqzulowcunhmvwfgjcaibvwcl"),
OrganizationName: to.Ptr("2__.-"),
SingleSignOnProperties: &armneonpostgres.SingleSignOnProperties{
SingleSignOnState: to.Ptr(armneonpostgres.SingleSignOnStatesInitial),
EnterpriseAppID: to.Ptr("fpibacregjfncfdsojs"),
SingleSignOnURL: to.Ptr("tmojh"),
AADDomains: []*string{
to.Ptr("kndszgrwzbvvlssvkej"),
},
},
},
},
Tags: map[string]*string{
"key2099": to.Ptr("omjjymaqtrqzksxszhzgyl"),
},
Location: to.Ptr(testsuite.location),
Name: to.Ptr(testsuite.organizationName),
}, nil)
testsuite.Require().NoError(err)

}

func (testsuite *NeonpostgresTestSuite) CleanUp() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
testsuite.Require().NoError(err)
clientFactory, err := armneonpostgres.NewClientFactory(testsuite.subscriptionId, cred, testsuite.options)
testsuite.Require().NoError(err)
poller, err := clientFactory.NewOrganizationsClient().BeginDelete(testsuite.ctx, testsuite.resourceGroupName, testsuite.organizationName, nil)
testsuite.Require().NoError(err)
testsuite.Require().NoError(err)
_, err = testutil.PollForTest(testsuite.ctx, poller)
testsuite.Require().NoError(err)
}

func (testsuite *NeonpostgresTestSuite) Prepare() {
// get default credential
cred, err := azidentity.NewDefaultAzureCredential(nil)
testsuite.Require().NoError(err)
// new client factory

fmt.Println("subscriptionId", testsuite.subscriptionId, "groupName", testsuite.resourceGroupName, "location", testsuite.location)
clientFactory, err := armresources.NewClientFactory(testsuite.subscriptionId, cred, testsuite.options)
testsuite.Require().NoError(err)
client := clientFactory.NewResourceGroupsClient()

testsuite.Require().NoError(err)
// check whether create new group successfully
res, err := client.CheckExistence(testsuite.ctx, testsuite.resourceGroupName, nil)
testsuite.Require().NoError(err)
if !res.Success {
_, err = client.CreateOrUpdate(testsuite.ctx, testsuite.resourceGroupName, armresources.ResourceGroup{
Location: to.Ptr(testsuite.location),
}, nil)
testsuite.Require().NoError(err)
}

fmt.Println("create new resource group ", testsuite.resourceGroupName, " of ", testsuite.subscriptionId, "successfully")
}
29 changes: 29 additions & 0 deletions sdk/resourcemanager/neonpostgres/armneonpostgres/utils_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//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.

package armneonpostgres_test

import (
"os"
"testing"

"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil"
)

const (
pathToPackage = "sdk/resourcemanager/neonpostgres/armneonpostgres/testdata"
)

func TestMain(m *testing.M) {
code := run(m)
os.Exit(code)
}

func run(m *testing.M) int {
f := testutil.StartProxy(pathToPackage)
defer f()
return m.Run()
}

0 comments on commit 590fc96

Please sign in to comment.