Exemplo n.º 1
0
        public void testSomething()
        {
            var gui      = startGui();
            var systemId = 1234;
            var topic    = new Topic(CloudMonitor.topic(systemId));
            var instance = "i-123456";

            gui.setSystemId(systemId);
            gui.doAllWork();
            topic.send("Instances", instance);
            gui.noMessage();
            hasRedGreen(0, 0, gui);
            requireCount(gui, 1);
            hasField(gui, 0, CloudSTOTracker.INSTANCE_ID, instance);
            var redTime = O.now().Add(new TimeSpan(0, 0, 0, 2));

            publish(instance, redTime, 0, 3, 10, 2.5, date("2009/02/02 10:00:01"));
            hasField(gui, 0, CloudSTOTracker.NUM_GREEN, "3");
            hasField(gui, 0, CloudSTOTracker.NUM_RED, "0");
            hasField(gui, 0, CloudSTOTracker.COMPLETED, "10");
            hasField(gui, 0, CloudSTOTracker.RUNS_PER_MIN, "2.50");
            hasField(gui, 0, CloudSTOTracker.LAST_COMPLETED, "2009/02/02 10:00:01");
            hasRedGreen(0, 3, gui);
            AreEqual(SystemStatus.GREEN, gui.status(instance));
            O.wait(() => { gui.doAllWork(); return(gui.status(instance).Equals(SystemStatus.YELLOW)); });
            hasRedGreen(0, 3, gui);
            publish(instance, O.SQL_MAX_DATE, 1, 2, 15, 5.5, date("2009/02/02 10:00:02"));
            O.wait(() => { gui.doAllWork(); return(gui.status(instance).Equals(SystemStatus.RED)); });
            hasRedGreen(1, 2, gui);
        }
Exemplo n.º 2
0
            void process(Message message, Dictionary <int, bool> completed, int totalRuns)
            {
                var response = (STOResponse)message.@object();

                runner.received(response);
                var completedRun   = response.runNumber();
                var runTimeMillis  = response.runTimeMillis();
                var completionTime = response.completedAt();
                var isLocal        = response.instanceId().Equals("LOCAL");

                message.delete();
                // Letting message get GC'd, rather than sitting in the thread pool really helps with the Java heap space.
                queueWorkItem(() => {
                    lock (completed) {
                        if (completed.ContainsKey(completedRun))
                        {
                            return;
                        }
                        completed[completedRun] = true;
                        if (!isLocal)
                        {
                            completionTimes.Add(date(completionTime));
                            updateRunsPerMinute(runTimeMillis);
                        }
                    }
                    LogC.info("completed run " + completedRun + paren(completed.Count + "/" + totalRuns));
                    new Topic(CloudMonitor.progressTopic(systemId)).send(new Dictionary <string, object> {
                        { "RunsComplete", completed.Count },
                        { "TotalRuns", totalRuns },
                        { "RunsPerMinute", runsPerMinute },
                    });
                    writeResults(completedRun);
                });
            }
Exemplo n.º 3
0
        void populate()
        {
            var systemId = gui.systemId();

            clear();
            systemTopic = new Topic(CloudMonitor.topic(systemId));
            systemTopic.subscribe(fields => populate(systemId, fields));
            new Topic(CloudMonitor.progressTopic(systemId)).subscribe(fields => updateSummary(systemId, fields));
        }
Exemplo n.º 4
0
 static void publish(string instance, DateTime redTime, int numRed, int numGreen, int total, double runsPerMinute, DateTime lastCompletion)
 {
     new Topic(CloudMonitor.instanceTopic(instance)).send(new Dictionary <string, object> {
         { "NumRed", numRed },
         { "NumGreen", numGreen },
         { "Completed", total },
         { "RunsPerMinute", runsPerMinute },
         { "LastCompleted", O.ymdHuman(lastCompletion) },
         { "RedTime", O.ymdHuman(redTime) }
     });
 }
Exemplo n.º 5
0
        void addRow(string id)
        {
            var row = table.NewRow();

            row[INSTANCE_ID] = id;
            var topic = CloudMonitor.instanceTopic(id);

            new Topic(topic).subscribe(fields => gui.runOnGuiThread(() => updateRow(row, fields)));
            table.Rows.Add(row);
            instances[row] = id;
            gui.setInstanceCount(table.Rows.Count);
        }
Exemplo n.º 6
0
        public void testAddRemoveInstances()
        {
            var gui      = startGui();
            var systemId = 1234;
            var topic    = new Topic(CloudMonitor.topic(systemId));

            new Thread(o => { O.sleep(1000); topic.send("Instances", "i-123456"); }).Start();
            gui.setSystemId(systemId);
            gui.doAllWork();
            gui.noMessage();
            requireCount(gui, 1);
            topic.send("Instances", "i-123456,i-98765");
            requireCount(gui, 2);
            gui.tracker.kill("i-123456");
            requireCount(gui, 1);
        }
Exemplo n.º 7
0
        public void testSummary()
        {
            var gui      = startGui();
            var systemId = 1234;
            var topic    = new Topic(CloudMonitor.progressTopic(systemId));

            gui.setSystemId(systemId);
            gui.doAllWork();
            O.freezeNow("2008/02/03 02:00:00");
            topic.send(new Dictionary <string, object> {
                { "RunsComplete", 1000 },
                { "TotalRuns", 10000 },
                { "RunsPerMinute", 10 },
            });
            O.wait(() => gui.runsComplete() == 1000);
            AreEqual(date("2008/02/03 17:00:00"), gui.completionTime());
            AreEqual(10000, gui.totalRuns());
        }