cc64a3a585
This commit adds a generate_subunit.py script which is used to generate a subunit stream with a single result for a period of time. It takes 2 mandatory args and 2 optional to specify the start time, stop time, and optionally the status (it defaults to success) and an id for test (if one isn't provided 'devstack' is used) The resulting stream is written to STDOUT. There is some overlap with subunit-output from tool from python-subunit, but this is a much smaller scope to just just do a test_id, status, and timestamps. subunit-output doesn't support timestamps. Eventually it'll be good to add the missing pieces to subunit-output at which point we can likely deprecate and remove this. The intent here is to leverage this to inject 'test results' into the subunit2sql db to reflect failures that occur before tempest (or any other test suite) is run. This is necessary for the openstack-health dashboard. (otherwise it makes our failure rate look much better than it is) This is only needed until we get a zuul mysql reporter in place which can give us the higher level run information. Change-Id: Icc7df33e4d73ba6322af38fbdf3aea230f2fcf4d
51 lines
1.4 KiB
Python
Executable File
51 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python2
|
|
# Copyright 2015 Hewlett-Packard Development Company, L.P.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
|
|
import datetime
|
|
import sys
|
|
|
|
import subunit
|
|
from subunit import iso8601
|
|
|
|
|
|
def main():
|
|
start_time = datetime.datetime.fromtimestamp(float(sys.argv[1])).replace(
|
|
tzinfo=iso8601.UTC)
|
|
elapsed_time = datetime.timedelta(seconds=int(sys.argv[2]))
|
|
stop_time = start_time + elapsed_time
|
|
|
|
if len(sys.argv) > 3:
|
|
status = sys.argv[3]
|
|
else:
|
|
status = 'success'
|
|
|
|
if len(sys.argv) > 4:
|
|
test_id = sys.argv[4]
|
|
else:
|
|
test_id = 'devstack'
|
|
|
|
# Write the subunit test
|
|
output = subunit.v2.StreamResultToBytes(sys.stdout)
|
|
output.startTestRun()
|
|
output.status(timestamp=start_time, test_id=test_id)
|
|
# Write the end of the test
|
|
output.status(test_status=status, timestamp=stop_time, test_id=test_id)
|
|
output.stopTestRun()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|