Skip to content

Commit f33dba9

Browse files
authored
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
1 parent 96378ae commit f33dba9

File tree

7 files changed

+24
-27
lines changed

7 files changed

+24
-27
lines changed

.azure-pipelines/lint_and_build.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ jobs:
44
vmImage: 'Ubuntu 18.04'
55

66
steps:
7+
- task: GoTool@0
8+
inputs:
9+
version: '1.13'
10+
displayName: "Select Go Version"
711
- template: steps/init_workspace.yml
812
- template: steps/linter_check.yml
9-
- template: steps/build_test.yml
13+
- template: steps/build_test.yml

.azure-pipelines/steps/live_test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ steps:
1111
go test -count=1 -v -timeout 12h ./network/
1212
go test -count=1 -v -timeout 12h ./sql/
1313
go test -count=1 -v -timeout 12h ./resources/
14+
go test -count=1 -v -timeout 12h ./web/
15+
go test -count=1 -v -timeout 12h ./insights/
1416
1517
displayName: 'Live Test'
1618
env:
@@ -24,4 +26,3 @@ steps:
2426
AZURE_USE_DEVICEFLOW: $(AZURE_USE_DEVICEFLOW)
2527
AZURE_STORAGE_ACCOUNT_NAME: $(AZURE_STORAGE_ACCOUNT_NAME)
2628
AZURE_STORAGE_ACCOUNT_GROUP_NAME: $(AZURE_STORAGE_ACCOUNT_GROUP_NAME)
27-

eventhubs/eventhubs_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ import (
1919
)
2020

2121
const (
22-
nsName = "ehtest04ns"
23-
hubName = "ehtest04hub"
22+
nsName = "goehtestns"
23+
hubName = "goehtesthub"
2424

2525
// for storage.LeaserCheckpointer
26-
storageAccountName = "ehtest0001storage"
27-
storageContainerName = "eventhubs0001leasercheckpointer"
26+
storageAccountName = "goehteststorage"
27+
storageContainerName = "goeventhubsleasercheckpointer"
2828
)
2929

3030
// TestMain sets up the environment and initiates tests.

insights/insights_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestMain(m *testing.M) {
4343

4444
// ExampleGetMetricsForWebsite creates a website then uses the insights package
4545
// to retrieve the queryable metric names and values.
46-
func Example_getMetricsForWebsite() {
46+
func TestGetMetricsForWebsite(t *testing.T) {
4747
var groupName = config.GenerateGroupName("GetMetricsForWebsite")
4848
config.SetGroupName(groupName)
4949
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*10)
@@ -56,7 +56,7 @@ func Example_getMetricsForWebsite() {
5656
util.PrintAndLog("created resource group")
5757
defer resources.Cleanup(ctx)
5858

59-
webSite, err := web.CreateContainerSite(ctx, siteName, "appsvc/sample-hello-world:latest")
59+
webSite, err := web.CreateWebApp(ctx, siteName)
6060
if err != nil {
6161
util.LogAndPanic(err)
6262
}

resources/deployment_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ package resources
77

88
import (
99
"context"
10-
"go/build"
1110
"log"
11+
"os"
1212
"path/filepath"
1313
"time"
1414

@@ -28,10 +28,9 @@ func Example_createTemplateDeployment() {
2828
util.LogAndPanic(err)
2929
}
3030

31-
gopath := build.Default.GOPATH
32-
repo := filepath.Join("github.com", "Azure-Samples", "azure-sdk-for-go-samples")
33-
templateFile := filepath.Join(gopath, "src", repo, "resources", "testdata", "template.json")
34-
parametersFile := filepath.Join(gopath, "src", repo, "resources", "testdata", "parameters.json")
31+
wd, _ := os.Getwd()
32+
templateFile := filepath.Join(wd, "testdata", "template.json")
33+
parametersFile := filepath.Join(wd, "testdata", "parameters.json")
3534
deployName := "VMdeploy"
3635

3736
template, err := util.ReadJSON(templateFile)

web/web.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package web
22

33
import (
44
"context"
5-
"fmt"
65

76
"github.com/Azure-Samples/azure-sdk-for-go-samples/internal/config"
87
"github.com/Azure-Samples/azure-sdk-for-go-samples/internal/iam"
@@ -20,8 +19,8 @@ func getWebAppsClient() (client web.AppsClient, err error) {
2019
return
2120
}
2221

23-
// CreateContainerSite provisions all infrastructure needed to run an Azure Web App for Containers.
24-
func CreateContainerSite(ctx context.Context, name, image string) (webSite web.Site, err error) {
22+
// CreateWebApp creates a blank web app with specified name
23+
func CreateWebApp(ctx context.Context, name string) (webSite web.Site, err error) {
2524
client, err := getWebAppsClient()
2625
if err != nil {
2726
return
@@ -31,12 +30,8 @@ func CreateContainerSite(ctx context.Context, name, image string) (webSite web.S
3130
config.GroupName(),
3231
name,
3332
web.Site{
34-
Location: to.StringPtr(config.Location()),
35-
SiteProperties: &web.SiteProperties{
36-
SiteConfig: &web.SiteConfig{
37-
LinuxFxVersion: to.StringPtr(fmt.Sprintf("DOCKER|%s", image)),
38-
},
39-
},
33+
Location: to.StringPtr(config.Location()),
34+
SiteProperties: &web.SiteProperties{},
4035
})
4136
if err != nil {
4237
return

web/web_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestMain(m *testing.M) {
3838
os.Exit(code)
3939
}
4040

41-
func Example_deployAppForContainer() {
41+
func TestCreateApp(t *testing.T) {
4242
var groupName = config.GenerateGroupName("WebAppForContainers")
4343
config.SetGroupName(groupName)
4444
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*10)
@@ -51,7 +51,7 @@ func Example_deployAppForContainer() {
5151
}
5252
defer resources.Cleanup(ctx)
5353

54-
_, err = CreateContainerSite(ctx, siteName, "appsvc/sample-hello-world:latest")
54+
_, err = CreateWebApp(ctx, siteName)
5555

5656
if err != nil {
5757
fmt.Println("failed to create: ", err)
@@ -63,7 +63,5 @@ func Example_deployAppForContainer() {
6363
fmt.Println("failed to get app configuration: ", err)
6464
return
6565
}
66-
fmt.Println(*configResource.LinuxFxVersion)
67-
68-
// Output: DOCKER|appsvc/sample-hello-world:latest
66+
fmt.Println(*configResource.Name)
6967
}

0 commit comments

Comments
 (0)