Skip to content

Commit

Permalink
Interpolate user home in config file template
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmitterdorfer committed Aug 17, 2016
1 parent bf22f34 commit 71dfd7a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
17 changes: 13 additions & 4 deletions night_rally.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
import shutil
import logging
import fileinput

tracks = collections.OrderedDict()

Expand Down Expand Up @@ -66,7 +67,7 @@
ch.setFormatter(formatter)
logging.root.addHandler(ch)

logger = logging.getLogger("night_rally.config")
logger = logging.getLogger("night_rally")


def date_for_cmd_param(d):
Expand All @@ -93,14 +94,19 @@ def run(tracks, effective_start_date):


def _configure_rally():
user_home = os.getenv("HOME")
root = os.path.dirname(os.path.realpath(__file__))
source = "%s/resources/rally-nightly.ini" % root
destination = "%s/.rally/rally-nightly.ini" % os.getenv("HOME")
destination = "%s/.rally/rally-nightly.ini" % user_home
logger.info("Copying rally configuration from [%s] to [%s]" % (source, destination))
shutil.copyfile(source, destination)
# materialize current user home
with fileinput.input(files=destination, inplace=True) as f:
for line in f:
print(line.replace("~", user_home))


def _run_rally( effective_start_date, tracks):
def _run_rally(effective_start_date, tracks, system=os.system):
ts = date_for_cmd_param(effective_start_date)
revision_ts = to_iso8601(effective_start_date)

Expand All @@ -115,7 +121,7 @@ def _run_rally( effective_start_date, tracks):
report_path = "%s/%s/rally/%s/%s/%s/%s/report.csv" % (root_dir, report_root_dir,
date_for_path(effective_start_date), track,
challenge, car)
if os.system(
if system(
"rally --configuration-name=nightly --pipeline={6} --quiet --revision \"@{0}\" --effective-start-date \"{1}\" "
"--track={2} --challenge={3} --car={4} --report-format=csv --report-file={5}"
.format(revision_ts, ts, track, challenge, car, report_path, pipeline)):
Expand Down Expand Up @@ -215,6 +221,9 @@ def report(effective_start_date, tracks, default_setup_per_track):
Publishes all data from the provided trial run.
:param effective_start_date: A timestamp for which we should publish data.
:param tracks: A hash of all tracks that have been run and their challenges.
:param default_setup_per_track: A hash of the default challenge / car per track.
"""
timestamp = date_for_path(effective_start_date)
# this timestamp gets used in the report files
Expand Down
4 changes: 2 additions & 2 deletions resources/rally-nightly.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
config.version = 5

[system]
root.dir = /home/dm/.rally/benchmarks
root.dir = ~/.rally/benchmarks
log.root.dir = logs
env.name = nightly

[source]
local.src.dir = /home/dm/.rally/benchmarks/src
local.src.dir = ~/.rally/benchmarks/src
remote.repo.url = https://github.com/elastic/elasticsearch.git

[build]
Expand Down

0 comments on commit 71dfd7a

Please sign in to comment.