Skip to content

Misc test fixes #1562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/lib/loginUser.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/bin/bash
echo "Logging in as user"
azure account add -u "$azureUser" -p "$password" -s "$subscription"
1 change: 1 addition & 0 deletions examples/lib/testrunner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export location="westus"
export CmdletSessionID=1010
export MSYS_NO_PATHCONV=1

echo "Logging in as user"
. $BASEDIR/loginUser.sh

for d in $( ls $BASEDIR/.. --ignore=lib ); do
Expand Down
14 changes: 8 additions & 6 deletions src/CLU/Commands.Common.ScenarioTest/ExampleScriptRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ public class ExampleScriptRunner
ResourceManagementClient _client;
const string DefaultLocation = "westus";
const string ResourceGroupNameKey = "groupName";
const string locationKey = "location";
const string LocationKey = "location";
const string BaseDir = "BASEDIR";
const string SessionKey = "CmdletSessionID";
const string storageAccountTypeKey = "storageAccountType";
const string storageAccountNameKey = "storageAccountName";
const string StorageAccountTypeKey = "storageAccountType";
const string StorageAccountNameKey = "storageAccountName";
const string DefaultStorageAccountType = "Standard_GRS";

public ExampleScriptRunner(string sessionId) : this(new Random(), sessionId)
Expand Down Expand Up @@ -106,11 +107,12 @@ public string RunScript(string testName)
DeployTemplate(deploymentTemplatePath, _resourceGroupName);
}

process.EnvironmentVariables[BaseDir] = testDirectory;
process.EnvironmentVariables[SessionKey] = _sessionId;
process.EnvironmentVariables[ResourceGroupNameKey] = _resourceGroupName;
process.EnvironmentVariables[locationKey] = DefaultLocation;
process.EnvironmentVariables[storageAccountTypeKey] = DefaultStorageAccountType;
process.EnvironmentVariables[storageAccountNameKey] = _storageAccountName;
process.EnvironmentVariables[LocationKey] = DefaultLocation;
process.EnvironmentVariables[StorageAccountTypeKey] = DefaultStorageAccountType;
process.EnvironmentVariables[StorageAccountNameKey] = _storageAccountName;
foreach (var helper in _context.EnvironmentHelpers)
{
helper.TrySetupScriptEnvironment(_context, _clientFactory, process.EnvironmentVariables);
Expand Down
7 changes: 5 additions & 2 deletions src/CLU/Commands.Common.ScenarioTest/ProcessHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,16 @@ private void SetEnvironmentVariables(ProcessStartInfo startInfo)

private void ProcessError(object sender, DataReceivedEventArgs e)
{
Logger.Instance.WriteError(e.Data);
if (e.Data != null)
{
Logger.Instance.WriteError(e.Data);
}
}

private void ProcessOutput(object sender, DataReceivedEventArgs e)
{
Logger.Instance.WriteMessage(e.Data);
_processOutput.Append(e.Data);
Logger.Instance.WriteMessage(e.Data);
}

private void EndProcess()
Expand Down
5 changes: 4 additions & 1 deletion src/CLU/Commands.Common.ScenarioTest/ScenarioTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using Microsoft.Azure.Commands.Common.Authentication.Models;
using Microsoft.Azure.Commands.Common.ScenarioTest;
using Microsoft.Azure.Commands.Models;
using Moq.Protected;
using Newtonsoft.Json;

namespace Microsoft.Azure.Commands.Common.ScenarioTest
Expand All @@ -34,6 +33,10 @@ public ScenarioTestFixture()
var helper = GetRunner("lib");
var profileText = helper.RunScript(credentials.LoginScriptName);
var profile = JsonConvert.DeserializeObject<PSAzureProfile>(profileText);
if (profile == null)
{
throw new ArgumentOutOfRangeException(nameof(profile), $"Deserialized profile is null: `{profileText}`");
}
AzureContext = (AzureContext) (profile.Context);
}

Expand Down
1 change: 0 additions & 1 deletion src/CLU/Commands.Common.ScenarioTest/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"Commands.Common": "",
"Commands.Common.Authentication": "",
"Commands.ResourceManager.Common": "",
"Commands.ScenarioTests.ResourceManager.Common": "",
"Microsoft.Azure.Commands.Profile": "",
"Microsoft.Azure.Management.Resources": "3.3.0-preview",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
Expand Down