Beispiel #1
0
        public void RoleInfoIsExtractedFromEmulatorOutput()
        {
            var dummyEmulatorOutput = "Exported interface at http://127.0.0.1:81/.\r\nExported interface at tcp://127.0.0.1:8080/.";
            var output = CsRun.GetRoleInfoMessage(dummyEmulatorOutput);

            Assert.True(output.Contains("Role is running at http://127.0.0.1:81"));
            Assert.True(output.Contains("Role is running at tcp://127.0.0.1:8080"));
        }
 public AzureService(string rootPath, string scaffoldingPath)
 {
     SetScaffolding(scaffoldingPath);
     Paths       = new ServicePathInfo(rootPath);
     Components  = new ServiceComponents(Paths);
     packageTool = new CsPack();
     runTool     = new CsRun();
 }
Beispiel #3
0
        private void ExecuteOnChange()
        {
            var timer    = new BlockingTimer();
            var observer = new SourceObservation(_fs, timer);

            observer.WatchForChange(_cmd.SourceFilename,
                                    () => {
                var result = CsRun.Run(_cmd.SourceFilename);
                ResultEvaluation.Handle(result, _resultLog);
            });
        }
Beispiel #4
0
        public void StopEmulators(out string warning)
        {
            var runTool = new CsRun(AzureTool.GetComputeEmulatorDirectory());

            runTool.StopComputeEmulator();

            var storageEmulator = new StorageEmulator(AzureTool.GetStorageEmulatorDirectory());

            storageEmulator.Stop();
            //for now, errors related with storage emulator are treated as non-fatal
            warning = storageEmulator.Error;
        }
Beispiel #5
0
        /// <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;
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        public void Receive_compiler_error()
        {
            var result = CsRun.Run("CsRun_tests_with_compiler_error.csrun");

            switch (result)
            {
            case CompilerErrorLogDto cel:
                foreach (var e in cel.Errors)
                {
                    Console.WriteLine($"{e}");
                }
                Assert.AreEqual(2, cel.Errors.Length);
                Assert.IsTrue(cel.Errors[0].IndexOf("Unexpected symbol `return'") >= 0);
                Assert.IsTrue(cel.Errors[1].IndexOf("Unexpected symbol `]'") >= 0);
                break;

            case RuntimeFailureLogDto rfl:
            case TestResultsLogDto trl:
                Assert.Fail($"Unexpected result type: {result.GetType().Name}");
                break;
            }
        }
        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("\"{0}\" \"{1}\" {2} /useiisexpress",
                testPackagePath, testConfigPath, Resources.CsRunLanuchBrowserArg);
            if (mode== ComputeEmulatorMode.Express)
            {
                expectedComputeArguments += " " + Resources.CsRunEmulatorExpressArg;
                expectedAzureProjectArgument += " " + Resources.CsRunEmulatorExpressArg;
            }

            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) + 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.AreEqual(csRun.DeploymentId, testDeploymentId);
            Assert.AreEqual(csRun.RoleInformation, expectedRoleRunningMessage);
        }
Beispiel #9
0
        public void Receive_test_results()
        {
            var result = CsRun.Run("CsRun_tests_with_failure.csrun");

            switch (result)
            {
            case CompilerErrorLogDto cel:
            case RuntimeFailureLogDto rfl:
                Assert.Fail($"Unexpected result type: {result.GetType().Name}");
                break;

            case TestResultsLogDto trl:
                Assert.AreEqual(3, trl.Results.Length);
                Assert.IsFalse(trl.Results[0].success);
                Assert.AreEqual("fehlschlagender test", trl.Results[0].label);
                Assert.IsTrue(trl.Results[1].success);
                Assert.AreEqual("addition mit positiven zahlen", trl.Results[2].label);

                Assert.AreEqual(1, trl.Failures.Length);
                Assert.AreEqual("fehlschlagender test", trl.Failures[0].Label);
                break;
            }
        }
        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();
        }
 //for stopping the emulator none of the path info is required
 public AzureService()
 {
     runTool = new CsRun();
 }
 public void StopEmulator()
 {
     var runTool = new CsRun(AzureTool.GetAzureEmulatorDirectory());
     runTool.StopEmulator();
 }
 /// <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);
 }
 public void StopEmulator(out string standardOutput, out string standardError)
 {
     var runTool = new CsRun();
     runTool.StopEmulator(out standardOutput, out standardError);
 }
 public void StartEmulator(bool launch, out string standardOutput, out string standardError)
 {
     var runTool = new CsRun();
     runTool.StartEmulator(Paths.LocalPackage, Paths.LocalConfiguration, launch, out standardOutput, out standardError);
 }
        public void StopEmulators(out string warning)
        {
            var runTool = new CsRun(AzureTool.GetComputeEmulatorDirectory());
            runTool.StopComputeEmulator();

            var storageEmulator = new StorageEmulator(AzureTool.GetStorageEmulatorDirectory());
            storageEmulator.Stop();
            //for now, errors related with storage emulator are treated as non-fatal  
            warning = storageEmulator.Error;
        }
        /// <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;
        }
Beispiel #18
0
        public void StopEmulator(out string standardOutput, out string standardError)
        {
            var runTool = new CsRun();

            runTool.StopEmulator(out standardOutput, out standardError);
        }
Beispiel #19
0
        public void StartEmulator(bool launch, out string standardOutput, out string standardError)
        {
            var runTool = new CsRun();

            runTool.StartEmulator(Paths.LocalPackage, Paths.LocalConfiguration, launch, out standardOutput, out standardError);
        }