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
=== modified file 'client.py'
--- client.py 2012-10-03 09:07:18 +0000
+++ client.py 2012-10-17 15:25:28 +0000
@@ -3,9 +3,9 @@
3import logging3import logging
4import platform4import platform
5import sys5import sys
6import os
67
7from utah.url import url_argument8from utah.url import url_argument
8from utah.group import check_user_group, print_group_error_message
9from utah.client.runner import Runner9from utah.client.runner import Runner
10from utah.client.state_agent import StateAgentYAML10from utah.client.state_agent import StateAgentYAML
11from utah.client.result import Result, ResultYAML, ResultJSON11from utah.client.result import Result, ResultYAML, ResultJSON
@@ -82,11 +82,11 @@
82 parser = get_parser()82 parser = get_parser()
83 args = parser.parse_args()83 args = parser.parse_args()
8484
85 # When resuming, this script is invoked as root by rc.local85 if not os.getuid() == 0:
86 # No group membership is assigned then, so root needs to be able to run86 parser.print_usage()
87 # this script anyway87 sys.stderr.write('{}: UTAH client is expected '
88 if not check_user_group(rootok=args.resume):88 'to be executed as root user\n'
89 print_group_error_message(__file__)89 .format(parser.prog))
90 sys.exit(3)90 sys.exit(3)
9191
92 setup_logging(args.debug)92 setup_logging(args.debug)
@@ -94,11 +94,6 @@
94 logging.debug(args)94 logging.debug(args)
95 logging.info(platform.uname())95 logging.info(platform.uname())
9696
97 """
98 print args
99 import sys
100 sys.exit(0)
101 """
102 resume = args.resume97 resume = args.resume
103 state_file = args.state_file98 state_file = args.state_file
104 testdir = args.testdir99 testdir = args.testdir
105100
=== modified file 'utah/client/README'
--- utah/client/README 2012-10-10 14:44:00 +0000
+++ utah/client/README 2012-10-17 15:25:28 +0000
@@ -45,8 +45,6 @@
45######################################################################45######################################################################
4646
47- test: <testcase directory name>47- test: <testcase directory name>
48 [command: <test case command line>]
49 [run_as: <userid>]
50 [overrides: 48 [overrides:
51 - <tc_control override>49 - <tc_control override>
52 - <tc_control override>50 - <tc_control override>
@@ -77,7 +75,8 @@
77type: <type>75type: <type>
78[timeout: <timeout in secs>]76[timeout: <timeout in secs>]
79[build_cmd: <build command>]77[build_cmd: <build command>]
80[command: <testcase command>]78command: <testcase command>
79run_as: <user>
81[tc_setup: <testcase setup command>]80[tc_setup: <testcase setup command>]
82[tc_cleanup: <testcase cleanup command>]81[tc_cleanup: <testcase cleanup command>]
83[reboot: {always, pass, never}] # defaults to 'never'82[reboot: {always, pass, never}] # defaults to 'never'
8483
=== modified file 'utah/client/examples/examples/test_one/tc_control'
--- utah/client/examples/examples/test_one/tc_control 2012-04-04 21:52:30 +0000
+++ utah/client/examples/examples/test_one/tc_control 2012-10-17 15:25:28 +0000
@@ -9,6 +9,7 @@
9type: userland9type: userland
10#timeout: 20010#timeout: 200
11command: echo "runit"11command: echo "runit"
12run_as: utah
12#build_cmd: echo "building"13#build_cmd: echo "building"
13tc_setup: echo "setup"14tc_setup: echo "setup"
14tc_cleanup: echo "cleanup"15tc_cleanup: echo "cleanup"
1516
=== modified file 'utah/client/examples/examples/test_two/tc_control'
--- utah/client/examples/examples/test_two/tc_control 2012-08-16 10:23:36 +0000
+++ utah/client/examples/examples/test_two/tc_control 2012-10-17 15:25:28 +0000
@@ -9,6 +9,7 @@
9type: userland9type: userland
10timeout: 20010timeout: 200
11command: echo "runit"11command: echo "runit"
12run_as: utah
12build_cmd: echo "building"13build_cmd: echo "building"
13tc_setup: echo "setup"14tc_setup: echo "setup"
14tc_cleanup: echo "cleanup"15tc_cleanup: echo "cleanup"
1516
=== modified file 'utah/client/examples/pass.run'
--- utah/client/examples/pass.run 2012-10-10 14:44:00 +0000
+++ utah/client/examples/pass.run 2012-10-17 15:25:28 +0000
@@ -6,4 +6,4 @@
6testsuites:6testsuites:
7 - name: utah_tests_sample7 - name: utah_tests_sample
8 fetch_method: bzr8 fetch_method: bzr
9 fetch_location: /usr/share/utah/client/examples/utah_tests_sample9 fetch_location: /usr/share/utah/client/examples/utah_tests_sample
1010
=== modified file 'utah/client/examples/utah_tests/test_one/tc_control'
--- utah/client/examples/utah_tests/test_one/tc_control 2012-08-16 11:01:45 +0000
+++ utah/client/examples/utah_tests/test_one/tc_control 2012-10-17 15:25:28 +0000
@@ -1,5 +1,6 @@
1description: A first sample test case.1description: A first sample test case.
2command: python test_one.py2command: python test_one.py
3run_as: utah
3dependencies: n/a4dependencies: n/a
4action: |5action: |
5 1. Action 16 1. Action 1
67
=== modified file 'utah/client/examples/utah_tests/test_two/tc_control'
--- utah/client/examples/utah_tests/test_two/tc_control 2012-08-13 16:22:08 +0000
+++ utah/client/examples/utah_tests/test_two/tc_control 2012-10-17 15:25:28 +0000
@@ -1,5 +1,6 @@
1description: A second sample test case.1description: A second sample test case.
2command: python test_two.py2command: python test_two.py
3run_as: utah
3dependencies: n/a4dependencies: n/a
4action: |5action: |
5 1. Action 16 1. Action 1
67
=== modified file 'utah/client/examples/utah_tests_sample/sample_one/tc_control'
--- utah/client/examples/utah_tests_sample/sample_one/tc_control 2012-08-16 10:23:36 +0000
+++ utah/client/examples/utah_tests_sample/sample_one/tc_control 2012-10-17 15:25:28 +0000
@@ -8,5 +8,6 @@
8timeout: 2008timeout: 200
9build_cmd: echo "building for sample_one"9build_cmd: echo "building for sample_one"
10command: python sample.py10command: python sample.py
11run_as: utah
11tc_setup: echo "setup for sample_one"12tc_setup: echo "setup for sample_one"
12tc_cleanup: echo "cleanup for sample_one"13tc_cleanup: echo "cleanup for sample_one"
1314
=== modified file 'utah/client/testcase.py'
--- utah/client/testcase.py 2012-10-11 15:23:37 +0000
+++ utah/client/testcase.py 2012-10-17 15:25:28 +0000
@@ -64,6 +64,10 @@
64 'type': 'string',64 'type': 'string',
65 'required': True,65 'required': True,
66 },66 },
67 'run_as': {
68 'type': 'string',
69 'required': True,
70 },
67 'tc_setup': {'type': 'string'},71 'tc_setup': {'type': 'string'},
68 'tc_cleanup': {'type': 'string'},72 'tc_cleanup': {'type': 'string'},
69 'reboot': {73 'reboot': {
7074
=== modified file 'utah/client/testsuite.py'
--- utah/client/testsuite.py 2012-10-11 13:47:30 +0000
+++ utah/client/testsuite.py 2012-10-17 15:25:28 +0000
@@ -50,8 +50,6 @@
50 'type': 'string',50 'type': 'string',
51 'required': True,51 'required': True,
52 },52 },
53 'command': {'type': 'string'},
54 'run_as': {'type': 'string'},
55 'overrides': {'type': 'object'},53 'overrides': {'type': 'object'},
56 },54 },
57 },55 },
5856
=== modified file 'utah/group.py'
--- utah/group.py 2012-10-04 15:56:03 +0000
+++ utah/group.py 2012-10-17 15:25:28 +0000
@@ -9,13 +9,10 @@
9from utah import config9from utah import config
1010
1111
12def check_user_group(group=config.group, rootok=False):12def check_user_group(group=config.group):
13 """13 """
14 Return if the user is a member of the given group14 Return if the user is a member of the given group
15 """15 """
16 if rootok and os.getuid() == 0:
17 return True
18
19 user_gids = os.getgroups()16 user_gids = os.getgroups()
20 gid = grp.getgrnam(group).gr_gid17 gid = grp.getgrnam(group).gr_gid
2118

Subscribers

People subscribed via source and target branches