AddWorkerRole() public method

public AddWorkerRole ( string Scaffolding, string name = null, int instanceCount = 1 ) : RoleInfo
Scaffolding string
name string
instanceCount int
return RoleInfo
Exemplo n.º 1
0
        public void CreateLocalPackageWithMultipleRoles()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                string standardOutput;
                string standardError;
                AzureService service = new AzureService(files.RootPath, serviceName, null);
                service.AddWorkerRole(Resources.NodeScaffolding);
                service.AddWebRole(Resources.NodeScaffolding);
                service.AddWorkerRole(Resources.PHPScaffolding);
                service.AddWebRole(Resources.PHPScaffolding);
                service.CreatePackage(DevEnv.Local, out standardOutput, out standardError);

                AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WorkerRole1\approot"), Path.Combine(Resources.NodeScaffolding, Resources.WorkerRole));
                AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WebRole1\approot"), Path.Combine(Resources.NodeScaffolding, Resources.WebRole));
                AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WorkerRole2\approot"), Path.Combine(Resources.PHPScaffolding, Resources.WorkerRole));
                AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WebRole2\approot"), Path.Combine(Resources.PHPScaffolding, Resources.WebRole));
            }
        }
 public void GetNextPortNodeWebRoleNull()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         int expectedPort = int.Parse(Resources.DefaultPort);
         AzureService service = new AzureService(files.RootPath, serviceName, null);
         service.AddWorkerRole(Resources.NodeScaffolding);
         service = new AzureService(service.Paths.RootPath, null);
         int nextPort = service.Components.GetNextPort();
         Assert.AreEqual<int>(expectedPort, nextPort);
     }
 }
Exemplo n.º 3
0
        internal string AddAzureNodeWorkerRoleProcess(string workerRoleName, int instances, string rootPath)
        {
            string result;
            AzureService service = new AzureService(rootPath, null);
            RoleInfo workerRole = service.AddWorkerRole(Resources.NodeScaffolding, workerRoleName, instances);
            try
            {
                service.ChangeRolePermissions(workerRole);
            }
            catch (UnauthorizedAccessException)
            {
                SafeWriteObject(Resources.AddRoleMessageInsufficientPermissions);
                SafeWriteObject(Environment.NewLine);
            }

            result = string.Format(Resources.AddRoleMessageCreate, rootPath, workerRole.Name);
            return result;
        }
        public void SetAzureInstancesProcessTestsPHPRoleNameDoesNotExistServiceContainsWorkerRoleFail()
        {
            string roleName = "WorkerRole1";
            string invalidRoleName = "foo";

            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                AzureService service = new AzureService(files.RootPath, serviceName, null);
                service.AddWorkerRole(Data.PHPWorkerRoleScaffoldingPath, roleName, 1);
                Testing.AssertThrows<ArgumentException>(() => service.SetRoleInstances(service.Paths, invalidRoleName, 10), string.Format(Resources.RoleNotFoundMessage, invalidRoleName));
            }
        }
 public void GetNextPortNullPHPWebEndpointAndWorkerRole()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         int expectedPort = int.Parse(Resources.DefaultPort);
         AzureService service = new AzureService(files.RootPath, serviceName, null);
         service.AddWebRole(Resources.PHPScaffolding);
         service.Components.Definition.WebRole.ToList().ForEach(wr => wr.Endpoints = null);
         service.AddWorkerRole(Resources.PHPScaffolding);
         service = new AzureService(service.Paths.RootPath, null);
         int nextPort = service.Components.GetNextPort();
         Assert.AreEqual<int>(expectedPort, nextPort);
     }
 }
Exemplo n.º 6
0
        public override void ExecuteCmdlet()
        {
            RootPath = RootPath ?? General.GetServiceRootPath(CurrentPath());
            AzureService service = new AzureService(RootPath, null);
            RoleInfo roleInfo = null;

            if (isWebRole)
            {
                roleInfo = service.AddWebRole(Scaffolding, Name, Instances);
            }
            else
            {
                roleInfo = service.AddWorkerRole(Scaffolding, Name, Instances);
            }

            OnProcessing(roleInfo);

            try
            {
                service.ChangeRolePermissions(roleInfo);
                SafeWriteOutputPSObject(typeof(RoleSettings).FullName, Parameters.RoleName, roleInfo.Name);
                WriteVerbose(string.Format(successMessage, RootPath, roleInfo.Name));
            }
            catch (UnauthorizedAccessException)
            {
                WriteWarning(Resources.AddRoleMessageInsufficientPermissions);
            }
        }
Exemplo n.º 7
0
        public void AzureServiceAddNewPHPWorkerRoleTest()
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                AzureService service = new AzureService(files.RootPath, serviceName, null);
                RoleInfo workerRole = service.AddWorkerRole(Resources.PHPScaffolding, "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 });
            }
        }