Skip to content

Commit 617c65b

Browse files
committed
Fixed VM and Deployments tests
1 parent f1ff07f commit 617c65b

File tree

6 files changed

+24
-20
lines changed

6 files changed

+24
-20
lines changed

examples/compute-management/02-VirtualMachineCreation.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ printf "\n2. Creating a new storage account '%s' in type '%s'.\n" "$storageAccou
99
azure storage account new --resourcegroupname "$groupName" --name "$storageAccountName" --location "$location" --type "$storageAccountType"
1010

1111
printf "\n3. Create virtual network.\n"
12-
result=`azure virtual network create --resourcegroupname "$groupName" --name test --location "$location" --addressprefix "[\"10.0.0.0/16\"]" --subnet "[{\"Name\":\"test\",\"AddressPrefix\":\"10.0.0.0/24\"}]" --force`
12+
result=`azure virtual network new --resourcegroupname "$groupName" --name test --location "$location" --addressprefix "[\"10.0.0.0/16\"]" --subnet "[{\"Name\":\"test\",\"AddressPrefix\":\"10.0.0.0/24\"}]" --force`
1313

1414
contextResult=`azure context get`
1515

@@ -19,7 +19,7 @@ subnetId="/subscriptions/$subId/resourceGroups/$groupName/providers/Microsoft.Ne
1919

2020
printf "\n4. Create network interface with:\r\nsubId='%s' \r\n& \r\nsubnetId='$subnetId'.\n" "$subId"
2121
export MSYS_NO_PATHCONV=1
22-
azure network interface create --name test --resourcegroupname "$groupName" --location "$location" --subnetid "$subnetId"
22+
azure network interface new --name test --resourcegroupname "$groupName" --location "$location" --subnetid "$subnetId"
2323
export MSYS_NO_PATHCONV=
2424

2525
nicId="/subscriptions/$subId/resourceGroups/$groupName/providers/Microsoft.Network/networkInterfaces/test"

examples/lib/testrunner.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ export TESTDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
33
. $TESTDIR/helper.sh
44
export groupName=`randomName testrg`
55
export location="westus"
6-
export CmdletSessionID=1010
76
export MSYS_NO_PATHCONV=1
87

98
echo "Logging in as user"

examples/resource-management/03-Deployments.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ printf "\n1. Creating a new resource group: %s and location: %s.\n" "$groupName"
66
azure group create --name "$groupName" --location "$location"
77

88
printf "\n2. Test template with dynamic parameters\n"
9-
siteName=`randomName testrn`
10-
azure group deployment test -g "$groupName" --templatefile $BASEDIR/resource-management/sampleTemplate.json --siteName "$siteName" --hostingPlanName "$siteName" --siteLocation "$location" --sku "Standard" --workerSize "0"
9+
azure group deployment test -g "$groupName" --templatefile $BASEDIR/sampleTemplate.json --siteName "$resourceName" --hostingPlanName "$resourceName" --siteLocation "$location" --sku "Standard" --workerSize "0"
1110

1211
printf "\n3. Test template with JSON parameter object\n"
13-
azure group deployment test -g "$groupName" --templatefile $BASEDIR/resource-management/sampleTemplate.json --templateparameterobject "{\"siteName\":\"$siteName\",\"hostingPlanName\":\"$siteName\",\"siteLocation\":\"$location\",\"sku\":\"Standard\",\"workerSize\": 0 }"
12+
azure group deployment test -g "$groupName" --templatefile $BASEDIR/sampleTemplate.json --templateparameterobject "{\"siteName\":\"$resourceName\",\"hostingPlanName\":\"$resourceName\",\"siteLocation\":\"$location\",\"sku\":\"Standard\",\"workerSize\": 0 }"
1413

1514
printf "\n4. Provisioning Deployment\n"
16-
deploymentInfo=`azure group deployment create --Name "$siteName" --ResourceGroupName "$groupName" --TemplateFile $BASEDIR/resource-management/sampleTemplate.json --TemplateParameterFile $BASEDIR/resource-management/sampleTemplateParams.json`
15+
deploymentInfo=`azure group deployment create --Name "$resourceName" --ResourceGroupName "$groupName" --TemplateFile $BASEDIR/sampleTemplate.json --TemplateParameterFile $BASEDIR/sampleTemplateParams.json`
1716
echo $deploymentInfo

src/CLU/Commands.Common.ScenarioTest/ExampleScriptRunner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class ExampleScriptRunner
4141
const string ResourceGroupNameKey = "groupName";
4242
const string LocationKey = "location";
4343
const string BaseDir = "BASEDIR";
44-
const string SessionKey = "CmdletSessionID";
44+
const string SessionKey = "AzureProfile";
4545
const string StorageAccountTypeKey = "storageAccountType";
4646
const string StorageAccountNameKey = "storageAccountName";
4747
const string DefaultStorageAccountType = "Standard_GRS";

src/CLU/Commands.Common.ScenarioTest/ExamplesTests/ResourceManagementTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ public void ResourcesTest()
4242
helper.RunScript("02-Resource");
4343
}
4444

45+
[Fact]
46+
public void DeploymentsTest()
47+
{
48+
var helper = _collectionState
49+
.GetRunner("resource-management");
50+
helper.EnvironmentVariables.Add("resourceName", helper.GenerateName("csmr"));
51+
helper.RunScript("03-Deployments");
52+
}
53+
4554
[Fact]
4655
public void RoleAssignmentsTest()
4756
{

src/CLU/Commands.Common.ScenarioTest/ScenarioTestFixture.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,24 @@ public ScenarioTestFixture()
3838
SessionId = $"{Generator.Next(10000, 99999)}";
3939
}
4040

41-
private ScenarioTestFixture(AzureContext conext, string sessionId)
42-
{
43-
Generator = new Random();
44-
SessionId = sessionId;
45-
AzureContext = conext;
46-
}
47-
4841
public string SessionId { get; protected set; }
4942
public Random Generator { get; protected set; }
5043

5144
public ScenarioTestFixture LoginAsUser()
5245
{
53-
return new ScenarioTestFixture(Login(EnvironmentCredentialsProvider.LoginUserScript), SessionId);
46+
var newTestFixture = new ScenarioTestFixture();
47+
newTestFixture.Login(EnvironmentCredentialsProvider.LoginUserScript);
48+
return newTestFixture;
5449
}
5550

5651
public ScenarioTestFixture LoginAsService()
5752
{
58-
return new ScenarioTestFixture(Login(EnvironmentCredentialsProvider.LoginServiceScript), SessionId);
53+
var newTestFixture = new ScenarioTestFixture();
54+
newTestFixture.Login(EnvironmentCredentialsProvider.LoginServiceScript);
55+
return newTestFixture;
5956
}
6057

61-
private AzureContext Login(string loginScript)
58+
private void Login(string loginScript)
6259
{
6360
var helper = new ExampleScriptRunner(Generator, SessionId)
6461
{
@@ -70,7 +67,7 @@ private AzureContext Login(string loginScript)
7067
{
7168
throw new ArgumentOutOfRangeException(nameof(profile), $"Deserialized profile is null: `{profileText}`");
7269
}
73-
return profile.Context;
70+
AzureContext = profile.Context;
7471
}
7572

7673
public ExampleScriptRunner GetRunner(string directoryName)
@@ -79,7 +76,7 @@ public ExampleScriptRunner GetRunner(string directoryName)
7976
{
8077
var credentials = new EnvironmentCredentialsProvider();
8178
credentials.Initialize();
82-
AzureContext = Login(credentials.LoginScriptName);
79+
Login(credentials.LoginScriptName);
8380
}
8481
var context = EnvironmentContextFactory.GetTestContext(directoryName);
8582
context.Context = AzureContext;

0 commit comments

Comments
 (0)