Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PgctlApp.all_services fails when executed by `pgctl {action} path/to/playground #163

Open
0xngold opened this issue Nov 17, 2016 · 0 comments
Labels

Comments

@0xngold
Copy link
Contributor

0xngold commented Nov 17, 2016

When all_services tries to use self.pgdir, a search is conducted from CWD to the root. If there is a playground subdirectory in any of the parents, it will be used. If no such directory exists in any of the parents, an exception is raised. The issue manifests when pgctl is invoked with a path to the playground.

With an invocation of self.all_services to PgctlApp.__change_state, DescribeDateExample.it_can_start_via_abspath_service will fail. This is because it runs with CWD set to arbitrary, and then passes a start command with a path pointing to the first date subdirectory.

.
├── arbitrary # CWD is here
├── date # (full path to this is passed to pgctl)
│   └── playground
│       └── date
│           ├── event
│           ├── log
│           ├── nosetsid
│           ├── run
│           └── supervise -> /nail/tmp/pytest-of-ngold/pytest-597/popen-gw2/it_can_start_via_abspath_servi0/home/.run/pgctl/nail/tmp/pytest-of-ngold/pytest-597/popen-gw2/it_can_start_via_abspath_servi0/date/playground/date/supervise
├── home
└── pytest-subprocesses.lock
______________________________________________ DescribeDateExample.it_can_start_via_abspath_service ______________________________________________
[gw2] linux2 -- Python 2.7.6 /nail/home/ngold/pg/pgctl/.tox/py27/bin/python2.7
self = <spec.examples.DescribeDateExample object at 0x1a6f350>
in_example_dir = local(u'/nail/tmp/pytest-of-ngold/pytest-597/popen-gw2/it_can_start_via_abspath_servi0/date')
scratch_dir = local(u'/nail/tmp/pytest-of-ngold/pytest-597/popen-gw2/it_can_start_via_abspat...old/pytest-597/popen-gw2/it_can_start_via_abspath_s
ervi0/date/playground/date')
tmpdir = local('/nail/tmp/pytest-of-ngold/pytest-597/popen-gw2/it_can_start_via_abspath_servi0')

    def it_can_start_via_abspath_service(self, in_example_dir, scratch_dir, tmpdir):
        with tmpdir.ensure_dir('arbitrary').as_cwd():
            assert not scratch_dir.join('now.date').isfile()
            date_abspath = str(in_example_dir.join('playground/date'))
>           check_call(('pgctl', 'start', date_abspath))

/nail/home/ngold/pg/pgctl/tests/spec/examples.py:197:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/nail/home/ngold/pg/pgctl/.tox/py27/lib/python2.7/site-packages/pgctl/subprocess.py:13: in wrapped
    return func(cmd, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

popenargs = (('pgctl', 'start', '/nail/tmp/pytest-of-ngold/pytest-597/popen-gw2/it_can_start_via_abspath_servi0/date/playground/date'),)
kwargs = {'close_fds': False}, retcode = 1
cmd = ('pgctl', 'start', '/nail/tmp/pytest-of-ngold/pytest-597/popen-gw2/it_can_start_via_abspath_servi0/date/playground/date')

    def check_call(*popenargs, **kwargs):
        """Run command with arguments.  Wait for command to complete.  If
        the exit code was zero then return, otherwise raise
        CalledProcessError.  The CalledProcessError object will have the
        return code in the returncode attribute.

        The arguments are the same as for the Popen constructor.  Example:

        check_call(["ls", "-l"])
        """
        retcode = call(*popenargs, **kwargs)
        if retcode:
            cmd = kwargs.get("args")
            if cmd is None:
                cmd = popenargs[0]
>           raise CalledProcessError(retcode, cmd)
E           CalledProcessError: Command '(u'pgctl', u'start', '/nail/tmp/pytest-of-ngold/pytest-597/popen-gw2/it_can_start_via_abspath_servi0/date
/playground/date')' returned non-zero exit status 1

/usr/lib/python2.7/subprocess.py:540: CalledProcessError
-------------------------------------------------------------- Captured stderr call --------------------------------------------------------------
[pgctl] Starting: date
[pgctl] Started: date
[pgctl] ERROR: could not find any directory named 'playground'
------------------------------------------------------------ Captured stderr teardown ------------------------------------------------------------
[pgctl] Stopping: date
[pgctl] Stopped: date
@0xngold 0xngold added the bug label Nov 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant