Beispiel #1
0
        public void Setup()
        {
            var app = new OnlyIfTestApp();

            var config = new ConDepEnvConfig {
                EnvironmentName = "bogusEnv"
            };
            var server = new ServerConfig {
                Name = "bogusHost"
            };

            config.Servers = new[] { server };

            _sequenceManager = new ExecutionSequenceManager(config.Servers, new DefaultLoadBalancer());

            var settings = new ConDepSettings {
                Config = config
            };

            var local = new LocalOperationsBuilder(_sequenceManager.NewLocalSequence("Test"));

            app.Configure(local, settings);

            _serverInfo = new ServerInfo {
                OperatingSystem = new OperatingSystemInfo {
                    Name = "Windows Server 2012"
                }
            };
        }
Beispiel #2
0
        public void TestThatEmptyPowerShellScriptFoldersIsNotNullAndEmpty()
        {
            var config = new ConDepEnvConfig();

            Assert.That(config.PowerShellScriptFolders, Is.Not.Null);
            Assert.That(config.PowerShellScriptFolders.Length, Is.EqualTo(0));
        }
Beispiel #3
0
        public void TestThatExecutionSequenceIsValid()
        {
            var config = new ConDepEnvConfig {
                EnvironmentName = "bogusEnv"
            };
            var server = new ServerConfig {
                Name = "jat-web03"
            };

            config.Servers = new[] { server };

            var sequenceManager = new ExecutionSequenceManager(config.Servers, new DefaultLoadBalancer());

            var settings = new ConDepSettings();

            settings.Config = config;

            var local = new LocalOperationsBuilder(sequenceManager.NewLocalSequence("Test"));

            //Configure.LocalOperations = local;
            _app.Configure(local, settings);

            var notification = new Notification();

            Assert.That(sequenceManager.IsValid(notification));
        }
Beispiel #4
0
        public void Setup()
        {
            var memStream      = new MemoryStream(Encoding.UTF8.GetBytes(_json));
            var tiersMemStream = new MemoryStream(Encoding.UTF8.GetBytes(_tiersJson));

            var parser = new EnvConfigParser();

            _config      = parser.GetTypedEnvConfig(memStream, null);
            _tiersConfig = parser.GetTypedEnvConfig(tiersMemStream, null);
        }
Beispiel #5
0
        public void Setup()
        {
            var memStream      = new MemoryStream(Encoding.UTF8.GetBytes(_json));
            var tiersMemStream = new MemoryStream(Encoding.UTF8.GetBytes(_tiersJson));

            _cryptoKey = JsonPasswordCrypto.GenerateKey(256);
            var parser = new EnvConfigParser(new ConfigJsonSerializer(new JsonConfigCrypto(_cryptoKey)));

            _config      = parser.GetTypedEnvConfig(memStream, null);
            _tiersConfig = parser.GetTypedEnvConfig(tiersMemStream, null);
        }
        private void SaveExecutionPathScriptsToFolder(string localTargetPath, ConDepEnvConfig config)
        {
            var currDir = Directory.GetCurrentDirectory();

            foreach (var psDir in config.PowerShellScriptFolders)
            {
                var absPath = Path.Combine(currDir, psDir);
                if (!Directory.Exists(absPath))
                {
                    throw new DirectoryNotFoundException(absPath);
                }

                var dirInfo = new DirectoryInfo(absPath);
                var files   = dirInfo.GetFiles("*.ps1", SearchOption.TopDirectoryOnly);
                foreach (var file in files.Select(x => x.FullName))
                {
                    File.Copy(file, Path.Combine(localTargetPath, Path.GetFileName(file)));
                }
            }
        }
Beispiel #7
0
        public ConDepEnvConfig GetTypedEnvConfig(Stream stream)
        {
            ConDepEnvConfig config = _configSerializer.DeSerialize(stream);

            if (config.Servers != null && config.Tiers != null)
            {
                throw new ConDepConfigurationException(
                          "You cannot define both Tiers and Servers at the same level. Either you use Tiers and define servers for each tier or you use Servers without Tiers. Servers without Tiers would be the same as having just one Tier.");
            }

            if (config.Servers == null)
            {
                config.Servers = new List <ServerConfig>();
            }

            if (config.Node.Port == null)
            {
                config.Node.Port = 4444;
            }
            if (config.Node.TimeoutInSeconds == null)
            {
                config.Node.TimeoutInSeconds = 100;
            }

            if (config.PowerShell.HttpPort == null)
            {
                config.PowerShell.HttpPort = 5985;
            }
            if (config.PowerShell.HttpsPort == null)
            {
                config.PowerShell.HttpsPort = 5986;
            }

            foreach (var server in config.UsingTiers ? config.Tiers.SelectMany(x => x.Servers) : config.Servers)
            {
                if (server.Node == null)
                {
                    server.Node = config.Node;
                }

                if (server.PowerShell == null)
                {
                    server.PowerShell = config.PowerShell;
                }

                if (!server.DeploymentUser.IsDefined())
                {
                    server.DeploymentUser = config.DeploymentUser;
                }

                if (server.Node.Port == null)
                {
                    server.Node.Port = config.Node.Port;
                }
                if (server.Node.TimeoutInSeconds == null)
                {
                    server.Node.TimeoutInSeconds = config.Node.TimeoutInSeconds;
                }

                if (server.PowerShell.HttpPort == null)
                {
                    server.PowerShell.HttpPort = config.PowerShell.HttpPort;
                }
                if (server.PowerShell.HttpsPort == null)
                {
                    server.PowerShell.HttpsPort = config.PowerShell.HttpsPort;
                }
            }
            return(config);
        }