コード例 #1
0
        public void TC003_TestDrainUpdate()
        {
            if (File.Exists("Jobs\\win_dea\\drain.bat"))
            {
                File.Delete("Jobs\\win_dea\\drain.bat");
            }

            File.Move("Jobs\\win_dea\\drain_update.bat", "Jobs\\win_dea\\drain.bat");

            //Arrange
            string fileContent = File.ReadAllText("settings.json");

            Config.Setup(JsonConvert.DeserializeObject(fileContent), false);
            string  argsString = "[\"update\",{\"deployment\":\"uhuru-cf-mitza\",\"release\":{\"name\":\"uhuru-cf\",\"version\":\"86.11-dev\"},\"job\":{\"name\":\"win_dea\",\"release\":\"uhuru-cf\",\"template\":\"win_dea\",\"version\":\"0.2-dev\",\"sha1\":\"cea000d7e5611f3fff6ddbf46163b6a4b025664b\",\"blobstore_id\":\"c9034ac9-ffc1-4aff-b17a-9be8533a6bfa\"},\"index\":0,\"networks\":{\"default\":{\"ip\":\"10.0.3.137\",\"netmask\":\"255.255.0.0\",\"cloud_properties\":{\"name\":\"VM Network\"},\"default\":[\"dns\",\"gateway\"],\"dns\":[\"10.0.0.10\",\"8.8.8.8\"],\"gateway\":\"10.0.0.1\"}},\"resource_pool\":{\"name\":\"windowspool\",\"cloud_properties\":{\"ram\":1000,\"cpu\":1,\"disk\":10192},\"stemcell\":{\"name\":\"test-stemcell\",\"version\":\"0.1.4\"}},\"packages\":{\"win_dea1\":{\"name\":\"win_dea\",\"version\":\"0.1-dev.1\",\"sha1\":\"8a90c0c416601e90bbe6a177d79d1efc2e47d526\",\"blobstore_id\":\"ba697254-60d5-4360-816d-e4dd5d3b8d02\"}},\"persistent_disk\":0,\"configuration_hash\":\"f7452dda13a19bc46a15d725e0151007ae194e2b\",\"properties\":{\"domain\":\"vcap.me\",\"env\":{},\"networks\":{\"apps\":\"default\",\"management\":\"default\"},\"nats\":{\"user\":\"nats\",\"password\":\"nats\",\"address\":\"10.0.3.136\",\"port\":4222},\"ccdb\":{\"user\":\"ccadmin\",\"password\":\"ccadmin\",\"address\":\"10.0.3.136\",\"port\":5524,\"dbname\":\"appcloud\",\"databases\":[{\"tag\":\"cc\",\"name\":\"appcloud\"}],\"roles\":[{\"tag\":\"admin\",\"name\":\"ccadmin\",\"password\":\"ccadmin\"}]},\"cc\":{\"srv_api_uri\":\"http://api.vcap.me\",\"password\":\"aaauuLaap44jadlas2l312lk\",\"token\":\"aaaf4eaa8c1758f66d5cb7adcb24adb9d7\",\"use_nginx\":false,\"allow_registration\":true,\"uaa\":{\"enabled\":false,\"resource_id\":\"cloud_controller\",\"client_secret\":\"aaaNxRJcx6cpv\"},\"admins\":[\"[email protected]\"]},\"router\":{\"status\":{\"port\":8080,\"user\":\"vcap\",\"password\":\"vcap\"}},\"dashboard\":{\"users\":[[\"dash\",\"admin\"]]},\"dea\":{\"max_memory\":4096},\"nfs_server\":{\"address\":\"10.0.3.136\",\"network\":\"10.0.0.0/16\"},\"opentsdb\":{\"address\":\"10.0.3.136\",\"port\":4242},\"service_plans\":{\"mysql\":{\"free\":{\"job_management\":{\"high_water\":1400,\"low_water\":100},\"configuration\":{\"allow_over_provisioning\":true,\"capacity\":200,\"max_db_size\":128,\"max_long_query\":3,\"max_long_tx\":0,\"max_clients\":20}}},\"postgresql\":{\"free\":{\"job_management\":{\"high_water\":1400,\"low_water\":100},\"configuration\":{\"capacity\":200,\"max_db_size\":128,\"max_long_query\":3,\"max_long_tx\":30,\"max_clients\":20}}},\"mongodb\":{\"free\":{\"job_management\":{\"high_water\":3000,\"low_water\":100},\"configuration\":{\"allow_over_provisioning\":true,\"capacity\":200,\"quota_files\":4,\"max_clients\":500}}},\"redis\":{\"free\":{\"job_management\":{\"high_water\":1400,\"low_water\":100},\"configuration\":{\"capacity\":200,\"max_memory\":16,\"max_swap\":32,\"max_clients\":500}}},\"rabbit\":{\"free\":{\"job_management\":{\"low_water\":100,\"high_water\":1400},\"configuration\":{\"max_memory_factor\":0.5,\"max_clients\":512,\"capacity\":200}}}},\"mysql_gateway\":{\"check_orphan_interval\":7200,\"token\":\"0xfeedface\"},\"mysql_node\":{\"production\":true,\"password\":\"aaa13djkas\"},\"redis_gateway\":{\"token\":\"0xfeedface\",\"check_orphan_interval\":7200},\"redis_node\":{\"command_rename_prefix\":\"sample\"},\"mongodb_gateway\":{\"check_orphan_interval\":7200,\"token\":\"0xfeedface\"},\"mongodb_node\":{},\"uhurufs_gateway\":{\"check_orphan_interval\":7200,\"token\":\"0xfeedface\"},\"uhurufs_node\":{\"statusport\":12345,\"basedir\":\"c:\\\\vcap\\\\store\\\\uhurufs\",\"capacity\":200},\"rabbit_gateway\":{\"token\":\"AAA430A8BAED490B1240338DA34B10D\"},\"rabbit_node\":{},\"postgresql_gateway\":{\"check_orphan_interval\":7200,\"token\":\"aaaeAh4BXFBXwLrrWJCpQTfeDnaCn7m\"},\"postgresql_node\":{\"production\":true},\"uaa\":{},\"win_dea\":{\"localroute\":\"10.0.3.30\",\"fillerport\":12345}}}]";
            dynamic args       = JsonConvert.DeserializeObject(argsString);

            //ConfigBlobStore
            Config.Configure         = true;
            Config.BlobstoreProvider = Config.Settings["blobstore"]["provider"].Value;
            Config.BlobstoreOptions  = Config.Settings["blobstore"]["options"];
            Config.Nats = new NatsClient.Reactor();
            Uri natsUri = new Uri(Config.MessageBus);

            Config.Nats.Start(natsUri);
            Monit.GetInstance().Start();

            //Act
            Drain  drain       = new Drain();
            object drainResult = drain.Process(args);

            //Assert
            Assert.AreEqual("0", drainResult.ToString());
        }
コード例 #2
0
        public void TC001_TestDrainStatus()
        {
            if (File.Exists("Jobs\\win_dea\\drain.bat"))
            {
                File.Delete("Jobs\\win_dea\\drain.bat");
            }

            File.Move("Jobs\\win_dea\\drain_status.bat", "Jobs\\win_dea\\drain.bat");
            //Arrange
            string fileContent = File.ReadAllText("settings.json");

            Config.Setup(JsonConvert.DeserializeObject(fileContent), false);
            string  argsString = "[\"status\"]";
            dynamic args       = JsonConvert.DeserializeObject(argsString);

            //ConfigBlobStore
            Config.Configure         = true;
            Config.BlobstoreProvider = Config.Settings["blobstore"]["provider"].Value;
            Config.BlobstoreOptions  = Config.Settings["blobstore"]["options"];
            Monit.GetInstance().Start();

            //Act
            Drain  drain       = new Drain();
            object drainResult = drain.Process(args);

            //Assert
            Assert.AreEqual("0", drainResult.ToString());
        }
コード例 #3
0
        public void TC002_TestDrainShutdown()
        {
            if (File.Exists("Jobs\\win_dea\\drain.bat"))
            {
                File.Delete("Jobs\\win_dea\\drain.bat");
            }

            File.Move("Jobs\\win_dea\\drain_shutdown.bat", "Jobs\\win_dea\\drain.bat");
            //Arrange
            string fileContent = File.ReadAllText("settings.json");

            Config.Setup(JsonConvert.DeserializeObject(fileContent), false);
            string  argsString = "[\"shutdown\"]";
            dynamic args       = JsonConvert.DeserializeObject(argsString);

            //ConfigBlobStore
            Config.Configure         = true;
            Config.BlobstoreProvider = Config.Settings["blobstore"]["provider"].Value;
            Config.BlobstoreOptions  = Config.Settings["blobstore"]["options"];
            Config.Nats = new NatsClient.Reactor();
            Uri natsUri = new Uri(Config.MessageBus);

            Config.Nats.Start(natsUri);
            Monit.GetInstance().Start();

            //Act
            Drain  drain       = new Drain();
            object drainResult = drain.Process(args);

            //Assert
            Assert.AreEqual(drainResult.ToString(), "0");
        }
コード例 #4
0
ファイル: Prepare.cs プロジェクト: mrdavidlaing/bosh-dotnet
        public object Process(dynamic args)
        {
            Monit.GetInstance().StopServices();

            dynamic spec;

            if (args.GetType().Name == "JObject")
            {
                spec = args;
            }
            else
            {
                spec = args[0];
            }

            Plan plan = new Plan(spec);

            foreach (Job job in plan.Jobs)
            {
                job.PrepareForInstall();
            }
            foreach (Package package in plan.Packages)
            {
                package.PrepareForInstall();
            }

            return(new object());
        }
コード例 #5
0
        /// <summary>
        /// Applies the plan.
        /// </summary>
        /// <returns></returns>
        private dynamic ApplyPlan()
        {
            Logger.Info("Applying : " + newSpec.ToString());

            if (oldPlan.Deployment.Value != string.Empty && oldPlan.Deployment.Value != newPlan.Deployment.Value)
            {
                MessageHandlerException exception = new MessageHandlerException(string.Format("attempt to apply {0} to {1}", oldPlan.Deployment.Value, newPlan.Deployment.Value));
                Logger.Error(exception.Message);
                throw exception;
            }

            if (newPlan.Configured)
            {
                try
                {
                    Monit.GetInstance().StopServices();
                    // TODO make sure processes have exited, even if windows reports services as stopped
                    Thread.Sleep(10000);
                    ApplyJob();
                    ApplyPackage();
                    ConfigureJob();
                }
                catch (Exception ex)
                {
                    MessageHandlerException exception = new MessageHandlerException(ex.Message, ex);
                    throw exception;
                }
            }
            Config.State.Write(newSpec);
            return(newSpec);
        }
コード例 #6
0
ファイル: Stop.cs プロジェクト: mrdavidlaing/bosh-dotnet
 /// <summary>
 /// Processes the specified args.
 /// </summary>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public object Process(dynamic args)
 {
     try
     {
         Monit.GetInstance().StopServices();
         return("stopped");
     }
     catch (Exception e)
     {
         throw new MessageHandlerException(String.Format(CultureInfo.InvariantCulture, "Cannot stop job: {0}", e.ToString()));
     }
 }
コード例 #7
0
ファイル: MonitTest.cs プロジェクト: mrdavidlaing/bosh-dotnet
        public void TC002_TestGetVitals()
        {
            //Arrange
            Monit monit = Monit.GetInstance(@"Monit");

            //Act
            Vitals vitals = monit.GetVitals;

            //Assert
            Assert.IsNotNull(vitals.CPU);
            Assert.IsNotNull(vitals.CPU.Sys);
            Assert.IsNotNull(vitals.Disk);
            Assert.IsNotNull(vitals.Load);
            Assert.IsNotNull(vitals.Memory);
        }
コード例 #8
0
        [Ignore] // This test is used for debugging
        public void TC001_TestHandler()
        {
            //Arrange
            string fileContent = File.ReadAllText(configFile);

            Config.Setup(JsonConvert.DeserializeObject(fileContent), false);

            //ConfigBlobStore
            Config.Configure         = true;
            Config.BlobstoreProvider = Config.Settings["blobstore"]["provider"].Value;
            Config.BlobstoreOptions  = Config.Settings["blobstore"]["options"];
            Monit.GetInstance().Start();
            //Act
            Handler.Start();
            while (true)
            {
                Thread.Sleep(1000);
            }
        }
コード例 #9
0
ファイル: Job.cs プロジェクト: UhuruSoftware/bosh-dotnet
        public Job(string jobName, string templateName, dynamic templateSpec, dynamic bindSpec)
        {
            Helpers.ValidateSpec(templateSpec);

            this.bindSpec = bindSpec;
            baseDir = Config.BaseDir;
            name = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", jobName, templateName);
            template = templateName;
            version = templateSpec["version"].Value;
            checksum = templateSpec["sha1"].Value;
            blobstoreId = templateSpec["blobstore_id"].Value;

            installPath = Path.Combine(baseDir, "data", "jobs", template, version);
            linkPath = Path.Combine(baseDir, "jobs", template);

            monit = Monit.GetInstance();

            string jobsPath = Path.Combine(baseDir, "jobs");
            if (!Directory.Exists(jobsPath))
            {
                Directory.CreateDirectory(jobsPath);
            }
        }
コード例 #10
0
ファイル: Job.cs プロジェクト: mrdavidlaing/bosh-dotnet
        public Job(string jobName, string templateName, dynamic templateSpec, dynamic bindSpec)
        {
            Helpers.ValidateSpec(templateSpec);

            this.bindSpec = bindSpec;
            baseDir       = Config.BaseDir;
            name          = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", jobName, templateName);
            template      = templateName;
            version       = templateSpec["version"].Value;
            checksum      = templateSpec["sha1"].Value;
            blobstoreId   = templateSpec["blobstore_id"].Value;

            installPath = Path.Combine(baseDir, "data", "jobs", template, version);
            linkPath    = Path.Combine(baseDir, "jobs", template);

            monit = Monit.GetInstance();

            string jobsPath = Path.Combine(baseDir, "jobs");

            if (!Directory.Exists(jobsPath))
            {
                Directory.CreateDirectory(jobsPath);
            }
        }
コード例 #11
0
ファイル: State.cs プロジェクト: mrdavidlaing/bosh-dotnet
 /// <summary>
 /// Initializes a new instance of the <see cref="State"/> class.
 /// </summary>
 public State()
 {
     monit = Monit.GetInstance();
 }
コード例 #12
0
ファイル: State.cs プロジェクト: UhuruSoftware/bosh-dotnet
 /// <summary>
 /// Initializes a new instance of the <see cref="State"/> class.
 /// </summary>
 public State()
 {
     monit = Monit.GetInstance();
 }