How to use the pgctl.subprocess.check_call function in pgctl

To help you get started, we’ve selected a few pgctl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Yelp / pgctl / tests / spec / examples.py View on Github external
def it_does_start(self, in_example_dir):
        test_string = 'oh, hi there.\n'
        with open('input', 'w') as input:
            input.write(test_string)
        assert not os.path.isfile('output')

        check_call(('pgctl', 'start', 'tail'))
        wait_for(lambda: os.path.isfile('output'))
        assert open('output').read() == test_string
github Yelp / pgctl / tests / spec / dirty_tests.py View on Github external
def it_fails_by_default(self):
        check_call(('pgctl', 'start'))
        assert_svstat('playground/sweet', state='up')
        assert_command(
            ('pgctl', 'stop'),
            '',
            '''\
[pgctl] Stopping: sweet
[pgctl] ERROR: service 'sweet' failed to stop after {TIME} seconds, its status is ready (pid {PID}) {TIME} seconds
==> playground/sweet/logs/current <==
{TIMESTAMP} sweet
{TIMESTAMP} sweet_error
[pgctl]
[pgctl] There might be useful information further up in the log; you can view it by running:
[pgctl]     less +G playground/sweet/logs/current
[pgctl] ERROR: Some services failed to stop: sweet
''',
            1,
github Yelp / pgctl / tests / spec / dirty_tests.py View on Github external
def it_succeeds_on_forceful_stop(self):
        check_call(('pgctl', 'start'))
        assert_svstat('playground/sweet', state='up')
        assert_command(
            ('pgctl', 'stop', '--force'),
            '',
            '''\
[pgctl] Stopping: sweet
[pgctl] WARNING: Killing these runaway processes at user's request (--force):
{PS-HEADER}
{PS-STATS} sleep 2.5

Learn why they did not stop: http://pgctl.readthedocs.org/en/latest/user/quickstart.html#writing-playground-services

[pgctl] Stopped: sweet
''',
            0,
            norm=norm.pgctl,
github Yelp / pgctl / tests / spec / examples.py View on Github external
def it_can_recover_from_a_git_clean(self, in_example_dir, service_name):
        def assert_status():
            assert_command(
                ('pgctl', 'status'),
                '''\
 ● sleep: down
 ● tail: ready
   └─ pid: {PID}, {TIME} seconds
''',
                '',
                0,
                norm=norm.pgctl,
            )

        check_call(('pgctl', 'start', 'tail'))
        assert_status()

        # simulate a git-clean: blow everything away, create a fresh copy
        parent_dir = in_example_dir.join('..')
        with parent_dir.as_cwd():
            in_example_dir.remove(rec=True)
            from testing import copy_example
            copy_example(service_name, parent_dir)

        assert_status()
github Yelp / pgctl / tests / spec / examples.py View on Github external
def it_stops_multiple_services(self, in_example_dir):
        check_call(('pgctl', 'start', 'sleep', 'tail'))

        assert_svstat('playground/sleep', state='up')
        assert_svstat('playground/tail', state='up')

        check_call(('pgctl', 'stop', 'sleep', 'tail'))

        assert_svstat('playground/sleep', state=SvStat.UNSUPERVISED)
        assert_svstat('playground/tail', state=SvStat.UNSUPERVISED)
github Yelp / pgctl / tests / spec / examples.py View on Github external
def it_displays_correctly_when_the_service_is_up_json(self, in_example_dir):
        check_call(('pgctl', 'start', 'sleep'))
        stdout, stderr, returncode = run(
            ('pgctl', '--json', 'status', 'sleep'),
        )
        assert returncode == 0
        assert json.loads(stdout) == {
            'sleep': {
                'exitcode': None,
                'pid': ANY_INTEGER(),
                'process': None,
                'seconds': ANY_INTEGER(),
                'state': 'ready',
            },
        }
        assert stderr == ''
github Yelp / pgctl / tests / spec / examples.py View on Github external
def it_displays_the_status_of_multiple_services_json(self, in_example_dir):
        """Expect multiple services with status and PID"""
        check_call(('pgctl', 'start', 'sleep'))
        stdout, stderr, returncode = run(
            ('pgctl', '--json', 'status', 'sleep', 'tail'),
        )
        assert returncode == 0
        assert json.loads(stdout) == {
            'sleep': {
                'exitcode': None,
                'pid': ANY_INTEGER(),
                'process': None,
                'seconds': ANY_INTEGER(),
                'state': 'ready',
            },
            'tail': {
                'exitcode': None,
                'pid': None,
                'process': None,
github Yelp / pgctl / tests / spec / examples.py View on Github external
def it_also_works_when_up(self, in_example_dir):
        check_call(('pgctl', 'start', 'sleep'))
        assert_svstat('playground/sleep', state='up')

        assert_command(
            ('pgctl', 'restart', 'sleep'),
            '',
            '''\
[pgctl] Stopping: sleep
[pgctl] Stopped: sleep
[pgctl] Starting: sleep
[pgctl] Started: sleep
''',
            0,
        )
        assert_svstat('playground/sleep', state='up')
github Yelp / pgctl / tests / spec / dirty_tests.py View on Github external
def it_warns_on_forcelly_stop_for_slow_start(self):
        check_call(('pgctl', 'start', 'slow-startup'))
        assert_command(
            ('pgctl', 'restart', 'slow-startup', '--force'),
            '',
            '''\
[pgctl] Stopping: slow-startup
[pgctl] WARNING: Killing these runaway processes at user's request (--force):
{PS-HEADER}
{PS-STATS} sleep 987654

Learn why they did not stop: http://pgctl.readthedocs.org/en/latest/user/quickstart.html#writing-playground-services

[pgctl] Stopped: slow-startup
[pgctl] Starting: slow-startup
[pgctl] Started: slow-startup
''',
            0,
github Yelp / pgctl / tests / spec / examples.py View on Github external
def it_is_idempotent(self, in_example_dir):
        check_call(('pgctl', 'start', 'sleep'))
        check_call(('pgctl', 'start', 'sleep'))