Skip to content

Commit

Permalink
Run tests based on existence of report on dokuwiki.
Browse files Browse the repository at this point in the history
- Instead of checking github's githash with local githash,
  now a check is made whether a report of this hash exists
  on dokuwiki or not.
  • Loading branch information
Karan Desai committed Jul 13, 2016
1 parent b671e54 commit 4c93337
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions tardis/tests/integration_tests/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import logging
import subprocess
import time
import yaml

import dokuwiki
import requests
from tardis import __githash__ as tardis_githash


logger = logging.getLogger(__name__)
Expand All @@ -16,29 +17,49 @@
help="Path to YAML config file for integration tests.")
parser.add_argument("--atomic-dataset", dest="atomic_dataset",
help="Path to atomic dataset.")
parser.add_argument("--less-packets", action="store_true", default=False,
help="Run integration tests with less packets.")


def run_tests():
args = parser.parse_args()

integration_tests_config = yaml.load(open(args.yaml_filepath))
doku_conn = dokuwiki.DokuWiki(
url=integration_tests_config['dokuwiki']['url'],
user=integration_tests_config['dokuwiki']['username'],
password=integration_tests_config['dokuwiki']['password']
)
less_packets = "--less-packets" if args.less_packets else ""
test_command = [
"python", "setup.py", "test",
"--test-path=tardis/tests/integration_tests/test_integration.py", "--args",
"--capture=no --integration-tests={0} --atomic-dataset={1} --remote-data "
"{2}".format(args.yaml_filepath, args.atomic_dataset, less_packets)
]
subprocess.call(test_command)

while True:
# Request Github API and get githash of master on Github.
gh_request = requests.get(
"https://api.github.com/repos/tardis-sn/tardis/branches/master"
)
gh_master_head_data = json.loads(gh_request.content)
gh_tardis_githash = gh_master_head_data['commit']['sha']
gh_tardis_githash = gh_master_head_data['commit']['sha'][:7]

if gh_tardis_githash != tardis_githash:
subprocess.call([
"git", "pull", "https://www.github.com/tardis-sn/tardis", "master"
])
# Check whether a report of this githash is uploaded on dokuwiki.
# If not, then this is a new commit and tests should be executed.
dokuwiki_report = doku_conn.pages.get(
"reports:{0}".format(gh_tardis_githash)
)

# If dokuwiki returns empty string, then it means that report has not
# been created yet.
if len(dokuwiki_report) == 0:
subprocess.call([
"python", "setup.py", "test",
"--test-path=tardis/tests/integration_tests/test_integration.py", "--args",
"-rs --integration-tests={0} --atomic-dataset={1} --remote-data".format(
args.yaml_filepath, args.atomic_dataset
)
"git", "pull", "https://www.github.com/tardis-sn/tardis", "master"
])
subprocess.call(test_command)
else:
checked = datetime.datetime.now()
logger.info("Up-to-date. Checked on {0} {1}".format(
Expand Down

0 comments on commit 4c93337

Please sign in to comment.