From f33dba9ea5b0627a65737295eea6a692bc079b8b Mon Sep 17 00:00:00 2001 From: "RuiJun Hu (MSFT)" <47708215+cxznmhdcxz@users.noreply.github.com> Date: Fri, 5 Jun 2020 08:55:55 +0000 Subject: [PATCH] passes web & insights tests (#280) * Update azure-pipelines.yml for Azure Pipelines * Update live_test.yml a test to trigger pipeline ci * Update live_test.yml * fix Example_createTemplateDeployment * include master in my own testing pipeline * fix Example_createTemplateDeployment * Update live_test.yml * Update live_test.yml * Update live_test.yml * passes insights and web tests * use proper eventhub name * Update yml, pipeline only trigger by master branch * update yml, select go version for pipeline --- .azure-pipelines/lint_and_build.yml | 6 +++++- .azure-pipelines/steps/live_test.yml | 3 ++- eventhubs/eventhubs_test.go | 8 ++++---- insights/insights_test.go | 4 ++-- resources/deployment_test.go | 9 ++++----- web/web.go | 13 ++++--------- web/web_test.go | 8 +++----- 7 files changed, 24 insertions(+), 27 deletions(-) diff --git a/.azure-pipelines/lint_and_build.yml b/.azure-pipelines/lint_and_build.yml index a0924811b..7f832dfb5 100644 --- a/.azure-pipelines/lint_and_build.yml +++ b/.azure-pipelines/lint_and_build.yml @@ -4,6 +4,10 @@ jobs: vmImage: 'Ubuntu 18.04' steps: + - task: GoTool@0 + inputs: + version: '1.13' + displayName: "Select Go Version" - template: steps/init_workspace.yml - template: steps/linter_check.yml - - template: steps/build_test.yml \ No newline at end of file + - template: steps/build_test.yml diff --git a/.azure-pipelines/steps/live_test.yml b/.azure-pipelines/steps/live_test.yml index 0ac21c2ea..cab4477ae 100644 --- a/.azure-pipelines/steps/live_test.yml +++ b/.azure-pipelines/steps/live_test.yml @@ -11,6 +11,8 @@ steps: go test -count=1 -v -timeout 12h ./network/ go test -count=1 -v -timeout 12h ./sql/ go test -count=1 -v -timeout 12h ./resources/ + go test -count=1 -v -timeout 12h ./web/ + go test -count=1 -v -timeout 12h ./insights/ displayName: 'Live Test' env: @@ -24,4 +26,3 @@ steps: AZURE_USE_DEVICEFLOW: $(AZURE_USE_DEVICEFLOW) AZURE_STORAGE_ACCOUNT_NAME: $(AZURE_STORAGE_ACCOUNT_NAME) AZURE_STORAGE_ACCOUNT_GROUP_NAME: $(AZURE_STORAGE_ACCOUNT_GROUP_NAME) - \ No newline at end of file diff --git a/eventhubs/eventhubs_test.go b/eventhubs/eventhubs_test.go index 926de8607..0dc09496c 100644 --- a/eventhubs/eventhubs_test.go +++ b/eventhubs/eventhubs_test.go @@ -19,12 +19,12 @@ import ( ) const ( - nsName = "ehtest04ns" - hubName = "ehtest04hub" + nsName = "goehtestns" + hubName = "goehtesthub" // for storage.LeaserCheckpointer - storageAccountName = "ehtest0001storage" - storageContainerName = "eventhubs0001leasercheckpointer" + storageAccountName = "goehteststorage" + storageContainerName = "goeventhubsleasercheckpointer" ) // TestMain sets up the environment and initiates tests. diff --git a/insights/insights_test.go b/insights/insights_test.go index 7497f1518..3f5b04cba 100644 --- a/insights/insights_test.go +++ b/insights/insights_test.go @@ -43,7 +43,7 @@ func TestMain(m *testing.M) { // ExampleGetMetricsForWebsite creates a website then uses the insights package // to retrieve the queryable metric names and values. -func Example_getMetricsForWebsite() { +func TestGetMetricsForWebsite(t *testing.T) { var groupName = config.GenerateGroupName("GetMetricsForWebsite") config.SetGroupName(groupName) ctx, cancel := context.WithTimeout(context.Background(), time.Minute*10) @@ -56,7 +56,7 @@ func Example_getMetricsForWebsite() { util.PrintAndLog("created resource group") defer resources.Cleanup(ctx) - webSite, err := web.CreateContainerSite(ctx, siteName, "appsvc/sample-hello-world:latest") + webSite, err := web.CreateWebApp(ctx, siteName) if err != nil { util.LogAndPanic(err) } diff --git a/resources/deployment_test.go b/resources/deployment_test.go index cda882d58..a0c86028a 100644 --- a/resources/deployment_test.go +++ b/resources/deployment_test.go @@ -7,8 +7,8 @@ package resources import ( "context" - "go/build" "log" + "os" "path/filepath" "time" @@ -28,10 +28,9 @@ func Example_createTemplateDeployment() { util.LogAndPanic(err) } - gopath := build.Default.GOPATH - repo := filepath.Join("github.com", "Azure-Samples", "azure-sdk-for-go-samples") - templateFile := filepath.Join(gopath, "src", repo, "resources", "testdata", "template.json") - parametersFile := filepath.Join(gopath, "src", repo, "resources", "testdata", "parameters.json") + wd, _ := os.Getwd() + templateFile := filepath.Join(wd, "testdata", "template.json") + parametersFile := filepath.Join(wd, "testdata", "parameters.json") deployName := "VMdeploy" template, err := util.ReadJSON(templateFile) diff --git a/web/web.go b/web/web.go index 49e2a3a9b..bc248294d 100644 --- a/web/web.go +++ b/web/web.go @@ -2,7 +2,6 @@ package web import ( "context" - "fmt" "github.com/Azure-Samples/azure-sdk-for-go-samples/internal/config" "github.com/Azure-Samples/azure-sdk-for-go-samples/internal/iam" @@ -20,8 +19,8 @@ func getWebAppsClient() (client web.AppsClient, err error) { return } -// CreateContainerSite provisions all infrastructure needed to run an Azure Web App for Containers. -func CreateContainerSite(ctx context.Context, name, image string) (webSite web.Site, err error) { +// CreateWebApp creates a blank web app with specified name +func CreateWebApp(ctx context.Context, name string) (webSite web.Site, err error) { client, err := getWebAppsClient() if err != nil { return @@ -31,12 +30,8 @@ func CreateContainerSite(ctx context.Context, name, image string) (webSite web.S config.GroupName(), name, web.Site{ - Location: to.StringPtr(config.Location()), - SiteProperties: &web.SiteProperties{ - SiteConfig: &web.SiteConfig{ - LinuxFxVersion: to.StringPtr(fmt.Sprintf("DOCKER|%s", image)), - }, - }, + Location: to.StringPtr(config.Location()), + SiteProperties: &web.SiteProperties{}, }) if err != nil { return diff --git a/web/web_test.go b/web/web_test.go index 629ee94bd..5aae0ed8c 100644 --- a/web/web_test.go +++ b/web/web_test.go @@ -38,7 +38,7 @@ func TestMain(m *testing.M) { os.Exit(code) } -func Example_deployAppForContainer() { +func TestCreateApp(t *testing.T) { var groupName = config.GenerateGroupName("WebAppForContainers") config.SetGroupName(groupName) ctx, cancel := context.WithTimeout(context.Background(), time.Minute*10) @@ -51,7 +51,7 @@ func Example_deployAppForContainer() { } defer resources.Cleanup(ctx) - _, err = CreateContainerSite(ctx, siteName, "appsvc/sample-hello-world:latest") + _, err = CreateWebApp(ctx, siteName) if err != nil { fmt.Println("failed to create: ", err) @@ -63,7 +63,5 @@ func Example_deployAppForContainer() { fmt.Println("failed to get app configuration: ", err) return } - fmt.Println(*configResource.LinuxFxVersion) - - // Output: DOCKER|appsvc/sample-hello-world:latest + fmt.Println(*configResource.Name) }