コード例 #1
0
ファイル: test_bounce_lib.py プロジェクト: radhikari54/paasta
    def test_upthendown_bounce_cleanup(self):
        """When marathon has the desired app, and there are other copies of
        the service running, and the new app is fully up, upthendown bounce
        should stop the old ones."""

        new_config = {'id': 'foo.bar.12345', 'instances': 5}
        happy_tasks = [mock.Mock() for _ in range(5)]
        old_app_live_happy_tasks = {
            'app1': {mock.Mock() for _ in range(3)},
            'app2': {mock.Mock() for _ in range(2)},
        }
        old_app_live_unhappy_tasks = {
            'app1': {mock.Mock() for _ in range(2)},
            'app2': {mock.Mock() for _ in range(3)},
        }

        assert bounce_lib.upthendown_bounce(
            new_config=new_config,
            new_app_running=True,
            happy_new_tasks=happy_tasks,
            old_app_live_happy_tasks=old_app_live_happy_tasks,
            old_app_live_unhappy_tasks=old_app_live_unhappy_tasks,
        ) == {
            "create_app": False,
            "tasks_to_drain": set.union(
                old_app_live_happy_tasks['app1'],
                old_app_live_happy_tasks['app2'],
                old_app_live_unhappy_tasks['app1'],
                old_app_live_unhappy_tasks['app2'],
            ),
        }
コード例 #2
0
ファイル: test_bounce_lib.py プロジェクト: oktopuz/paasta
    def test_upthendown_bounce_old_but_no_new(self):
        """When marathon has the desired app, but there are other copies of
        the service running, upthendown bounce should start the new one. but
        not stop the old one yet."""

        new_config = {'id': 'foo.bar.12345', 'instances': 5}
        old_app_live_happy_tasks = {
            'app1': set(mock.Mock() for _ in xrange(3)),
            'app2': set(mock.Mock() for _ in xrange(2)),
        }
        old_app_live_unhappy_tasks = {
            'app1': set(mock.Mock() for _ in xrange(2)),
            'app2': set(mock.Mock() for _ in xrange(3)),
        }

        assert bounce_lib.upthendown_bounce(
            new_config=new_config,
            new_app_running=False,
            happy_new_tasks=[],
            old_app_live_happy_tasks=old_app_live_happy_tasks,
            old_app_live_unhappy_tasks=old_app_live_unhappy_tasks,
        ) == {
            "create_app": True,
            "tasks_to_drain": set(),
        }
コード例 #3
0
ファイル: test_bounce_lib.py プロジェクト: radhikari54/paasta
    def test_upthendown_bounce_old_but_no_new(self):
        """When marathon has the desired app, but there are other copies of
        the service running, upthendown bounce should start the new one. but
        not stop the old one yet."""

        new_config = {'id': 'foo.bar.12345', 'instances': 5}
        old_app_live_happy_tasks = {
            'app1': {mock.Mock() for _ in range(3)},
            'app2': {mock.Mock() for _ in range(2)},
        }
        old_app_live_unhappy_tasks = {
            'app1': {mock.Mock() for _ in range(2)},
            'app2': {mock.Mock() for _ in range(3)},
        }

        assert bounce_lib.upthendown_bounce(
            new_config=new_config,
            new_app_running=False,
            happy_new_tasks=[],
            old_app_live_happy_tasks=old_app_live_happy_tasks,
            old_app_live_unhappy_tasks=old_app_live_unhappy_tasks,
        ) == {
            "create_app": True,
            "tasks_to_drain": set(),
        }
コード例 #4
0
ファイル: test_bounce_lib.py プロジェクト: oktopuz/paasta
    def test_upthendown_bounce_cleanup(self):
        """When marathon has the desired app, and there are other copies of
        the service running, and the new app is fully up, upthendown bounce
        should stop the old ones."""

        new_config = {'id': 'foo.bar.12345', 'instances': 5}
        happy_tasks = [mock.Mock() for _ in xrange(5)]
        old_app_live_happy_tasks = {
            'app1': set(mock.Mock() for _ in xrange(3)),
            'app2': set(mock.Mock() for _ in xrange(2)),
        }
        old_app_live_unhappy_tasks = {
            'app1': set(mock.Mock() for _ in xrange(2)),
            'app2': set(mock.Mock() for _ in xrange(3)),
        }

        assert bounce_lib.upthendown_bounce(
            new_config=new_config,
            new_app_running=True,
            happy_new_tasks=happy_tasks,
            old_app_live_happy_tasks=old_app_live_happy_tasks,
            old_app_live_unhappy_tasks=old_app_live_unhappy_tasks,
        ) == {
            "create_app": False,
            "tasks_to_drain": set.union(
                old_app_live_happy_tasks['app1'],
                old_app_live_happy_tasks['app2'],
                old_app_live_unhappy_tasks['app1'],
                old_app_live_unhappy_tasks['app2'],
            ),
        }
コード例 #5
0
    def test_upthendown_bounce_no_existing_apps(self):
        """When marathon is unaware of a service, upthendown bounce should try to
        create a marathon app."""
        new_config = {"id": "foo.bar.12345"}
        happy_tasks = []

        assert bounce_lib.upthendown_bounce(
            new_config=new_config,
            new_app_running=False,
            happy_new_tasks=happy_tasks,
            old_non_draining_tasks=[],
        ) == {"create_app": True, "tasks_to_drain": set()}
コード例 #6
0
ファイル: test_bounce_lib.py プロジェクト: iomedhealth/paasta
    def test_upthendown_bounce_no_existing_apps(self):
        """When marathon is unaware of a service, upthendown bounce should try to
        create a marathon app."""
        new_config = {'id': 'foo.bar.12345'}
        happy_tasks = []

        assert bounce_lib.upthendown_bounce(
            new_config=new_config,
            new_app_running=False,
            happy_new_tasks=happy_tasks,
            old_app_live_tasks={},
        ) == {
            "create_app": True,
            "tasks_to_drain": set(),
        }
コード例 #7
0
    def test_upthendown_bounce_old_but_no_new(self):
        """When marathon has the desired app, but there are other copies of
        the service running, upthendown bounce should start the new one. but
        not stop the old one yet."""

        new_config = {"id": "foo.bar.12345", "instances": 5}
        old_app_live_happy_tasks = [mock.Mock() for _ in range(5)]
        old_app_live_unhappy_tasks = [mock.Mock() for _ in range(5)]

        assert bounce_lib.upthendown_bounce(
            new_config=new_config,
            new_app_running=False,
            happy_new_tasks=[],
            old_non_draining_tasks=old_app_live_happy_tasks
            + old_app_live_unhappy_tasks,
        ) == {"create_app": True, "tasks_to_drain": set()}
コード例 #8
0
    def test_upthendown_bounce_done(self):
        """When marathon has the desired app, and there are no other copies of
        the service running, upthendown bounce should neither start nor stop
        anything."""

        new_config = {"id": "foo.bar.12345", "instances": 5}
        happy_tasks = [mock.Mock() for _ in range(5)]
        old_app_live_happy_tasks = []
        old_app_live_unhappy_tasks = []

        assert bounce_lib.upthendown_bounce(
            new_config=new_config,
            new_app_running=True,
            happy_new_tasks=happy_tasks,
            old_non_draining_tasks=old_app_live_happy_tasks
            + old_app_live_unhappy_tasks,
        ) == {"create_app": False, "tasks_to_drain": set()}
コード例 #9
0
ファイル: test_bounce_lib.py プロジェクト: iomedhealth/paasta
    def test_upthendown_bounce_done(self):
        """When marathon has the desired app, and there are no other copies of
        the service running, upthendown bounce should neither start nor stop
        anything."""

        new_config = {'id': 'foo.bar.12345', 'instances': 5}
        happy_tasks = [mock.Mock() for _ in xrange(5)]
        old_app_live_tasks = {}

        assert bounce_lib.upthendown_bounce(
            new_config=new_config,
            new_app_running=True,
            happy_new_tasks=happy_tasks,
            old_app_live_tasks=old_app_live_tasks,
        ) == {
            "create_app": False,
            "tasks_to_drain": set(),
        }
コード例 #10
0
    def test_upthendown_bounce_mid_bounce(self):
        """When marathon has the desired app, and there are other copies of
        the service running, but the new app is not fully up, upthendown bounce
        should not stop the old ones."""

        new_config = {'id': 'foo.bar.12345', 'instances': 5}
        happy_tasks = [mock.Mock() for _ in range(3)]
        old_app_live_happy_tasks = [mock.Mock() for _ in range(5)]
        old_app_live_unhappy_tasks = [mock.Mock() for _ in range(5)]

        assert bounce_lib.upthendown_bounce(
            new_config=new_config,
            new_app_running=True,
            happy_new_tasks=happy_tasks,
            old_non_draining_tasks=old_app_live_happy_tasks +
            old_app_live_unhappy_tasks,
        ) == {
            "create_app": False,
            "tasks_to_drain": set(),
        }