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

show and scan: add JSON option and metadata #2558

Merged
merged 16 commits into from
Feb 6, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add cylc scan --describe meta output and test
  • Loading branch information
sadielbartholomew committed Jan 29, 2018
commit d56f3877c7b3a9c9c3391dd9d6036472704b8dbf
61 changes: 32 additions & 29 deletions bin/cylc-scan
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def main():

parser.add_option(
"-d", "--describe",
help="Print suite titles and descriptions if available.",
help="Print suite metadata if available.",
action="store_true", default=False, dest="describe")

parser.add_option(
Expand Down Expand Up @@ -267,40 +267,43 @@ def main():

if options.describe:
try:
title = suite_identity[KEY_META].get(KEY_TITLE)
meta_items = suite_identity[KEY_META]
except KeyError:
# Compat:<=7.5.0
title = suite_identity.get(KEY_TITLE)
if title is None:
print indent + bold("(description and state totals withheld)")
meta_items = {
"title": suite_identity.get(KEY_TITLE),
"description": suite_identity.get(KEY_DESCRIPTION)
}

# Deal with the title first for case of just withheld statement
if not meta_items["title"]:
print indent + bold("(description and state totals "
"withheld)")
continue
print indent + bold("Title:")
if title == "":
line = "(no title)"
else:
line = '"%s"' % title
print indent * 2 + line

try:
description = suite_identity[KEY_META].get(KEY_DESCRIPTION)
except KeyError:
# Compat:<=7.5.0
description = suite_identity.get(KEY_DESCRIPTION)
print indent + bold("Description:")
if description == "":
lines = "(no description)"
else:
lines = '"%s"' % description
line1 = True
for line in lines.split('\n'):
line = line.lstrip()
if not line1:
# Indent under the double quote.
line = " " + line
line1 = False
print indent * 2 + line
print (indent + bold("Title:\n") + indent * 2 +
'"%s"' % meta_items["title"])
for metaitem in meta_items.keys():
if metaitem != "title":
if metaitem == "description" or metaitem == "group":
print indent + bold(metaitem.capitalize() + ":")
else:
print indent + bold(metaitem + ":")
if not meta_items[metaitem]:
lines = "(no %s)" % metaitem
else:
lines = '"%s"' % meta_items[metaitem]
line1 = True
for line in lines.split('\n'):
line = line.lstrip()
if not line1:
# Indent under the double quote.
line = " " + line
line1 = False
print indent * 2 + line

totals = suite_identity.get(KEY_STATES)

if options.print_totals:
if totals is None:
print indent + bold("(state totals withheld)")
Expand Down
4 changes: 4 additions & 0 deletions tests/authentication/01-description.t
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ cmp_ok 'scan.out' <<__END__
${SUITE_NAME} ${USER}@${HOST}:${PORT}
Title:
"Authentication test suite."
URL:
(no URL)
Group:
(no group)
Description:
"Stalls when the first task fails."
(state totals withheld)
Expand Down
4 changes: 4 additions & 0 deletions tests/authentication/02-state-totals.t
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ cmp_ok 'scan.out' <<__END__
${SUITE_NAME} ${USER}@${HOST}:${PORT}
Title:
"Authentication test suite."
URL:
(no URL)
Group:
(no group)
Description:
"Stalls when the first task fails."
Task state totals:
Expand Down
4 changes: 4 additions & 0 deletions tests/authentication/03-full-read.t
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ cmp_ok 'scan.out' <<__END__
${SUITE_NAME} ${USER}@${HOST}:${PORT}
Title:
"Authentication test suite."
URL:
(no URL)
Group:
(no group)
Description:
"Stalls when the first task fails."
Task state totals:
Expand Down
4 changes: 4 additions & 0 deletions tests/authentication/04-shutdown.t
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ cmp_ok 'scan.out' <<__END__
${SUITE_NAME} ${USER}@${HOST}:${PORT}
Title:
"Authentication test suite."
URL:
(no URL)
Group:
(no group)
Description:
"Stalls when the first task fails."
Task state totals:
Expand Down
4 changes: 4 additions & 0 deletions tests/authentication/05-full-control.t
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ cmp_ok 'scan.out' <<__END__
${SUITE_NAME} ${USER}@${HOST}:${PORT}
Title:
"Authentication test suite."
URL:
(no URL)
Group:
(no group)
Description:
"Stalls when the first task fails."
Task state totals:
Expand Down
4 changes: 4 additions & 0 deletions tests/authentication/06-suite-override.t
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ cmp_ok 'scan.out' <<__END__
${SUITE_NAME} ${USER}@${HOST}:${PORT}
Title:
"Authentication test suite."
URL:
(no URL)
Group:
(no group)
Description:
"Stalls when the first task fails.
Suite overrides global authentication settings."
Expand Down
4 changes: 4 additions & 0 deletions tests/authentication/07-sha-hash.t
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ cmp_ok 'scan.out' <<__END__
${SUITE_NAME} ${USER}@${HOST}:${PORT}
Title:
"Authentication test suite."
URL:
(no URL)
Group:
(no group)
Description:
"Stalls when the first task fails."
Task state totals:
Expand Down
41 changes: 38 additions & 3 deletions tests/cylc-scan/00-simple.t
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,50 @@
# Test cylc scan is picking up running suite
. $(dirname $0)/test_header
#-------------------------------------------------------------------------------
set_test_number 2
set_test_number 6
create_test_globalrc
host_port_ref () {
SUITE=$1
FQDN=$(python -c "import sys
sys.path.insert(0, '$CYLC_HOME')
import cylc.hostuserutil
print cylc.hostuserutil.get_fqdn_by_host('`hostname`')")
PORT=$(sed -n 's/CYLC_SUITE_PORT=//p' \
"${HOME}/cylc-run/${SUITE}/.service/contact")
echo "$SUITE `whoami`@$FQDN:$PORT"
}
#-------------------------------------------------------------------------------
install_suite $TEST_NAME_BASE simple
install_suite $TEST_NAME_BASE ctb-cylc-scan-simple
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-validate
run_ok $TEST_NAME cylc validate $SUITE_NAME
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-run
suite_run_ok $TEST_NAME cylc run --reference-test --debug --no-detach $SUITE_NAME
run_ok $TEST_NAME cylc run $SUITE_NAME --hold
SCAN_LINE=$(host_port_ref "${SUITE_NAME}")
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-basic
run_ok $TEST_NAME cylc scan --no-bold -n "$SUITE_NAME"
cmp_ok "$TEST_NAME.stdout" <<<${SCAN_LINE}
#-------------------------------------------------------------------------------
TEST_NAME=$TEST_NAME_BASE-describe
run_ok $TEST_NAME cylc scan --no-bold --describe -n "$SUITE_NAME"
cmp_ok "$TEST_NAME.stdout" <<__SHOW_OUTPUT__
${SCAN_LINE}
Title:
"A simple test"
Group:
(no group)
Description:
"A simple test to simply test whether cylc scan is
doing the right thing - let's see what happens."
URL:
(no URL)
datum:
"metadatum"
another_datum:
"another_metadatum"
__SHOW_OUTPUT__
#-------------------------------------------------------------------------------
cylc stop $SUITE_NAME --now
purge_suite $SUITE_NAME
18 changes: 18 additions & 0 deletions tests/cylc-scan/ctb-cylc-scan-simple/suite.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[meta]
title = A simple test
description = """A simple test to simply test whether cylc scan is
doing the right thing - let's see what happens."""
datum = metadatum
another_datum = another_metadatum

[cylc]
[[reference test]]
required run mode = live
live mode suite timeout = PT1M
[scheduling]
[[dependencies]]
graph = "foo"
[runtime]
[[foo]]
[[bar]]
[[baz]]
10 changes: 0 additions & 10 deletions tests/cylc-scan/simple/suite.rc

This file was deleted.