Пример #1
0
        public void testRunApp()
        {
            var lo = new LocalOperations("m1", lf, appInitializedDetectorFactory, null);

            lo.SelectPlan("p1");

            AppState st;

            st = lo.GetAppState(ads["a"].AppIdTuple);
            Assert.AreEqual(st.Started, false, "not yet launched");
            Assert.AreEqual(st.Running, false, "not yet running");
            Assert.AreEqual(st.Killed, false, "not yet killed");
            Assert.AreEqual(st.Initialized, false, "not yet initialized");

            lo.LaunchApp(ads["a"].AppIdTuple);
            lo.tick(10.0);

            st = lo.GetAppState(ads["a"].AppIdTuple);
            Assert.AreEqual(st.Started, true, "launched");
            Assert.AreEqual(st.Running, true, "running");
            Assert.AreEqual(st.Killed, false, "not yet killed");
            Assert.AreEqual(st.Initialized, true, "initialized");

            lo.KillApp(ads["a"].AppIdTuple);
            lo.tick(10.0);

            st = lo.GetAppState(ads["a"].AppIdTuple);
            Assert.AreEqual(st.Started, true, "started after kill");
            Assert.AreEqual(st.Killed, true, "killed after kill");
            Assert.AreEqual(st.Running, false, "not running after kill");
            Assert.AreEqual(st.Initialized, false, "not initialized after kill");
        }
Пример #2
0
        /// <summary>
        /// Returns a string with comma separated appIdTuples of apps whose state matches given predicate;
        /// the apps go in alphabetical order ("m10.b", "m2.a"...)
        /// </summary>
        public string getAppsWithMatchingState(LocalOperations lo, Predicate <AppState> predicate)
        {
            var appIds =
                from p in lo.GetPlanRepo()
                from a in p.getAppDefs()
                where predicate(lo.GetAppState(a.AppIdTuple))
                orderby a.AppIdTuple.ToString()
                select a.AppIdTuple.ToString();

            return(string.Join(",", appIds.ToArray()));
        }