Beispiel #1
0
        public void EnableAzureMemcacheRoleProcessOnWorkerRoleSuccess()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                string serviceName     = "AzureService";
                string rootPath        = files.CreateNewService(serviceName);
                string cacheRoleName   = "CacheWorkerRole";
                string workerRoleName  = "WorkerRole";
                string expectedMessage = string.Format(Resources.EnableMemcacheMessage, workerRoleName, cacheRoleName, Resources.MemcacheEndpointPort);

                addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand()
                {
                    RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = workerRoleName
                };
                addNodeWorkerCmdlet.ExecuteCmdlet();
                addCacheRoleCmdlet.AddAzureCacheWorkerRoleProcess(cacheRoleName, 1, rootPath);
                mockCommandRuntime.ResetPipelines();
                enableCacheCmdlet.PassThru = true;
                enableCacheCmdlet.EnableAzureMemcacheRoleProcess(workerRoleName, cacheRoleName, rootPath);

                WorkerRole workerRole = Testing.GetWorkerRole(rootPath, workerRoleName);

                AzureAssert.RuntimeUrlAndIdExists(workerRole.Startup.Task, Resources.CacheRuntimeValue);

                AzureAssert.ScaffoldingExists(Path.Combine(files.RootPath, serviceName, workerRoleName), Path.Combine(Resources.CacheScaffolding, Resources.WorkerRole));
                AzureAssert.StartupTaskExists(workerRole.Startup.Task, Resources.CacheStartupCommand);

                AzureAssert.InternalEndpointExists(workerRole.Endpoints.InternalEndpoint,
                                                   new InternalEndpoint {
                    name = Resources.MemcacheEndpointName, protocol = InternalProtocol.tcp, port = Resources.MemcacheEndpointPort
                });

                LocalStore localStore = new LocalStore
                {
                    name = Resources.CacheDiagnosticStoreName,
                    cleanOnRoleRecycle = false
                };

                AzureAssert.LocalResourcesLocalStoreExists(localStore, workerRole.LocalResources);

                DefinitionConfigurationSetting diagnosticLevel = new DefinitionConfigurationSetting {
                    name = Resources.CacheClientDiagnosticLevelAssemblyName
                };
                AzureAssert.ConfigurationSettingExist(diagnosticLevel, workerRole.ConfigurationSettings);

                ConfigConfigurationSetting clientDiagnosticLevel = new ConfigConfigurationSetting {
                    name = Resources.ClientDiagnosticLevelName, value = Resources.ClientDiagnosticLevelValue
                };
                AzureAssert.ConfigurationSettingExist(clientDiagnosticLevel, Testing.GetCloudRole(rootPath, workerRoleName).ConfigurationSettings);
                AzureAssert.ConfigurationSettingExist(clientDiagnosticLevel, Testing.GetLocalRole(rootPath, workerRoleName).ConfigurationSettings);

                string workerConfigPath  = string.Format(@"{0}\{1}\{2}", rootPath, workerRoleName, "web.config");
                string workerCloudConfig = File.ReadAllText(workerConfigPath);
                Assert.IsTrue(workerCloudConfig.Contains("configSections"));
                Assert.IsTrue(workerCloudConfig.Contains("dataCacheClients"));

                Assert.AreEqual <string>(expectedMessage, mockCommandRuntime.VerboseStream[0]);
                Assert.AreEqual <string>(workerRoleName, (mockCommandRuntime.OutputPipeline[0] as PSObject).GetVariableValue <string>(Parameters.RoleName));
            }
        }
        public void AddAzureWorkerRoleWithTemplateFolder()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                string roleName               = "WorkerRole1";
                string serviceName            = "AzureService";
                string rootPath               = files.CreateNewService(serviceName);
                string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreate, rootPath, roleName);
                string scaffoldingPath        = "MyWorkerTemplateFolder";
                using (new DirStack(rootPath))
                {
                    addWorkerCmdlet = new AddAzureWorkerRoleCommand()
                    {
                        RootPath       = rootPath,
                        CommandRuntime = mockCommandRuntime,
                        Name           = roleName,
                        TemplateFolder = scaffoldingPath
                    };

                    addWorkerCmdlet.ExecuteCmdlet();

                    AzureAssert.ScaffoldingExists(Path.Combine(rootPath, roleName), scaffoldingPath);
                    Assert.Equal <string>(roleName,
                                          ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue <string>(Parameters.RoleName));
                    Assert.Equal <string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]);
                }
            }
        }
Beispiel #3
0
        public void AddNewCacheWorkerRoleSuccessful()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                string rootPath = Path.Combine(files.RootPath, "AzureService");
                string roleName = "WorkerRole";
                int    expectedInstanceCount = 10;
                newServiceCmdlet.NewAzureServiceProcess(files.RootPath, "AzureService");
                WorkerRole cacheWorkerRole = addCacheRoleCmdlet.AddAzureCacheWorkerRoleProcess(roleName, expectedInstanceCount, rootPath);

                AzureAssert.ScaffoldingExists(Path.Combine(files.RootPath, "AzureService", "WorkerRole"), Path.Combine(Resources.GeneralScaffolding, Resources.WorkerRole));

                AzureAssert.WorkerRoleImportsExists(new Import {
                    moduleName = Resources.CachingModuleName
                }, cacheWorkerRole);

                AzureAssert.LocalResourcesLocalStoreExists(new LocalStore {
                    name = Resources.CacheDiagnosticStoreName, cleanOnRoleRecycle = false
                },
                                                           cacheWorkerRole.LocalResources);

                Assert.IsNull(cacheWorkerRole.Endpoints.InputEndpoint);

                AssertConfigExists(Testing.GetCloudRole(rootPath, roleName));
                AssertConfigExists(Testing.GetLocalRole(rootPath, roleName), Resources.EmulatorConnectionString);

                PSObject actualOutput = mockCommandRuntime.OutputPipeline[1] as PSObject;
                Assert.AreEqual <string>(roleName, actualOutput.Members[Parameters.CacheWorkerRoleName].Value.ToString());
                Assert.AreEqual <int>(expectedInstanceCount, int.Parse(actualOutput.Members[Parameters.Instances].Value.ToString()));
            }
        }
        public void AddAzureWebRoleWithTemplateFolder()
        {
            string scaffoldingPath = "MyWebTemplateFolder";

            Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, scaffoldingPath));

            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                string roleName               = "WebRole1";
                string serviceName            = "AzureService";
                string rootPath               = files.CreateNewService(serviceName);
                string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreate, rootPath, roleName);
                string originalDirectory      = Directory.GetCurrentDirectory();
                Directory.SetCurrentDirectory(rootPath);
                addWebCmdlet = new AddAzureWebRoleCommand()
                {
                    RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = roleName, TemplateFolder = scaffoldingPath
                };

                addWebCmdlet.ExecuteCmdlet();

                AzureAssert.ScaffoldingExists(Path.Combine(rootPath, roleName), scaffoldingPath);
                Assert.Equal <string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue <string>(Parameters.RoleName));
                Assert.Equal <string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]);

                Directory.SetCurrentDirectory(originalDirectory);
            }
        }
Beispiel #5
0
        public void AddAzurePythonWebRoleWillRecreateDeploymentSettings()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                string roleName    = "WebRole1";
                string serviceName = "AzureService";
                string rootPath    = files.CreateNewService(serviceName);
                addPythonWebCmdlet = new AddAzureDjangoWebRoleCommand()
                {
                    RootPath = rootPath, CommandRuntime = mockCommandRuntime
                };
                addPythonWebCmdlet.CommandRuntime = mockCommandRuntime;
                string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreatePython, rootPath, roleName);
                string settingsFilePath       = Path.Combine(rootPath, Resources.SettingsFileName);
                File.Delete(settingsFilePath);
                Assert.IsFalse(File.Exists(settingsFilePath));

                addPythonWebCmdlet.ExecuteCmdlet();

                AzureAssert.ScaffoldingExists(Path.Combine(rootPath, roleName), Path.Combine(Resources.PythonScaffolding, Resources.WebRole));
                Assert.AreEqual <string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue <string>(Parameters.RoleName));
                Assert.AreEqual <string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]);
                Assert.IsTrue(File.Exists(settingsFilePath));
            }
        }
        public void GlobalPathInfoTests()
        {
            GlobalPathInfo pathInfo     = new GlobalPathInfo(Data.AzureAppDir);
            string         azureSdkPath = Data.AzureAppDir;

            AzureAssert.AreEqualGlobalPathInfo(azureSdkPath, Path.Combine(azureSdkPath, Resources.PublishSettingsFileName), pathInfo);
        }
        public void AddAzureWorkerRoleWillRecreateDeploymentSettings()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                string roleName               = "WorkerRole1";
                string serviceName            = "AzureService";
                string rootPath               = files.CreateNewService(serviceName);
                string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreate, rootPath, roleName);
                string settingsFilePath       = Path.Combine(rootPath, Resources.SettingsFileName);
                string originalDirectory      = Directory.GetCurrentDirectory();
                Directory.SetCurrentDirectory(rootPath);
                File.Delete(settingsFilePath);
                Assert.False(File.Exists(settingsFilePath));
                addWorkerCmdlet = new AddAzureWorkerRoleCommand()
                {
                    RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = roleName
                };

                addWorkerCmdlet.ExecuteCmdlet();

                AzureAssert.ScaffoldingExists(Path.Combine(rootPath, roleName), Path.Combine(Resources.GeneralScaffolding, Resources.WorkerRole));
                Assert.Equal <string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue <string>(Parameters.RoleName));
                Assert.Equal <string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]);
                Assert.True(File.Exists(settingsFilePath));

                Directory.SetCurrentDirectory(originalDirectory);
            }
        }
Beispiel #8
0
        public void ServiceComponentsTest()
        {
            newServiceCmdlet.NewAzureServiceProcess(Directory.GetCurrentDirectory(), serviceName);
            ServiceComponents components = new ServiceComponents(new ServicePathInfo(serviceName));

            AzureAssert.AreEqualServiceComponents(components);
        }
        public void SavePackageWithOneNodeWebRoleTest()
        {
            //Create a temp directory for monitoring and cleaning up the output of our test
            using (FileSystemHelper files = new FileSystemHelper(this)
            {
                EnableMonitoring = true
            })
            {
                //Create a new service that we're going to pack locally
                string serviceName = "TEST_SERVICE_NAME";
                NewAzureServiceCommand newService = new NewAzureServiceCommand();
                newService.NewAzureServiceProcess(files.RootPath, serviceName);
                string servicePath = files.CreateDirectory(serviceName);

                //Add a Node web role to the solution
                string roleName      = "TEST_WEB_ROLE";
                int    instanceCount = 2;
                AddAzureNodeWebRoleCommand addAzureNodeWebRole = new AddAzureNodeWebRoleCommand();
                addAzureNodeWebRole.AddAzureNodeWebRoleProcess(roleName, instanceCount, servicePath);

                //Run our packaging command
                SaveAzureServicePackageCommand saveServicePackage = new SaveAzureServicePackageCommand();
                saveServicePackage.CreatePackage(servicePath);

                //Assert that the service structure is as expected
                AzureAssert.ScaffoldingExists(Path.Combine(files.RootPath, serviceName, roleName), Path.Combine(Resources.NodeScaffolding, Resources.WebRole));

                // Verify the generated files
                files.AssertFiles(new Dictionary <string, Action <string> >()
                {
                    {
                        serviceName + @"\deploymentSettings.json",
                        null
                    },
                    {
                        serviceName + @"\ServiceDefinition.csdef",
                        p => File.ReadAllText(p).Contains(serviceName)
                    },
                    {
                        serviceName + @"\ServiceConfiguration.Cloud.cscfg",
                        p => File.ReadAllText(p).Contains(serviceName)
                    },
                    {
                        serviceName + @"\ServiceConfiguration.Local.cscfg",
                        p => File.ReadAllText(p).Contains(serviceName)
                    },
                    {
                        serviceName + @"\cloud_package.cspkg",
                        p =>
                        {
                            using (Package package = Package.Open(p))
                            {
                                Assert.AreEqual(6, package.GetParts().Count());
                            }
                        }
                    }
                });
            }
        }
Beispiel #10
0
 public void AzureServiceCreateNew()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         AzureService service = new AzureService(files.RootPath, serviceName, null);
         AzureAssert.AzureServiceExists(Path.Combine(files.RootPath, serviceName), Resources.GeneralScaffolding, serviceName);
     }
 }
Beispiel #11
0
        private void AssertCachingEnabled(
            FileSystemHelper files,
            string serviceName,
            string rootPath,
            string webRoleName,
            string expectedMessage)
        {
            WebRole      webRole      = Testing.GetWebRole(rootPath, webRoleName);
            RoleSettings roleSettings = Testing.GetCloudRole(rootPath, webRoleName);

            AzureAssert.RuntimeUrlAndIdExists(webRole.Startup.Task, Resources.CacheRuntimeValue);

            Assert.AreEqual <string>(Resources.CacheRuntimeVersionKey, webRole.Startup.Task[0].Environment[0].name);
            Assert.AreEqual <string>(enableCacheCmdlet.CacheRuntimeVersion, webRole.Startup.Task[0].Environment[0].value);

            Assert.AreEqual <string>(Resources.EmulatedKey, webRole.Startup.Task[2].Environment[0].name);
            Assert.AreEqual <string>("/RoleEnvironment/Deployment/@emulated", webRole.Startup.Task[2].Environment[0].RoleInstanceValue.xpath);

            Assert.AreEqual <string>(Resources.CacheRuntimeUrl, webRole.Startup.Task[2].Environment[1].name);
            Assert.AreEqual <string>(TestResources.CacheRuntimeUrl, webRole.Startup.Task[2].Environment[1].value);
            Assert.AreEqual(1, webRole.Startup.Task.Count(t => t.commandLine.Equals(Resources.CacheStartupCommand)));


            AzureAssert.ScaffoldingExists(Path.Combine(files.RootPath, serviceName, webRoleName), Path.Combine(Resources.CacheScaffolding, Resources.WebRole));
            AzureAssert.StartupTaskExists(webRole.Startup.Task, Resources.CacheStartupCommand);

            AzureAssert.InternalEndpointExists(webRole.Endpoints.InternalEndpoint,
                                               new InternalEndpoint {
                name = Resources.MemcacheEndpointName, protocol = InternalProtocol.tcp, port = Resources.MemcacheEndpointPort
            });

            LocalStore localStore = new LocalStore
            {
                name = Resources.CacheDiagnosticStoreName,
                cleanOnRoleRecycle = false
            };

            AzureAssert.LocalResourcesLocalStoreExists(localStore, webRole.LocalResources);

            DefinitionConfigurationSetting diagnosticLevel = new DefinitionConfigurationSetting {
                name = Resources.CacheClientDiagnosticLevelAssemblyName
            };

            AzureAssert.ConfigurationSettingExist(diagnosticLevel, webRole.ConfigurationSettings);

            ConfigConfigurationSetting clientDiagnosticLevel = new ConfigConfigurationSetting {
                name = Resources.ClientDiagnosticLevelName, value = Resources.ClientDiagnosticLevelValue
            };

            AzureAssert.ConfigurationSettingExist(clientDiagnosticLevel, roleSettings.ConfigurationSettings);

            AssertWebConfig(string.Format(@"{0}\{1}\{2}", rootPath, webRoleName, Resources.WebCloudConfig));
            AssertWebConfig(string.Format(@"{0}\{1}\{2}", rootPath, webRoleName, Resources.WebConfigTemplateFileName));

            Assert.AreEqual <string>(expectedMessage, mockCommandRuntime.VerboseStream[0]);
            Assert.AreEqual <string>(webRoleName, (mockCommandRuntime.OutputPipeline[0] as PSObject).GetVariableValue <string>(Parameters.RoleName));
        }
        public void TestDeploymentSettingsTestWithFullServiceSettings()
        {
            string             label          = "MyLabel";
            string             deploymentName = service.ServiceName;
            ServiceSettings    fullSettings   = ServiceSettingsTestData.Instance.Data[ServiceSettingsState.Sample1];
            DeploymentSettings deploySettings = new DeploymentSettings(fullSettings, packagePath, configPath, label, deploymentName);

            AzureAssert.AreEqualDeploymentSettings(fullSettings, configPath, deploymentName, label, packagePath, "f62b1e05-af8f-4205-8f98-325079adc155", deploySettings);
        }
        public void AzureServiceAddNewNodeWebRoleTest()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                AzureService service = new AzureService(files.RootPath, serviceName, null);
                RoleInfo     webRole = service.AddWebRole(Resources.NodeScaffolding, "MyWebRole", 10);

                AzureAssert.AzureServiceExists(Path.Combine(files.RootPath, serviceName), Resources.GeneralScaffolding, serviceName, webRoles: new WebRoleInfo[] { (WebRoleInfo)webRole }, webScaff: Path.Combine(Resources.NodeScaffolding, Resources.WebRole), roles: new RoleInfo[] { webRole });
            }
        }
Beispiel #14
0
        public void AzureServiceAddNewNodeWorkerRoleTest()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                CloudServiceProject service    = new CloudServiceProject(files.RootPath, serviceName, null);
                RoleInfo            workerRole = service.AddWorkerRole(Test.Utilities.Common.Data.NodeWorkerRoleScaffoldingPath, "MyWorkerRole", 10);

                AzureAssert.AzureServiceExists(Path.Combine(files.RootPath, serviceName), Resources.GeneralScaffolding, serviceName, workerRoles: new WorkerRoleInfo[] { (WorkerRoleInfo)workerRole }, workerScaff: Path.Combine(Resources.NodeScaffolding, Resources.WorkerRole), roles: new RoleInfo[] { workerRole });
            }
        }
Beispiel #15
0
        public void AzureServiceAddNewPHPWorkerRoleTest()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                AzureService service    = new AzureService(files.RootPath, serviceName, null);
                RoleInfo     workerRole = service.AddWorkerRole(Data.PHPWorkerRoleScaffoldingPath, "MyWorkerRole", 10);

                AzureAssert.AzureServiceExists(Path.Combine(files.RootPath, serviceName), Resources.GeneralScaffolding, serviceName, workerRoles: new WorkerRoleInfo[] { (WorkerRoleInfo)workerRole }, workerScaff: Path.Combine(Resources.PHPScaffolding, Resources.WorkerRole), roles: new RoleInfo[] { workerRole });
            }
        }
Beispiel #16
0
        public void ServiceComponentsTest()
        {
            TestMockSupport.TestExecutionFolder = AppDomain.CurrentDomain.BaseDirectory;
            newServiceCmdlet.NewAzureServiceProcess(TestMockSupport.TestExecutionFolder, serviceName);
            ServiceComponents components = new ServiceComponents(
                new PowerShellProjectPathInfo(
                    Path.Combine(AppDomain.CurrentDomain.BaseDirectory, serviceName)));

            AzureAssert.AreEqualServiceComponents(components);
        }
        public void TestDeploymentSettingsTestWithDefaultServiceSettings()
        {
            string label          = "MyLabel";
            string deploymentName = service.ServiceName;

            settings.Subscription = "TestSubscription2";
            DeploymentSettings deploySettings = new DeploymentSettings(settings, packagePath, configPath, label, deploymentName);

            AzureAssert.AreEqualDeploymentSettings(settings, configPath, deploymentName, label, packagePath, "f62b1e05-af8f-4205-8f98-325079adc155", deploySettings);
        }
Beispiel #18
0
        public void AddAzureNodeWorkerRoleProcess()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                new NewAzureServiceProjectCommand().NewAzureServiceProcess(files.RootPath, "AzureService");
                new AddAzureNodeWorkerRoleCommand().AddAzureNodeWorkerRoleProcess("WorkerRole", 1, Path.Combine(files.RootPath, "AzureService"));

                AzureAssert.ScaffoldingExists(Path.Combine(files.RootPath, "AzureService", "WorkerRole"), Path.Combine(Resources.NodeScaffolding, Resources.WorkerRole));
            }
        }
Beispiel #19
0
        public void AddAzurePythonWebRoleProcess()
        {
            var pyInstall = AddAzureDjangoWebRoleCommand.FindPythonInterpreterPath();

            if (pyInstall == null)
            {
                Assert.Inconclusive("Python is not installed on this machine and therefore the Python tests cannot be run");
                return;
            }

            string stdOut, stdErr;

            ProcessHelper.StartAndWaitForProcess(
                new ProcessStartInfo(
                    Path.Combine(pyInstall, "python.exe"),
                    String.Format("-m django.bin.django-admin")
                    ),
                out stdOut,
                out stdErr
                );

            if (stdOut.IndexOf("django-admin.py") == -1)
            {
                Assert.Inconclusive("Django is not installed on this machine and therefore the Python tests cannot be run");
                return;
            }

            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                string roleName    = "WebRole1";
                string serviceName = "AzureService";
                string rootPath    = files.CreateNewService(serviceName);
                addPythonWebCmdlet = new AddAzureDjangoWebRoleCommand()
                {
                    RootPath = rootPath, CommandRuntime = mockCommandRuntime
                };
                addPythonWebCmdlet.CommandRuntime = mockCommandRuntime;
                string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreatePython, rootPath, roleName);
                mockCommandRuntime.ResetPipelines();

                addPythonWebCmdlet.ExecuteCmdlet();

                AzureAssert.ScaffoldingExists(Path.Combine(rootPath, roleName), Path.Combine(Resources.PythonScaffolding, Resources.WebRole));
                Assert.AreEqual <string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue <string>(Parameters.RoleName));
                Assert.AreEqual <string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]);
                Assert.IsTrue(Directory.Exists(Path.Combine(rootPath, roleName, roleName)));
                Assert.IsTrue(File.Exists(Path.Combine(rootPath, roleName, roleName, "manage.py")));
                Assert.IsTrue(Directory.Exists(Path.Combine(rootPath, roleName, roleName, roleName)));
                Assert.IsTrue(File.Exists(Path.Combine(rootPath, roleName, roleName, roleName, "__init__.py")));
                Assert.IsTrue(File.Exists(Path.Combine(rootPath, roleName, roleName, roleName, "settings.py")));
                Assert.IsTrue(File.Exists(Path.Combine(rootPath, roleName, roleName, roleName, "urls.py")));
                Assert.IsTrue(File.Exists(Path.Combine(rootPath, roleName, roleName, roleName, "wsgi.py")));
            }
        }
Beispiel #20
0
        public void CreateLocalPackageWithPHPWorkerRoleTest()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
                service.AddWorkerRole(Test.Utilities.Common.Data.PHPWorkerRoleScaffoldingPath);
                service.CreatePackage(DevEnv.Local);

                AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WorkerRole1\approot"), Path.Combine(Resources.PHPScaffolding, Resources.WorkerRole));
            }
        }
        public void NewAzureServiceProcessTest()
        {
            string serviceName = "AzureService";

            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                new NewAzureServiceCommand().NewAzureServiceProcess(files.RootPath, serviceName);

                AzureAssert.AzureServiceExists(files.RootPath, Resources.GeneralScaffolding, serviceName);
            }
        }
        public void CreateLocalPackageWithWorkerRoleTest()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                string       standardOutput;
                string       standardError;
                AzureService service = new AzureService(files.RootPath, serviceName, null);
                service.AddWorkerRole();
                service.CreatePackage(DevEnv.Local, out standardOutput, out standardError);

                AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WorkerRole1\approot"), Path.Combine(Resources.NodeScaffolding, Resources.WorkerRole));
            }
        }
        public void ImportAzurePublishSettingsProcessTests()
        {
            GlobalPathInfo globalPathInfo = new GlobalPathInfo(Data.AzureSdkAppDir);

            foreach (string filePath in Data.ValidPublishSettings)
            {
                new ImportAzurePublishSettingsCommand().ImportAzurePublishSettingsProcess(filePath, Data.AzureSdkAppDir);
                PublishData expectedPublishSettings = General.DeserializeXmlFile <PublishData>(filePath);
                PublishData actualPublishSettings   = General.DeserializeXmlFile <PublishData>(globalPathInfo.PublishSettings);
                string      thmbprint = actualPublishSettings.Items[0].ManagementCertificate;
                AzureAssert.AreEqualGlobalComponents(thmbprint, globalPathInfo, new ServiceSettings(), actualPublishSettings, new GlobalComponents(Data.AzureSdkAppDir));
            }
        }
        public void GlobalComponentsCreateNew()
        {
            foreach (string fileName in Data.ValidPublishSettings)
            {
                // Prepare
                GlobalComponents globalComponents        = GlobalComponents.CreateFromPublishSettings(Data.AzureAppDir, null, fileName);
                PublishData      expectedPublishSettings = General.DeserializeXmlFile <PublishData>(fileName);

                // Assert
                AzureAssert.AreEqualGlobalComponents(new GlobalPathInfo(Data.AzureAppDir), expectedPublishSettings, globalComponents);

                // Clean
                globalComponents.DeleteGlobalComponents();
            }
        }
Beispiel #25
0
 private static void AssertConfigExists(RoleSettings role, string connectionString = "")
 {
     AzureAssert.ConfigurationSettingExist(new ConfigConfigurationSetting {
         name = Resources.NamedCacheSettingName, value = Resources.NamedCacheSettingValue
     }, role.ConfigurationSettings);
     AzureAssert.ConfigurationSettingExist(new ConfigConfigurationSetting {
         name = Resources.DiagnosticLevelName, value = Resources.DiagnosticLevelValue
     }, role.ConfigurationSettings);
     AzureAssert.ConfigurationSettingExist(new ConfigConfigurationSetting {
         name = Resources.CachingCacheSizePercentageSettingName, value = string.Empty
     }, role.ConfigurationSettings);
     AzureAssert.ConfigurationSettingExist(new ConfigConfigurationSetting {
         name = Resources.CachingConfigStoreConnectionStringSettingName, value = connectionString
     }, role.ConfigurationSettings);
 }
Beispiel #26
0
        public void GlobalComponentsCreateNew()
        {
            foreach (string fileName in Data.ValidPublishSettings)
            {
                // Prepare
                GlobalComponents globalComponents        = new GlobalComponents(fileName, Data.AzureSdkAppDir);
                PublishData      actualPublishSettings   = General.DeserializeXmlFile <PublishData>(Path.Combine(Data.AzureSdkAppDir, Resources.PublishSettingsFileName));
                PublishData      expectedPublishSettings = General.DeserializeXmlFile <PublishData>(fileName);

                // Assert
                AzureAssert.AreEqualGlobalComponents(actualPublishSettings.Items[0].ManagementCertificate, new GlobalPathInfo(Data.AzureSdkAppDir), new ServiceSettings(), expectedPublishSettings, globalComponents);

                // Clean
                new RemoveAzurePublishSettingsCommand().RemovePublishSettingsProcess(Data.AzureSdkAppDir);
            }
        }
Beispiel #27
0
        public void GlobalSettingsManagerLoadExisting()
        {
            for (var i = 0; i < Data.ValidPublishSettings.Count; i++)
            {
                var publishSettingsFile = Data.ValidPublishSettings[i];

                // Prepare
                new ImportAzurePublishSettingsCommand().ImportSubscriptionFile(publishSettingsFile, null);
                GlobalSettingsManager globalSettingsManager   = GlobalSettingsManager.Load(GlobalPathInfo.GlobalSettingsDirectory);
                PublishData           actualPublishSettings   = General.DeserializeXmlFile <PublishData>(Path.Combine(GlobalPathInfo.GlobalSettingsDirectory, Resources.PublishSettingsFileName));
                PublishData           expectedPublishSettings = General.DeserializeXmlFile <PublishData>(publishSettingsFile);

                // Assert
                AzureAssert.AreEqualGlobalSettingsManager(new GlobalPathInfo(GlobalPathInfo.GlobalSettingsDirectory), expectedPublishSettings, globalSettingsManager);
            }
        }
Beispiel #28
0
        public void CreateLocalPackageWithOnePHPWebRoleTest()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                CloudServiceProject service     = new CloudServiceProject(files.RootPath, serviceName, null);
                RoleInfo            webRoleInfo = service.AddWebRole(Test.Utilities.Common.Data.PHPWebRoleScaffoldingPath);
                string logsDir        = Path.Combine(service.Paths.RootPath, webRoleInfo.Name, "server.js.logs");
                string logFile        = Path.Combine(logsDir, "0.txt");
                string targetLogsFile = Path.Combine(service.Paths.LocalPackage, "roles", webRoleInfo.Name, @"approot\server.js.logs\0.txt");
                files.CreateDirectory(logsDir);
                files.CreateEmptyFile(logFile);
                service.CreatePackage(DevEnv.Local);

                AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WebRole1\approot"), Path.Combine(Resources.PHPScaffolding, Resources.WebRole));
                Assert.True(File.Exists(targetLogsFile));
            }
        }
        public void AddAzureWorkerRoleProcess()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                string roleName = "WorkerRole1";
                string serviceName = "AzureService";
                string rootPath = files.CreateNewService(serviceName);
                string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreate, rootPath, roleName);
                TestMockSupport.TestExecutionFolder = rootPath;
                addWorkerCmdlet = new AddAzureWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = roleName };

                addWorkerCmdlet.ExecuteCmdlet();

                AzureAssert.ScaffoldingExists(Path.Combine(rootPath, roleName), Path.Combine(Resources.GeneralScaffolding, Resources.WorkerRole));
                Assert.Equal<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue<string>(Parameters.RoleName));
                Assert.Equal<string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]);
            }
        }
        public void CreateLocalPackageWithOneWebRoleTest()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                string       standardOutput;
                string       standardError;
                AzureService service        = new AzureService(files.RootPath, serviceName, null);
                RoleInfo     webRoleInfo    = service.AddWebRole();
                string       logsDir        = Path.Combine(service.Paths.RootPath, webRoleInfo.Name, "server.js.logs");
                string       logFile        = Path.Combine(logsDir, "0.txt");
                string       targetLogsFile = Path.Combine(service.Paths.LocalPackage, "roles", webRoleInfo.Name, @"approot\server.js.logs\0.txt");
                files.CreateDirectory(logsDir);
                files.CreateEmptyFile(logFile);
                service.CreatePackage(DevEnv.Local, out standardOutput, out standardError);

                AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WebRole1\approot"), Path.Combine(Resources.NodeScaffolding, Resources.WebRole));
                Assert.IsTrue(File.Exists(targetLogsFile));
            }
        }