Merge lp:~canonical-platform-qa/snappy-ecosystem-tests/export-staging-variables-ssh into lp:snappy-ecosystem-tests
- export-staging-variables-ssh
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | I Ahmad |
Approved revision: | 31 |
Merged at revision: | 28 |
Proposed branch: | lp:~canonical-platform-qa/snappy-ecosystem-tests/export-staging-variables-ssh |
Merge into: | lp:snappy-ecosystem-tests |
Prerequisite: | lp:~canonical-platform-qa/snappy-ecosystem-tests/register-snap-tests |
Diff against target: |
72 lines (+23/-7) 2 files modified
snappy_ecosystem_tests/environment/data/snapd.py (+12/-3) snappy_ecosystem_tests/utils/ssh.py (+11/-4) |
To merge this branch: | bzr merge lp:~canonical-platform-qa/snappy-ecosystem-tests/export-staging-variables-ssh |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
platform-qa-bot | continuous-integration | Approve | |
Heber Parrucci (community) | Abstain | ||
Review via email: mp+318743@code.launchpad.net |
This proposal supersedes a proposal from 2017-03-02.
Commit message
Export staging variables over ssh.
Description of the change
Ensure staging environment variables are available over ssh.
platform-qa-bot (platform-qa-bot) wrote : Posted in a previous version of this proposal | # |
Omer Akram (om26er) wrote : Posted in a previous version of this proposal | # |
By default ssh is secure and does not allow any random environment variable to be exported. So the ssh config within the container also needs to be updated to allow these variables to be exported.
That can be enabled by container setup script. We basically need to append staging environment variable names to AcceptEnv key inside /etc/ssh/
For testing just update the AcceptEnv line in the container to
AcceptEnv *
Omer Akram (om26er) wrote : Posted in a previous version of this proposal | # |
(and restart the container)
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:25
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 26. By Omer Akram
-
Finish rebase
- 27. By Omer Akram
-
fix
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:27
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
Heber Parrucci (heber013) wrote : | # |
Comment inline
- 28. By Omer Akram
-
fix per suggestion
Omer Akram (om26er) wrote : | # |
replied inline.
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:28
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 29. By Omer Akram
-
merge with pre-req
platform-qa-bot (platform-qa-bot) wrote : | # |
FAILED: Continuous integration, rev:29
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
- 30. By Omer Akram
-
ignore arguments-differ pylint warning
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:30
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
Heber Parrucci (heber013) wrote : | # |
Comments inline. Thanks
I Ahmad (iahmad) wrote : | # |
+1 for heber's recommendation, env should not be hard coded rather
configurable based on value in config file
On Fri, Mar 3, 2017 at 2:29 AM, Heber Parrucci <<email address hidden>
> wrote:
> Review: Needs Fixing
>
> Comments inline. Thanks
>
> Diff comments:
>
> >
> > === modified file 'snappy_
> > --- snappy_
> > +++ snappy_
> > @@ -31,13 +33,13 @@
> > class SSHClient(
> > """Extended SSHClient."""
> >
> > - def exec_command(self, command, bufsize=-1, timeout=None,
> get_pty=False,
> > - cwd=''):
> > + def exec_command(self, command, bufsize=-1, timeout=None,
> get_pty=False, # pylint: disable=
>
> If we disable the rules every time pylint warns us about something, we are
> losing the tool benefits and would be the same as not using it at all.
> In this particular case you are changing the parent method signature which
> could be ok in some cases. But if we look deeper in the problem, you have
> created an SSHClient and overrided exec_command just to change the dir when
> executing the command. I think this is not necessary at all... You could
> use the paramiko function and achieve the same. And the trick will be in
> the helper side... For example in case of snapd:
> http://
>
> > + environment=None, cwd=''):
> > """Execute the given command over ssh."""
> > if cwd:
> > command = 'cd {}; {}'.format(cwd, command)
> > _, stdout, stderr = super()
> timeout,
> > - get_pty)
> > + get_pty, environment)
> > if stdout.
> > raise ValueError(
> > response = stdout.
> > @@ -118,4 +120,9 @@
> > _hostname, _username, _port = get_snapd_
> > ssh = SSHManager.
> > hostname or _hostname, username or _username, port or _port)
> > - return ssh.exec_
> > + return ssh.exec_command(
> > + command,
> > + cwd=cwd,
> > + environment=
> 'staging'
>
> It is almost the same than before the fix. What I meant when wrote the
> suggestion is to dynamically pass the corresponding environment variables
> depending on the current store. You could have a function that returns the
> corresponding dictionary containing the variables and receives the store
> name as parameter. So in the future if we need to add variables for example
> for production, we just create the dictionary and that's all, we don't need
> to change this method for that.
>
> > + else None
> > + )
>
>
> --
> https:/
> ecosystem-
> You are subscribed to branch lp:snappy-ecosystem-tests.
>
Omer Akram (om26er) wrote : | # |
replied inline.
I Ahmad (iahmad) wrote : | # |
There could be situation where container is previously set to staging but
now needs to be reset to the production (in cases where environment needs
to be reused).
On Fri, Mar 3, 2017 at 4:48 PM, Omer Akram <email address hidden> wrote:
> replied inline.
>
> Diff comments:
>
> >
> > === modified file 'snappy_
> > --- snappy_
> > +++ snappy_
> > @@ -31,13 +33,13 @@
> > class SSHClient(
> > """Extended SSHClient."""
> >
> > - def exec_command(self, command, bufsize=-1, timeout=None,
> get_pty=False,
> > - cwd=''):
> > + def exec_command(self, command, bufsize=-1, timeout=None,
> get_pty=False, # pylint: disable=
>
> pylint is picky, yes. But since I am trying to extend the functionality of
> a method, I added a new parameter, quite normal.
>
> pylint threw that warning because it could easily be a mistake on my end,
> but given its intentional, I had to silence pylint for that. The reason I
> added that override was inspired by the conversation I found on pylint'
> mailing list[1].
>
> [1] http://
>
> > + environment=None, cwd=''):
> > """Execute the given command over ssh."""
> > if cwd:
> > command = 'cd {}; {}'.format(cwd, command)
> > _, stdout, stderr = super()
> timeout,
> > - get_pty)
> > + get_pty, environment)
> > if stdout.
> > raise ValueError(
> > response = stdout.
> > @@ -118,4 +120,9 @@
> > _hostname, _username, _port = get_snapd_
> > ssh = SSHManager.
> > hostname or _hostname, username or _username, port or _port)
> > - return ssh.exec_
> > + return ssh.exec_command(
> > + command,
> > + cwd=cwd,
> > + environment=
> 'staging'
>
> I might be a little off here but if we don't export any variables we are
> by default on production. Only staging parameters need to be exported, if
> that's not the case, can you please show a code example so that I can
> incorporate that in.
>
> > + else None
> > + )
>
>
> --
> https:/
> ecosystem-
> You are subscribed to branch lp:snappy-ecosystem-tests.
>
Heber Parrucci (heber013) wrote : | # |
Reply inline
Omer Akram (om26er) wrote : | # |
Heber, replied inline.
Omer Akram (om26er) wrote : | # |
> There could be situation where container is previously set to staging but
> now needs to be reset to the production (in cases where environment needs
> to be reused).
if get_current_store() returns staging, then staging variables will be available, if it returns 'production' then by default production variables will be exported.
>
> On Fri, Mar 3, 2017 at 4:48 PM, Omer Akram <email address hidden> wrote:
>
> > replied inline.
> >
> > Diff comments:
> >
> > >
> > > === modified file 'snappy_
> > > --- snappy_
> > > +++ snappy_
> > > @@ -31,13 +33,13 @@
> > > class SSHClient(
> > > """Extended SSHClient."""
> > >
> > > - def exec_command(self, command, bufsize=-1, timeout=None,
> > get_pty=False,
> > > - cwd=''):
> > > + def exec_command(self, command, bufsize=-1, timeout=None,
> > get_pty=False, # pylint: disable=
> >
> > pylint is picky, yes. But since I am trying to extend the functionality of
> > a method, I added a new parameter, quite normal.
> >
> > pylint threw that warning because it could easily be a mistake on my end,
> > but given its intentional, I had to silence pylint for that. The reason I
> > added that override was inspired by the conversation I found on pylint'
> > mailing list[1].
> >
> > [1] http://
> >
> > > + environment=None, cwd=''):
> > > """Execute the given command over ssh."""
> > > if cwd:
> > > command = 'cd {}; {}'.format(cwd, command)
> > > _, stdout, stderr = super()
> > timeout,
> > > - get_pty)
> > > + get_pty, environment)
> > > if stdout.
> > > raise ValueError(
> > > response = stdout.
> > > @@ -118,4 +120,9 @@
> > > _hostname, _username, _port = get_snapd_
> > > ssh = SSHManager.
> > > hostname or _hostname, username or _username, port or _port)
> > > - return ssh.exec_
> > > + return ssh.exec_command(
> > > + command,
> > > + cwd=cwd,
> > > + environment=
> > 'staging'
> >
> > I might be a little off here but if we don't export any variables we are
> > by default on production. Only staging parameters need to be exported, if
> > that's not the case, can you please show a code example so that I can
> > incorporate that in.
> >
> > > + else None
> > > + )
> >
> >
> > --
> > https:/
> > ecosystem-
> > You are subscribed to branch lp:snappy-ecosystem-tests.
> >
- 31. By Omer Akram
-
merge with trunk
platform-qa-bot (platform-qa-bot) wrote : | # |
PASSED: Continuous integration, rev:31
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild:
https:/
Heber Parrucci (heber013) wrote : | # |
Reply inline
platform-qa-bot (platform-qa-bot) : | # |
Preview Diff
1 | === modified file 'snappy_ecosystem_tests/environment/data/snapd.py' |
2 | --- snappy_ecosystem_tests/environment/data/snapd.py 2017-03-01 10:28:47 +0000 |
3 | +++ snappy_ecosystem_tests/environment/data/snapd.py 2017-03-03 13:01:15 +0000 |
4 | @@ -67,15 +67,24 @@ |
5 | {'command': COMMAND_APT_INSTALL_STAGING_DEBS, 'cwd': DIRECTORY_CLONE} |
6 | ] |
7 | |
8 | -CONTAINER_ENV_VARS = { |
9 | - 'GOPATH': CONTAINER_HOME, |
10 | - 'SNAPPY_USE_STAGING_STORE': '1', |
11 | +SNAPCRAFT_STAGING_VARIABLES = { |
12 | ENV_STORE_API_ROOT: URL_API_ROOT, |
13 | ENV_STORE_SEARCH_ROOT: URL_SEARCH_ROOT, |
14 | ENV_STORE_UPLOAD_ROOT: URL_UPLOAD_ROOT, |
15 | ENV_SSO_API_ROOT: URL_SSO_API_ROOT, |
16 | } |
17 | |
18 | +SNAPD_STAGING_VARIABLES = { |
19 | + 'SNAPPY_USE_STAGING_STORE': '1' |
20 | +} |
21 | + |
22 | +STAGING_VARIABLES = dict( |
23 | + SNAPCRAFT_STAGING_VARIABLES, **SNAPD_STAGING_VARIABLES) |
24 | + |
25 | +CONTAINER_ENV_VARS = { |
26 | + 'GOPATH': CONTAINER_HOME, |
27 | +} |
28 | + |
29 | DEFAULT_CONTAINER_CONFIG = { |
30 | "name": "snapd", |
31 | "source": { |
32 | |
33 | === modified file 'snappy_ecosystem_tests/utils/ssh.py' |
34 | --- snappy_ecosystem_tests/utils/ssh.py 2017-03-02 18:36:24 +0000 |
35 | +++ snappy_ecosystem_tests/utils/ssh.py 2017-03-03 13:01:15 +0000 |
36 | @@ -24,6 +24,8 @@ |
37 | import paramiko |
38 | |
39 | from snappy_ecosystem_tests.utils.user import get_snapd_remote_host_credentials |
40 | +from snappy_ecosystem_tests.utils.storeconfig import get_current_store |
41 | +from snappy_ecosystem_tests.environment.data.snapd import STAGING_VARIABLES |
42 | |
43 | LOGGER = logging.getLogger(__name__) |
44 | |
45 | @@ -31,13 +33,13 @@ |
46 | class SSHClient(paramiko.SSHClient): |
47 | """Extended SSHClient.""" |
48 | |
49 | - def exec_command(self, command, bufsize=-1, timeout=None, get_pty=False, |
50 | - cwd=''): |
51 | + def exec_command(self, command, bufsize=-1, timeout=None, get_pty=False, # pylint: disable=arguments-differ |
52 | + environment=None, cwd=''): |
53 | """Execute the given command over ssh.""" |
54 | if cwd: |
55 | command = 'cd {}; {}'.format(cwd, command) |
56 | _, stdout, stderr = super().exec_command(command, bufsize, timeout, |
57 | - get_pty) |
58 | + get_pty, environment) |
59 | if stdout.channel.recv_exit_status() != 0: |
60 | raise ValueError(stderr.read().decode().strip()) |
61 | response = stdout.read().decode().strip() |
62 | @@ -118,4 +120,9 @@ |
63 | _hostname, _username, _port = get_snapd_remote_host_credentials() |
64 | ssh = SSHManager.get_instance( |
65 | hostname or _hostname, username or _username, port or _port) |
66 | - return ssh.exec_command(command, cwd=cwd) |
67 | + return ssh.exec_command( |
68 | + command, |
69 | + cwd=cwd, |
70 | + environment=STAGING_VARIABLES if get_current_store() == 'staging' |
71 | + else None |
72 | + ) |
PASSED: Continuous integration, rev:24 /platform- qa-jenkins. ubuntu. com/job/ snappy- ecosystem- tests-ci/ 226/ /platform- qa-jenkins. ubuntu. com/job/ generic- update- mp/2027/ console
https:/
Executed test runs:
None: https:/
Click here to trigger a rebuild: /platform- qa-jenkins. ubuntu. com/job/ snappy- ecosystem- tests-ci/ 226/rebuild
https:/