public void AzureServiceAddExistingRoleFail()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         AzureService service = new AzureService(files.RootPath, serviceName, null);
         service.AddWebRole("WebRole");
         Testing.AssertThrows<ArgumentException>(() => service.AddWebRole("WebRole"), string.Format(Resources.AddRoleMessageRoleExists, "WebRole"));
     }
 }
 public void GetNextPortAddingThirdEndpoint()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         int expectedPort = int.Parse(Resources.DefaultPort) + 1;
         AzureService service = new AzureService(files.RootPath, serviceName, null);
         service.AddWebRole();
         service.AddWebRole();
         service = new AzureServiceWrapper(service.Paths.RootPath, null);
         int nextPort = service.Components.GetNextPort();
         Assert.AreEqual<int>(expectedPort, nextPort);
     }
 }
        public void AzureServiceAddNewWebRoleTest()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                AzureService service = new AzureService(files.RootPath, serviceName, null);
                RoleInfo webRole = service.AddWebRole("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 });
            }
        }
Example #4
0
        public void CreateLocalPackageWithOneWebRoleTest()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                string standardOutput;
                string standardError;
                AzureService service = new AzureService(files.RootPath, serviceName, null);
                service.AddWebRole();
                service.CreatePackage(DevEnv.Local, out standardOutput, out standardError);

                AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WebRole1\approot"), Path.Combine(Resources.NodeScaffolding, Resources.WebRole));
            }
        }
 public void GetNextPortNullWebEndpointAndNullWorkerRole()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         int expectedPort = int.Parse(Resources.DefaultWebPort);
         AzureService service = new AzureService(files.RootPath, serviceName, null);
         service.AddWebRole();
         service = new AzureService(service.Paths.RootPath, null);
         service.Components.Definition.WebRole.ToList().ForEach(wr => wr.Endpoints = null);
         int nextPort = service.Components.GetNextPort();
         Assert.AreEqual<int>(expectedPort, nextPort);
     }
 }
        public void SetAzureInstancesProcessTests()
        {
            int newRoleInstances = 10;

            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                AzureService service = new AzureService(files.RootPath, serviceName, null);
                service.AddWebRole();
                new SetAzureInstancesCommand().SetAzureInstancesProcess("WebRole1", newRoleInstances, service.Paths.RootPath);
                service = new AzureService(service.Paths.RootPath, null);

                Assert.AreEqual<int>(newRoleInstances, service.Components.CloudConfig.Role[0].Instances.count);
                Assert.AreEqual<int>(newRoleInstances, service.Components.LocalConfig.Role[0].Instances.count);
            }
        }
        internal string AddAzureNodeWebRoleProcess(string webRoleName, int instances, string rootPath)
        {
            string result;
            AzureService service = new AzureService(rootPath, null);
            RoleInfo webRole = service.AddWebRole(webRoleName, instances);
            try
            {
                service.ChangeRolePermissions(webRole);
            }
            catch (UnauthorizedAccessException)
            {
                SafeWriteObject(Resources.AddRoleMessageInsufficientPermissions);
            }

            result = string.Format(Resources.AddRoleMessageCreate, rootPath, webRole.Name);
            return result;
        }
        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));
            }
        }
 public void GetNextPortWithEmptyPortIndpoints()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         int expectedPort = int.Parse(Resources.DefaultPort);
         AzureService service = new AzureService(files.RootPath, serviceName, null);
         service.AddWebRole();
         service.Components.Definition.WebRole[0].Endpoints.InputEndpoint = null;
         service.Components.Save(service.Paths);
         service.AddWebRole();
         service = new AzureServiceWrapper(service.Paths.RootPath, null);
         int nextPort = service.Components.GetNextPort();
         Assert.AreEqual<int>(expectedPort, nextPort);
     }
 }
        public void SetRoleInstancesTest()
        {
            int newInstances = 10;

            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                AzureService service = new AzureService(files.RootPath, serviceName, null);
                service.AddWebRole("WebRole", 1);
                service.SetRoleInstances(service.Paths, "WebRole", newInstances);
                Assert.AreEqual<int>(service.Components.CloudConfig.Role[0].Instances.count, newInstances);
                Assert.AreEqual<int>(service.Components.LocalConfig.Role[0].Instances.count, newInstances);
            }
        }