-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for compose-image-rtt-tests in pdc client
Support list, info, update sub-commands. Only test result is allowed to update. JIRA: PDC-1260
- Loading branch information
Showing
6 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (c) 2015 Red Hat | ||
# Licensed under The MIT License (MIT) | ||
# http://opensource.org/licenses/MIT | ||
# | ||
import json | ||
|
||
from pdc_client import get_paged | ||
from pdc_client.plugin_helpers import PDCClientPlugin, add_parser_arguments, extract_arguments | ||
|
||
|
||
class ComposeImageRTTTestsPlugin(PDCClientPlugin): | ||
def register(self): | ||
self.set_command('compose-image-rtt-tests') | ||
list_parser = self.add_action('list', help='list all compose image rtt tests') | ||
add_parser_arguments(list_parser, {'compose': {}, | ||
'variant': {}, | ||
'arch': {}, | ||
'file_name': {}, | ||
'test_result': {}}, | ||
group='Filtering') | ||
list_parser.set_defaults(func=self.list_compose_image_rtt_tests) | ||
|
||
info_parser = self.add_action('info', help='display details of a compose image RTT test') | ||
self._add_common_arguments(info_parser) | ||
info_parser.set_defaults(func=self.compose_image_rtt_test_info) | ||
|
||
help_text = 'update an existing compose image\'s RTT test result (untested, passed or failed)' | ||
update_parser = self.add_action('update', help=help_text) | ||
self._add_common_arguments(update_parser) | ||
add_parser_arguments(update_parser, {'test_result': {'choices': ['passed', 'failed', 'untested']}}) | ||
update_parser.set_defaults(func=self.compose_image_rtt_test_update) | ||
|
||
def _add_common_arguments(self, parser): | ||
parser.add_argument('compose_id', metavar='COMPOSE_ID') | ||
parser.add_argument('variant_uid', metavar='VARIANT_UID') | ||
parser.add_argument('arch', metavar='ARCH') | ||
parser.add_argument('file_name', metavar='FILE_NAME') | ||
|
||
def _print_compose_image_rtt_test_list(self, rtt_tests): | ||
if rtt_tests: | ||
print '{0:<50} {1:20} {2:10} {3:70} {4}\n'.format( | ||
'Compose', | ||
'Variant', | ||
'Arch', | ||
'File Name', | ||
'Test Result') | ||
for test in rtt_tests: | ||
print '{0:<50} {1:20} {2:10} {3:70} {4}'.format( | ||
test['compose'], | ||
test['variant'], | ||
test['arch'], | ||
test['file_name'], | ||
test['test_result']) | ||
|
||
def list_compose_image_rtt_tests(self, args): | ||
filters = extract_arguments(args) | ||
rtt_tests = get_paged(self.client['compose-image-rtt-tests']._, **filters) | ||
if args.json: | ||
print json.dumps(list(rtt_tests)) | ||
return | ||
self._print_compose_image_rtt_test_list(rtt_tests) | ||
|
||
def _display_test_info_detail(self, args, test_info): | ||
if args.json: | ||
print json.dumps(test_info) | ||
return | ||
fmt = '{0:20} {1}' | ||
print fmt.format('Compose', test_info['compose']) | ||
print fmt.format('Variant', test_info['variant']) | ||
print fmt.format('Arch', test_info['arch']) | ||
print fmt.format('File Name', test_info['file_name']) | ||
print fmt.format('Test Result', test_info['test_result']) | ||
|
||
def compose_image_rtt_test_info(self, args): | ||
test_info =\ | ||
self.client['compose-image-rtt-tests'][args.compose_id][args.variant_uid][args.arch][args.file_name]._() | ||
self._display_test_info_detail(args, test_info) | ||
|
||
def compose_image_rtt_test_update(self, args): | ||
patch_data = extract_arguments(args) | ||
self.client['compose-image-rtt-tests'][args.compose_id][args.variant_uid][args.arch][args.file_name]._ += \ | ||
patch_data | ||
data = {'compose': args.compose_id, | ||
'variant': args.variant_uid, | ||
'arch': args.arch, | ||
'file_name': args.file_name} | ||
data.update(patch_data) | ||
self._display_test_info_detail(args, data) | ||
|
||
|
||
PLUGIN_CLASSES = [ComposeImageRTTTestsPlugin] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"arch": "x86_64", | ||
"compose": "RHEL-7.0-0", | ||
"variant": "Client", | ||
"test_result": "untested", | ||
"file_name": "RHEL-7.0-1-Client-x86_64-boot.iso" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"arch": "x86_64", | ||
"compose": "RHEL-7.0-0", | ||
"variant": "Client", | ||
"test_result": "passed", | ||
"file_name": "RHEL-7.0-1-Client-x86_64-boot.iso" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Compose Variant Arch File Name Test Result | ||
|
||
RHEL-7.0-0 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-1 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-2 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-3 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-4 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-5 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-6 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-7 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-8 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-9 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-10 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-11 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-12 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-13 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-14 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-15 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-16 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-17 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-18 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-19 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-20 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-21 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-22 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-23 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-24 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-25 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-26 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-27 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-28 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested | ||
RHEL-7.0-29 Client x86_64 RHEL-7.0-1-Client-x86_64-boot.iso untested |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (c) 2015 Red Hat | ||
# Licensed under The MIT License (MIT) | ||
# http://opensource.org/licenses/MIT | ||
# | ||
from pdc_client.test_helpers import CLITestCase | ||
from pdc_client.runner import Runner | ||
from copy import deepcopy | ||
|
||
|
||
class ComposeImageRTTTestsTestCase(CLITestCase): | ||
def setUp(self): | ||
self.runner = Runner() | ||
self.runner.setup() | ||
|
||
def _setup_list(self, api): | ||
api.add_endpoint('compose-image-rtt-tests', 'GET', [ | ||
{"arch": "x86_64", | ||
"compose": "RHEL-7.0-{0}".format(x), | ||
"variant": "Client", | ||
"test_result": "untested", | ||
"file_name": "RHEL-7.0-1-Client-x86_64-boot.iso"} | ||
for x in range(30) | ||
]) | ||
|
||
def _setup_detail(self, api): | ||
obj = {"arch": "x86_64", | ||
"compose": "RHEL-7.0-0", | ||
"variant": "Client", | ||
"test_result": "untested", | ||
"file_name": "RHEL-7.0-1-Client-x86_64-boot.iso"} | ||
api.add_endpoint("""compose-image-rtt-tests/RHEL-7.0-0/Client/x86_64/RHEL-7.0-1-Client-x86_64-boot.iso""", | ||
'GET', obj) | ||
# PATCH test result to passed | ||
obj_update = deepcopy(obj) | ||
obj_update["test_result"] = "passed" | ||
api.add_endpoint("""compose-image-rtt-tests/RHEL-7.0-0/Client/x86_64/RHEL-7.0-1-Client-x86_64-boot.iso""", | ||
'PATCH', obj_update) | ||
|
||
def test_list(self, api): | ||
self._setup_list(api) | ||
with self.expect_output('list_multi_page.txt'): | ||
self.runner.run(['compose-image-rtt-tests', 'list']) | ||
self.assertEqual(api.calls['compose-image-rtt-tests'], | ||
[('GET', {'page': 1}), | ||
('GET', {'page': 2})]) | ||
|
||
def test_info(self, api): | ||
self._setup_detail(api) | ||
with self.expect_output('detail.json', parse_json=True): | ||
self.runner.run(['--json', 'compose-image-rtt-tests', 'info', 'RHEL-7.0-0', 'Client', | ||
'x86_64', 'RHEL-7.0-1-Client-x86_64-boot.iso']) | ||
self.assertEqual( | ||
api.calls['compose-image-rtt-tests/RHEL-7.0-0/Client/x86_64/RHEL-7.0-1-Client-x86_64-boot.iso'], | ||
[('GET', {})]) | ||
|
||
def test_update(self, api): | ||
self._setup_detail(api) | ||
with self.expect_output('detail_for_patch.json', parse_json=True): | ||
self.runner.run(['--json', 'compose-image-rtt-tests', 'update', 'RHEL-7.0-0', 'Client', | ||
'x86_64', 'RHEL-7.0-1-Client-x86_64-boot.iso', '--test-result', 'passed']) | ||
self.assertEqual( | ||
api.calls['compose-image-rtt-tests/RHEL-7.0-0/Client/x86_64/RHEL-7.0-1-Client-x86_64-boot.iso'], | ||
[('PATCH', {"test_result": "passed"})]) |