Merge lp:~javier.collado/utah/bug1047351 into lp:utah

Proposed by Javier Collado
Status: Merged
Approved by: Joe Talbott
Approved revision: 721
Merged at revision: 713
Proposed branch: lp:~javier.collado/utah/bug1047351
Merge into: lp:utah
Diff against target: 179 lines (+19/-21)
11 files modified
client.py (+6/-11)
utah/client/README (+2/-3)
utah/client/examples/examples/test_one/tc_control (+1/-0)
utah/client/examples/examples/test_two/tc_control (+1/-0)
utah/client/examples/pass.run (+1/-1)
utah/client/examples/utah_tests/test_one/tc_control (+1/-0)
utah/client/examples/utah_tests/test_two/tc_control (+1/-0)
utah/client/examples/utah_tests_sample/sample_one/tc_control (+1/-0)
utah/client/testcase.py (+4/-0)
utah/client/testsuite.py (+0/-2)
utah/group.py (+1/-4)
To merge this branch: bzr merge lp:~javier.collado/utah/bug1047351
Reviewer Review Type Date Requested Status
Joe Talbott (community) Approve
Review via email: mp+130098@code.launchpad.net

Description of the change

This branch contains changes to:
- Check that the client is executed as root
- Make run_as mandatory in the tc_control file (keeping optional in the ts_control file)

I've run a few tests and they worked fine except for the case in which `run_as` was also included
in the test suite. However when `run_as` was included in the test suite as an override, then it worked fine.

In my opinion both `command` and `run_as` in the test suite should be specified as overrides
to make clear that the tester is aware about them being defined in the tc_control file already.
If you agree on this, I can remove both fields from the test suite schema.

To post a comment you must log in.
lp:~javier.collado/utah/bug1047351 updated
721. By Javier Collado

Removed `command` and `run_as` from test suite schema

They are only removed from the schema at the same level as `test`. Both can
still be used below `overrides` and that's the way they're expected to be used.

Revision history for this message
Joe Talbott (joetalbott) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'client.py'
2--- client.py 2012-10-03 09:07:18 +0000
3+++ client.py 2012-10-17 15:25:28 +0000
4@@ -3,9 +3,9 @@
5 import logging
6 import platform
7 import sys
8+import os
9
10 from utah.url import url_argument
11-from utah.group import check_user_group, print_group_error_message
12 from utah.client.runner import Runner
13 from utah.client.state_agent import StateAgentYAML
14 from utah.client.result import Result, ResultYAML, ResultJSON
15@@ -82,11 +82,11 @@
16 parser = get_parser()
17 args = parser.parse_args()
18
19- # When resuming, this script is invoked as root by rc.local
20- # No group membership is assigned then, so root needs to be able to run
21- # this script anyway
22- if not check_user_group(rootok=args.resume):
23- print_group_error_message(__file__)
24+ if not os.getuid() == 0:
25+ parser.print_usage()
26+ sys.stderr.write('{}: UTAH client is expected '
27+ 'to be executed as root user\n'
28+ .format(parser.prog))
29 sys.exit(3)
30
31 setup_logging(args.debug)
32@@ -94,11 +94,6 @@
33 logging.debug(args)
34 logging.info(platform.uname())
35
36- """
37- print args
38- import sys
39- sys.exit(0)
40- """
41 resume = args.resume
42 state_file = args.state_file
43 testdir = args.testdir
44
45=== modified file 'utah/client/README'
46--- utah/client/README 2012-10-10 14:44:00 +0000
47+++ utah/client/README 2012-10-17 15:25:28 +0000
48@@ -45,8 +45,6 @@
49 ######################################################################
50
51 - test: <testcase directory name>
52- [command: <test case command line>]
53- [run_as: <userid>]
54 [overrides:
55 - <tc_control override>
56 - <tc_control override>
57@@ -77,7 +75,8 @@
58 type: <type>
59 [timeout: <timeout in secs>]
60 [build_cmd: <build command>]
61-[command: <testcase command>]
62+command: <testcase command>
63+run_as: <user>
64 [tc_setup: <testcase setup command>]
65 [tc_cleanup: <testcase cleanup command>]
66 [reboot: {always, pass, never}] # defaults to 'never'
67
68=== modified file 'utah/client/examples/examples/test_one/tc_control'
69--- utah/client/examples/examples/test_one/tc_control 2012-04-04 21:52:30 +0000
70+++ utah/client/examples/examples/test_one/tc_control 2012-10-17 15:25:28 +0000
71@@ -9,6 +9,7 @@
72 type: userland
73 #timeout: 200
74 command: echo "runit"
75+run_as: utah
76 #build_cmd: echo "building"
77 tc_setup: echo "setup"
78 tc_cleanup: echo "cleanup"
79
80=== modified file 'utah/client/examples/examples/test_two/tc_control'
81--- utah/client/examples/examples/test_two/tc_control 2012-08-16 10:23:36 +0000
82+++ utah/client/examples/examples/test_two/tc_control 2012-10-17 15:25:28 +0000
83@@ -9,6 +9,7 @@
84 type: userland
85 timeout: 200
86 command: echo "runit"
87+run_as: utah
88 build_cmd: echo "building"
89 tc_setup: echo "setup"
90 tc_cleanup: echo "cleanup"
91
92=== modified file 'utah/client/examples/pass.run'
93--- utah/client/examples/pass.run 2012-10-10 14:44:00 +0000
94+++ utah/client/examples/pass.run 2012-10-17 15:25:28 +0000
95@@ -6,4 +6,4 @@
96 testsuites:
97 - name: utah_tests_sample
98 fetch_method: bzr
99- fetch_location: /usr/share/utah/client/examples/utah_tests_sample
100+ fetch_location: /usr/share/utah/client/examples/utah_tests_sample
101
102=== modified file 'utah/client/examples/utah_tests/test_one/tc_control'
103--- utah/client/examples/utah_tests/test_one/tc_control 2012-08-16 11:01:45 +0000
104+++ utah/client/examples/utah_tests/test_one/tc_control 2012-10-17 15:25:28 +0000
105@@ -1,5 +1,6 @@
106 description: A first sample test case.
107 command: python test_one.py
108+run_as: utah
109 dependencies: n/a
110 action: |
111 1. Action 1
112
113=== modified file 'utah/client/examples/utah_tests/test_two/tc_control'
114--- utah/client/examples/utah_tests/test_two/tc_control 2012-08-13 16:22:08 +0000
115+++ utah/client/examples/utah_tests/test_two/tc_control 2012-10-17 15:25:28 +0000
116@@ -1,5 +1,6 @@
117 description: A second sample test case.
118 command: python test_two.py
119+run_as: utah
120 dependencies: n/a
121 action: |
122 1. Action 1
123
124=== modified file 'utah/client/examples/utah_tests_sample/sample_one/tc_control'
125--- utah/client/examples/utah_tests_sample/sample_one/tc_control 2012-08-16 10:23:36 +0000
126+++ utah/client/examples/utah_tests_sample/sample_one/tc_control 2012-10-17 15:25:28 +0000
127@@ -8,5 +8,6 @@
128 timeout: 200
129 build_cmd: echo "building for sample_one"
130 command: python sample.py
131+run_as: utah
132 tc_setup: echo "setup for sample_one"
133 tc_cleanup: echo "cleanup for sample_one"
134
135=== modified file 'utah/client/testcase.py'
136--- utah/client/testcase.py 2012-10-11 15:23:37 +0000
137+++ utah/client/testcase.py 2012-10-17 15:25:28 +0000
138@@ -64,6 +64,10 @@
139 'type': 'string',
140 'required': True,
141 },
142+ 'run_as': {
143+ 'type': 'string',
144+ 'required': True,
145+ },
146 'tc_setup': {'type': 'string'},
147 'tc_cleanup': {'type': 'string'},
148 'reboot': {
149
150=== modified file 'utah/client/testsuite.py'
151--- utah/client/testsuite.py 2012-10-11 13:47:30 +0000
152+++ utah/client/testsuite.py 2012-10-17 15:25:28 +0000
153@@ -50,8 +50,6 @@
154 'type': 'string',
155 'required': True,
156 },
157- 'command': {'type': 'string'},
158- 'run_as': {'type': 'string'},
159 'overrides': {'type': 'object'},
160 },
161 },
162
163=== modified file 'utah/group.py'
164--- utah/group.py 2012-10-04 15:56:03 +0000
165+++ utah/group.py 2012-10-17 15:25:28 +0000
166@@ -9,13 +9,10 @@
167 from utah import config
168
169
170-def check_user_group(group=config.group, rootok=False):
171+def check_user_group(group=config.group):
172 """
173 Return if the user is a member of the given group
174 """
175- if rootok and os.getuid() == 0:
176- return True
177-
178 user_gids = os.getgroups()
179 gid = grp.getgrnam(group).gr_gid
180

Subscribers

People subscribed via source and target branches