/// <summary> /// Deploys package on local machine. This method does following: /// 1. Starts compute emulator. /// 2. Starts storage emulator. /// 3. Remove all previous deployments in the emulator. /// 4. Deploys the package on local machine. /// </summary> /// <param name="packagePath">Path to package which will be deployed</param> /// <param name="configPath">Local configuration path to used with the package</param> /// <param name="launch">Switch which opens browser for web roles after deployment</param> /// <param name="mode">Emulator mode: Full or Express</param> /// <param name="standardOutput">Standard output of deployment</param> /// <param name="standardError">Standard error of deployment</param> /// <returns>Deployment id associated with the deployment</returns> public int StartEmulator(string packagePath, string configPath, bool launch, ComputeEmulatorMode mode, out string standardOutput, out string standardError) { // Starts compute emulator. StartComputeEmulator(mode, out standardOutput, out standardError); // Starts storage emulator. StartStorageEmulator(out standardOutput, out standardError); // Remove all previous deployments in the emulator. RemoveAllDeployments(out standardOutput, out standardError); // Deploys the package on local machine. string arguments = string.Format(Resources.RunInEmulatorArguments, packagePath, configPath, (launch) ? Resources.CsRunLanuchBrowserArg : string.Empty); StartCsRunProcess(mode, arguments, out standardOutput, out standardError); // Get deployment id for future use. DeploymentId = GetDeploymentCount(standardOutput); standardOutput = GetRoleInfoMessage(standardOutput); return DeploymentId; }
private void StartCsRunProcess(ComputeEmulatorMode mode, string arguments) { if (mode == ComputeEmulatorMode.Full) { arguments += " " + Resources.CsRunFullEmulatorArg; } StartCsRunProcess(arguments); }
/// <summary> /// Starts azure emulator for this service. /// </summary> /// <remarks>This methods removes all deployments already in the emulator.</remarks> /// <param name="launchBrowser">Switch to control opening a browser for web roles.</param> /// <param name="standardOutput">Output result from csrun.exe</param> /// <param name="standardError">Error result from csrun.exe</param> public void StartEmulators(bool launchBrowser, ComputeEmulatorMode mode, out string roleInformation, out string warning) { var runTool = new CsRun(AzureTool.GetComputeEmulatorDirectory()); runTool.StartEmulator(Paths.LocalPackage, Paths.LocalConfiguration, launchBrowser, mode); roleInformation = runTool.RoleInformation; var storageEmulator = new StorageEmulator(AzureTool.GetStorageEmulatorDirectory()); storageEmulator.Start(); //for now, errors related with storage emulator are treated as non-fatal warning = storageEmulator.Error; }
private void StartEmulatorCommonTest(ComputeEmulatorMode mode) { // Setup string testEmulatorFolder = @"C:\sample-path"; string testPackagePath = @"c:\sample-path\local_package.csx"; string testConfigPath = @"c:\sample-path\ServiceConfiguration.Local.cscfg"; string expectedCsrunCommand = testEmulatorFolder + @"\" + Resources.CsRunExe; string expectedComputeArguments = Resources.CsRunStartComputeEmulatorArg; string expectedRemoveAllDeploymentsArgument = Resources.CsRunRemoveAllDeploymentsArg; string expectedAzureProjectArgument = string.Format("/run:\"{0}\";\"{1}\" {2} /useiisexpress", testPackagePath, testConfigPath, Resources.CsRunLanuchBrowserArg); if (mode == ComputeEmulatorMode.Full) { expectedComputeArguments += " " + Resources.CsRunFullEmulatorArg; expectedAzureProjectArgument += " " + Resources.CsRunFullEmulatorArg; } string testRoleUrl = "http://127.0.0.1:8080/"; int testDeploymentId = 58; string testOutput = string.Format("Started: deployment23({0}) Role is running at " + testRoleUrl + ".", testDeploymentId.ToString()); string expectedRoleRunningMessage = string.Format(Resources.EmulatorRoleRunningMessage, testRoleUrl) + System.Environment.NewLine; CsRun csRun = new CsRun(testEmulatorFolder); Mock <ProcessHelper> commandRunner = new Mock <ProcessHelper>(); commandRunner.Setup(p => p.StartAndWaitForProcess(expectedCsrunCommand, expectedComputeArguments)); commandRunner.Setup(p => p.StartAndWaitForProcess(expectedCsrunCommand, expectedRemoveAllDeploymentsArgument)); commandRunner.Setup(p => p.StartAndWaitForProcess(expectedCsrunCommand, expectedAzureProjectArgument)) .Callback(() => { commandRunner.Object.StandardOutput = testOutput; }); // Execute csRun.CommandRunner = commandRunner.Object; csRun.StartEmulator(testPackagePath, testConfigPath, true, mode); // Assert commandRunner.VerifyAll(); Assert.Equal(csRun.DeploymentId, testDeploymentId); Assert.Equal(csRun.RoleInformation, expectedRoleRunningMessage); }
private void StartEmulatorCommonTest(ComputeEmulatorMode mode) { // Setup string testEmulatorFolder = @"C:\sample-path"; string testPackagePath = @"c:\sample-path\local_package.csx"; string testConfigPath = @"c:\sample-path\ServiceConfiguration.Local.cscfg"; string expectedCsrunCommand = testEmulatorFolder + @"\" + Resources.CsRunExe; string expectedComputeArguments = Resources.CsRunStartComputeEmulatorArg; string expectedRemoveAllDeploymentsArgument = Resources.CsRunRemoveAllDeploymentsArg; string expectedAzureProjectArgument = string.Format("/run:\"{0}\";\"{1}\" {2} /useiisexpress", testPackagePath, testConfigPath, Resources.CsRunLanuchBrowserArg); if (mode== ComputeEmulatorMode.Full) { expectedComputeArguments += " " + Resources.CsRunFullEmulatorArg; expectedAzureProjectArgument += " " + Resources.CsRunFullEmulatorArg; } string testRoleUrl = "http://127.0.0.1:8080/"; int testDeploymentId = 58; string testOutput = string.Format("Started: deployment23({0}) Role is running at " + testRoleUrl + ".", testDeploymentId.ToString()); string expectedRoleRunningMessage = string.Format(Resources.EmulatorRoleRunningMessage, testRoleUrl) + System.Environment.NewLine; CsRun csRun = new CsRun(testEmulatorFolder); Mock<ProcessHelper> commandRunner = new Mock<ProcessHelper>(); commandRunner.Setup(p => p.StartAndWaitForProcess(expectedCsrunCommand, expectedComputeArguments)); commandRunner.Setup(p => p.StartAndWaitForProcess(expectedCsrunCommand, expectedRemoveAllDeploymentsArgument)); commandRunner.Setup(p => p.StartAndWaitForProcess(expectedCsrunCommand, expectedAzureProjectArgument)) .Callback(() => { commandRunner.Object.StandardOutput = testOutput; }); // Execute csRun.CommandRunner = commandRunner.Object; csRun.StartEmulator(testPackagePath, testConfigPath, true, mode); // Assert commandRunner.VerifyAll(); Assert.Equal(csRun.DeploymentId, testDeploymentId); Assert.Equal(csRun.RoleInformation, expectedRoleRunningMessage); }
/// <summary> /// Deploys package on local machine. This method does following: /// 1. Starts compute emulator. /// 2. Remove all previous deployments in the emulator. /// 3. Deploys the package on local machine. /// </summary> /// <param name="packagePath">Path to package which will be deployed</param> /// <param name="configPath">Local configuration path to used with the package</param> /// <param name="launch">Switch which opens browser for web roles after deployment</param> /// <param name="mode">Emulator mode: Full or Express</param> /// <param name="roleInformation">Standard output of deployment</param> /// <param name="standardError">Standard error of deployment</param> /// <returns>Deployment id associated with the deployment</returns> public int StartEmulator(string packagePath, string configPath, bool launch, ComputeEmulatorMode mode) { RoleInformation = string.Empty; // Starts compute emulator. StartComputeEmulator(mode); // Remove all previous deployments in the emulator. RemoveAllDeployments(); // Deploys the package on local machine. string arguments = string.Format(Resources.RunInEmulatorArguments, packagePath, configPath, (launch) ? Resources.CsRunLanuchBrowserArg : string.Empty); StartCsRunProcess(mode, arguments); DeploymentId = GetDeploymentCount(_standardOutput); RoleInformation = GetRoleInfoMessage(_standardOutput); return DeploymentId; }
/// <summary> /// Deploys package on local machine. This method does following: /// 1. Starts compute emulator. /// 2. Remove all previous deployments in the emulator. /// 3. Deploys the package on local machine. /// </summary> /// <param name="packagePath">Path to package which will be deployed</param> /// <param name="configPath">Local configuration path to used with the package</param> /// <param name="launch">Switch which opens browser for web roles after deployment</param> /// <param name="mode">Emulator mode: Full or Express</param> /// <param name="roleInformation">Standard output of deployment</param> /// <param name="standardError">Standard error of deployment</param> /// <returns>Deployment id associated with the deployment</returns> public int StartEmulator(string packagePath, string configPath, bool launch, ComputeEmulatorMode mode) { RoleInformation = string.Empty; // Starts compute emulator. StartComputeEmulator(mode); // Remove all previous deployments in the emulator. RemoveAllDeployments(); // Deploys the package on local machine. string arguments = string.Format(Resources.RunInEmulatorArguments, packagePath, configPath, (launch) ? Resources.CsRunLanuchBrowserArg : string.Empty); StartCsRunProcess(mode, arguments); DeploymentId = GetDeploymentCount(_standardOutput); RoleInformation = GetRoleInfoMessage(_standardOutput); return(DeploymentId); }
private void StartEmulatorCommonTest(ComputeEmulatorMode mode) { // Setup string testEmulatorFolder = @"C:\foo-bar"; string testPackagePath = @"c:\foo-bar\local_package.csx"; string testConfigPath = @"c:\foo-bar\ServiceConfiguration.Local.cscfg"; string expectedCsrunCommand = testEmulatorFolder + @"\" + Resources.CsRunExe; string expectedComputeArguments = Resources.CsRunStartComputeEmulatorArg; string expectedStorageArgument = Resources.CsRunStartStorageEmulatorArg; string expectedRemoveAllDeploymentsArgument = Resources.CsRunRemoveAllDeploymentsArg; string expectedAzureProjectArgument = string.Format("\"{0}\" \"{1}\" {2} /useiisexpress", testPackagePath, testConfigPath, Resources.CsRunLanuchBrowserArg); if (mode== ComputeEmulatorMode.Express) { expectedComputeArguments += " " + Resources.CsRunEmulatorExpressArg; expectedAzureProjectArgument += " " + Resources.CsRunEmulatorExpressArg; } string testOutput = "Role is running at tcp://127.0.0.1:8080"; CsRun csRun = new CsRun(testEmulatorFolder); Mock<ProcessHelper> commandRunner = new Mock<ProcessHelper>(); commandRunner.Setup(p => p.StartAndWaitForProcess(expectedCsrunCommand, expectedComputeArguments)); commandRunner.Setup(p => p.StartAndWaitForProcess(expectedCsrunCommand, expectedStorageArgument)); commandRunner.Setup(p => p.StartAndWaitForProcess(expectedCsrunCommand, expectedRemoveAllDeploymentsArgument)); commandRunner.Setup(p => p.StartAndWaitForProcess(expectedCsrunCommand, expectedAzureProjectArgument)) .Callback(() => { commandRunner.Object.StandardOutput = testOutput; }); // Execute csRun.CommandRunner = commandRunner.Object; string output, error; csRun.StartEmulator(testPackagePath, testConfigPath, true, mode, out output, out error); // Assert commandRunner.VerifyAll(); }
/// <summary> /// Starts azure emulator for this service. /// </summary> /// <remarks>This methods removes all deployments already in the emulator.</remarks> /// <param name="launchBrowser">Switch to control opening a browser for web roles.</param> /// <param name="standardOutput">Output result from csrun.exe</param> /// <param name="standardError">Error result from csrun.exe</param> public void StartEmulator(bool launchBrowser, ComputeEmulatorMode mode , out string standardOutput, out string standardError) { var runTool = new CsRun(AzureTool.GetAzureEmulatorDirectory()); runTool.StartEmulator(Paths.LocalPackage, Paths.LocalConfiguration, launchBrowser, mode, out standardOutput, out standardError); }
/// <summary> /// Starts azure emulator for this service. /// </summary> /// <remarks>This methods removes all deployments already in the emulator.</remarks> /// <param name="launchBrowser">Switch to control opening a browser for web roles.</param> /// <param name="mode"></param> /// <param name="roleInformation"></param> /// <param name="warning"></param> public void StartEmulators(bool launchBrowser, ComputeEmulatorMode mode , out string roleInformation, out string warning) { var runTool = new CsRun(AzureTool.GetComputeEmulatorDirectory()); runTool.StartEmulator(Paths.LocalPackage, Paths.LocalConfiguration, launchBrowser, mode); roleInformation = runTool.RoleInformation; var storageEmulator = new StorageEmulator(AzureTool.GetStorageEmulatorDirectory()); storageEmulator.Start(); //for now, errors related with storage emulator are treated as non-fatal warning = storageEmulator.Error; }
private void StartComputeEmulator(ComputeEmulatorMode mode) { StartCsRunProcess(mode, Resources.CsRunStartComputeEmulatorArg); }
private void StartCsRunProcess(ComputeEmulatorMode mode, string arguments) { if (mode == ComputeEmulatorMode.Express) { arguments += " " + Resources.CsRunEmulatorExpressArg; } StartCsRunProcess(arguments); }
private void StartComputeEmulator(ComputeEmulatorMode mode, out string standardOutput, out string standardError) { StartCsRunProcess(mode, Resources.CsRunStartComputeEmulatorArg, out standardOutput, out standardError); }
private void StartCsRunProcess(ComputeEmulatorMode mode, string arguments, out string standardOutput, out string standardError) { if (mode == ComputeEmulatorMode.Express) { arguments += " " + Resources.CsRunEmulatorExpressArg; } StartCsRunProcess(arguments, out standardOutput, out standardError); }