Ejemplo n.º 1
0
    def test_evict_non_existent_app(self):
        # tests that apps previously run with this session that are finished and eventually
        # removed by the scheduler also get removed from the session after a status() API has been
        # called on the app

        scheduler = LocalScheduler(self.image_fetcher, cache_size=1)
        session = StandaloneSession(name="test_session",
                                    scheduler=scheduler,
                                    wait_interval=1)
        test_file = os.path.join(self.test_dir, "test_file")
        role = (session.role(name="touch").runs("touch.sh", test_file).on(
            self.test_container))
        app = session.app("touch_test_file").of(role)

        # local scheduler was setup with a cache size of 1
        # run the same app twice (the first will be removed from the scheduler's cache)
        # then validate that the first one will drop from the session's app cache as well
        app_id1 = session.run(app)
        session.wait(app_id1)

        app_id2 = session.run(app)
        session.wait(app_id2)

        apps = session.list()

        self.assertEqual(1, len(apps))
        self.assertFalse(app_id1 in apps)
        self.assertTrue(app_id2 in apps)
Ejemplo n.º 2
0
 def test_wait_unknown_app(self):
     session = StandaloneSession(name=SESSION_NAME,
                                 schedulers={"default": self.scheduler},
                                 wait_interval=1)
     self.assertIsNone(
         session.wait("default://test_session/unknown_app_id"))
     self.assertIsNone(session.wait("default://another_session/some_app"))
Ejemplo n.º 3
0
    def test_run(self):
        test_file = os.path.join(self.test_dir, "test_file")
        session = StandaloneSession(name="test_session",
                                    scheduler=self.scheduler,
                                    wait_interval=1)
        role = (session.role(name="touch").runs("touch.sh", test_file).on(
            self.test_container))
        app = session.app("name").of(role)

        app_id = session.run(app)
        self.assertEqual(AppState.SUCCEEDED, session.wait(app_id).state)
Ejemplo n.º 4
0
    def test_run(self):
        test_file = os.path.join(self.test_dir, "test_file")
        session = StandaloneSession(name=SESSION_NAME,
                                    schedulers={"default": self.scheduler},
                                    wait_interval=1)
        role = Role(name="touch").runs("touch.sh",
                                       test_file).on(self.test_container)
        app = Application("name").of(role)

        app_id = session.run(app, cfg=self.cfg)
        self.assertEqual(AppState.SUCCEEDED, session.wait(app_id).state)
Ejemplo n.º 5
0
 def test_wait_unknown_app(self):
     session = StandaloneSession(name="test_session",
                                 scheduler=self.scheduler,
                                 wait_interval=1)
     with self.assertRaises(UnknownAppException):
         session.wait("unknown_app_id")