Skip to content

Commit

Permalink
passes web & insights tests (#280)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
cxznmhdcxz authored Jun 5, 2020
1 parent 96378ae commit f33dba9
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 27 deletions.
6 changes: 5 additions & 1 deletion .azure-pipelines/lint_and_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- template: steps/build_test.yml
3 changes: 2 additions & 1 deletion .azure-pipelines/steps/live_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
8 changes: 4 additions & 4 deletions eventhubs/eventhubs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions insights/insights_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down
9 changes: 4 additions & 5 deletions resources/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ package resources

import (
"context"
"go/build"
"log"
"os"
"path/filepath"
"time"

Expand All @@ -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)
Expand Down
13 changes: 4 additions & 9 deletions web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 3 additions & 5 deletions web/web_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
}

0 comments on commit f33dba9

Please sign in to comment.