public static void GetTestSettings(string testSettings) { switch (testSettings) { case "UseDefaults": default: CredentialHelper.GetCredentialInfo(Environment.CurrentDirectory); break; case "UseCustom": if (!string.IsNullOrWhiteSpace(Resource.PublishSettingsFile)) { publishSettingsFile = Resource.PublishSettingsFile; } else { Assert.IsNotNull(CredentialHelper.PublishSettingsFile); } if (!string.IsNullOrWhiteSpace(Resource.DefaultSubscriptionName)) { defaultSubscriptionName = Resource.DefaultSubscriptionName; } break; case "UseDefaultsandOverride": CredentialHelper.GetCredentialInfo(Environment.CurrentDirectory); if (!string.IsNullOrWhiteSpace(Resource.PublishSettingsFile)) { CredentialHelper.PublishSettingsFile = Resource.PublishSettingsFile; } if (!string.IsNullOrWhiteSpace(Resource.DefaultSubscriptionName)) { CredentialHelper.DefaultSubscriptionName = Resource.DefaultSubscriptionName; } break; } if (!string.IsNullOrWhiteSpace(Resource.Location)) { location = Resource.Location; } }
public void Initialize() { vhdName = Utilities.GetUniqueShortName(vhdNamePrefix); image = Utilities.GetUniqueShortName(imageNamePrefix); vhdBlobLocation = string.Format("{0}{1}/{2}", blobUrlRoot, vhdContainerName, vhdName); try { if (string.IsNullOrEmpty(localFile)) { CredentialHelper.CopyTestData(testDataContainer, osVhdName, vhdContainerName, vhdName); } else { vmPowershellCmdlets.AddAzureVhd(new FileInfo(localFile), vhdBlobLocation); } } catch (Exception e) { if (e.ToString().Contains("already exists") || e.ToString().Contains("currently a lease")) { // Use the already uploaded vhd. Console.WriteLine("Using already uploaded blob.."); } else { Console.WriteLine(e.ToString()); Assert.Inconclusive("Upload vhd is not set!"); } } try { vmPowershellCmdlets.AddAzureVMImage(image, vhdBlobLocation, OS.Windows); } catch (Exception e) { Console.WriteLine(e.ToString()); throw; } pass = false; testStartTime = DateTime.Now; }
public static void ClassInit(TestContext context) { //SetTestSettings(); if (defaultAzureSubscription.Equals(null)) { Assert.Inconclusive("No Subscription is selected!"); } vhdBlobLocation = string.Format("{0}{1}/{2}", blobUrlRoot, vhdContainerName, vhdName); if (string.IsNullOrEmpty(localFile)) { try { CredentialHelper.CopyTestData(testDataContainer, osVhdName, vhdContainerName, vhdName); } catch (Exception e) { Console.WriteLine(e.ToString()); Assert.Inconclusive("No vhd exists for Save-AzureVhd tests!"); } } else { try { vmPowershellCmdlets.AddAzureVhd(new FileInfo(localFile), vhdBlobLocation); } catch (Exception e) { if (e.ToString().Contains("already exists")) { // Use the already uploaded vhd. Console.WriteLine("Using already uploaded blob.."); } else { Assert.Inconclusive("No vhd exists for Save-AzureVhd tests!"); } } } }
public static void SetTestSettings() { vmPowershellCmdlets = new ServiceManagementCmdletTestHelper(); CredentialHelper.GetTestSettings(Resource.TestSettings); vmPowershellCmdlets.RemoveAzureSubscriptions(); vmPowershellCmdlets.ImportAzurePublishSettingsFile(CredentialHelper.PublishSettingsFile); if (string.IsNullOrEmpty(CredentialHelper.DefaultSubscriptionName)) { defaultAzureSubscription = vmPowershellCmdlets.GetCurrentAzureSubscription(); if (string.IsNullOrEmpty(Resource.DefaultSubscriptionName)) { CredentialHelper.DefaultSubscriptionName = defaultAzureSubscription.SubscriptionName; } } else { defaultAzureSubscription = vmPowershellCmdlets.SetDefaultAzureSubscription(CredentialHelper.DefaultSubscriptionName); } locationName = vmPowershellCmdlets.GetAzureLocationName(new[] { CredentialHelper.Location }); // Get-AzureLocation if (String.IsNullOrEmpty(locationName)) { Console.WriteLine("No location is selected!"); } Console.WriteLine("Location Name: {0}", locationName); if (defaultAzureSubscription.CurrentStorageAccount == null && !string.IsNullOrEmpty(CredentialHelper.DefaultStorageName)) { SetDefaultStorage(); } imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false); // Get-AzureVMImage if (String.IsNullOrEmpty(imageName)) { Console.WriteLine("No image is selected!"); } else { Console.WriteLine("Image Name: {0}", imageName); } }