Ejemplo n.º 1
0
        public RoleInfo AddDjangoWebRole(string name = null, int instanceCount = 1)
        {
            name = GetRoleName(name, Resources.WebRole, Components.Definition.WebRole == null ? new string[0] : Components.Definition.WebRole.Select(wr => wr.name.ToLower()));
            WebRoleInfo role = new WebRoleInfo(name, instanceCount);

            AddPythonRoleCore(role, RoleType.WebRole);

            return(role);
        }
Ejemplo n.º 2
0
        public RoleInfo AddWebRole(string scaffolding, string name = null, int instanceCount = 1)
        {
            name = GetRoleName(name, Resources.WebRole, Components.Definition.WebRole == null ? new String[0] : Components.Definition.WebRole.Select(wr => wr.name.ToLower()));
            WebRoleInfo role = new WebRoleInfo(name, instanceCount);

            AddRoleCore(scaffolding, role);

            return(role);
        }
Ejemplo n.º 3
0
        public RoleInfo AddWebRole(
            string scaffolding,
            string name = null,
            int instanceCount = 1)
        {
            name = GetRoleName(name, Resources.WebRole, Components.Definition.WebRole == null ?
                new string[0] :
                Components.Definition.WebRole.Select(wr => wr.name.ToLower()));

            WebRoleInfo role = new WebRoleInfo(name, instanceCount);

            AddRoleCore(scaffolding, role);

            return role;
        }
Ejemplo n.º 4
0
        public RoleInfo AddDjangoWebRole(string name = null, int instanceCount = 1)
        {
            name = GetRoleName(name, Resources.WebRole, Components.Definition.WebRole == null ? new String[0] : Components.Definition.WebRole.Select(wr => wr.name.ToLower()));
            WebRoleInfo role = new WebRoleInfo(name, instanceCount);
            AddPythonRoleCore(role, RoleType.WebRole);

            return role;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Validates that given service definition is valid for a service. Validation steps:
        /// 1. Validates name element matches serviceName
        /// 2. Validates web role element has all webRoles with same configuration.
        /// 3. Validates worker role element has all workerRoles with same configuration.
        /// </summary>
        /// <param name="actual">Service definition to be checked</param>
        /// <param name="serviceName">New created service name</param>
        public static void IsValidServiceDefinition(ServiceDefinition actual, string serviceName, WebRoleInfo[] webRoles = null, WorkerRoleInfo[] workerRoles = null)
        {
            Assert.AreEqual<string>(serviceName, actual.name);

            if (webRoles != null)
            {
                Assert.AreEqual<int>(webRoles.Length, actual.WebRole.Length);
                int length = webRoles.Length;

                for (int i = 0; i < length; i++)
                {
                    Assert.IsTrue(webRoles[i].Equals(actual.WebRole[i]));
                }
            }
            else
            {
                Assert.IsNull(actual.WebRole);
            }

            if (workerRoles != null)
            {
                Assert.AreEqual<int>(workerRoles.Length, actual.WorkerRole.Length);
                int length = workerRoles.Length;

                for (int i = 0; i < length; i++)
                {
                    Assert.IsTrue(workerRoles[i].Equals(actual.WorkerRole[i]));
                }
            }
            else
            {
                Assert.IsNull(actual.WorkerRole);
            }
        }
Ejemplo n.º 6
0
        public static void AzureServiceExists(string serviceRootPath, string scaffoldFilePath, string serviceName, ServiceSettings settings = null, WebRoleInfo[] webRoles = null, WorkerRoleInfo[] workerRoles = null, string webScaff = null, string workerScaff = null, RoleInfo[] roles = null)
        {
            ServiceComponents components = new Microsoft.WindowsAzure.Management.Utilities.CloudService.ServiceComponents(new Microsoft.WindowsAzure.Management.Utilities.CloudService.ServicePathInfo(serviceRootPath));

            ScaffoldingExists(serviceRootPath, scaffoldFilePath);

            if (webRoles != null)
            {
                for (int i = 0; i < webRoles.Length; i++)
                {
                    ScaffoldingExists(Path.Combine(serviceRootPath, webRoles[i].Name), webScaff);
                }
            }

            if (workerRoles != null)
            {
                for (int i = 0; i < workerRoles.Length; i++)
                {
                    ScaffoldingExists(Path.Combine(serviceRootPath, workerRoles[i].Name), workerScaff);
                }
            }

            AreEqualServiceConfiguration(components.LocalConfig, serviceName, roles);
            AreEqualServiceConfiguration(components.CloudConfig, serviceName, roles);
            IsValidServiceDefinition(components.Definition, serviceName, webRoles, workerRoles);
            AreEqualServiceSettings(settings ?? new ServiceSettings(), components.Settings);
        }
Ejemplo n.º 7
0
        private void AddPHPRoleTest(int webRole, int workerRole, int order = 0)
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                AzureServiceWrapper wrappedService = new AzureServiceWrapper(files.RootPath, serviceName, null);
                CloudServiceProject service = new CloudServiceProject(Path.Combine(files.RootPath, serviceName), null);

                WebRoleInfo[] webRoles = null;
                if (webRole > 0)
                {
                    webRoles = new WebRoleInfo[webRole];
                    for (int i = 0; i < webRoles.Length; i++)
                    {
                        webRoles[i] = new WebRoleInfo(string.Format("{0}{1}", Resources.WebRole, i + 1), 1);
                    }
                }

                WorkerRoleInfo[] workerRoles = null;
                if (workerRole > 0)
                {
                    workerRoles = new WorkerRoleInfo[workerRole];
                    for (int i = 0; i < workerRoles.Length; i++)
                    {
                        workerRoles[i] = new WorkerRoleInfo(string.Format("{0}{1}", Resources.WorkerRole, i + 1), 1);
                    }
                }

                RoleInfo[] roles = (webRole + workerRole > 0) ? new RoleInfo[webRole + workerRole] : null;
                if (order == 0)
                {
                    for (int i = 0, w = 0, wo = 0; i < webRole + workerRole; )
                    {
                        if (w++ < webRole) roles[i++] = wrappedService.AddWebRole(Data.PHPWebRoleScaffoldingPath);
                        if (wo++ < workerRole) roles[i++] = wrappedService.AddWorkerRole(Data.PHPWorkerRoleScaffoldingPath);
                    }
                }
                else if (order == 1)
                {
                    for (int i = 0, w = 0, wo = 0; i < webRole + workerRole; )
                    {
                        if (wo++ < workerRole) roles[i++] = wrappedService.AddWorkerRole(Data.PHPWorkerRoleScaffoldingPath);
                        if (w++ < webRole) roles[i++] = wrappedService.AddWebRole(Data.PHPWebRoleScaffoldingPath);
                    }
                }
                else if (order == 2)
                {
                    wrappedService.AddRole(Data.PHPWebRoleScaffoldingPath, Data.PHPWorkerRoleScaffoldingPath, webRole, workerRole);
                    webRoles.CopyTo(roles, 0);
                    Array.Copy(workerRoles, 0, roles, webRole, workerRoles.Length);
                }
                else if (order == 3)
                {
                    wrappedService.AddRole(Data.PHPWebRoleScaffoldingPath, Data.PHPWorkerRoleScaffoldingPath, 0, workerRole);
                    workerRoles.CopyTo(roles, 0);
                    wrappedService.AddRole(Data.PHPWebRoleScaffoldingPath, Data.PHPWorkerRoleScaffoldingPath, webRole, 0);
                    Array.Copy(webRoles, 0, roles, workerRole, webRoles.Length);
                }
                else
                {
                    throw new ArgumentException("value for order parameter is unknown");
                }

                AzureAssert.AzureServiceExists(Path.Combine(files.RootPath, serviceName), Resources.GeneralScaffolding, serviceName, webRoles: webRoles, workerRoles: workerRoles, webScaff: Data.PHPWebRoleScaffoldingPath, workerScaff: Data.PHPWorkerRoleScaffoldingPath, roles: roles);
            }
        }