Return-Path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=profusion-mobi.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=jRZWmVbuS1DvTkrfn8duKtcfk5NEsiQOhSpV1joaOME=; b=ntCFxssGE3rIfcg6Vmv5VIi4G08GsuY3gYdxqrxaeBXUhYJQfG9v26M1NSz3o/8/j9 AIsWIE0zxImY8LyAdbpHKs2Wb6xLbJlsJpiseDfQUNzQBjWkMjGE4BImcjDIb+/FA6i6 CzZvvU734px9GweRK1h0oAT13fKfbyFvbf84N2AvfPQO3M49CyyZwv1N2SgSQKJPIfcO Lt827F5CgpbJLoHIS81BfuPMEB2afy722U1/3m01Ku/0Y7cZmrpXdzgPuln7/OKiQL5I bYJ7HOUU/1Ro+Ypg6JSAf8s/vBnP1MqJpQxjptPWnPhGoMNylx+57b0dzXIQpV0+IudL r0xw== From: Guilherme Campos Camargo Date: Thu, 8 Feb 2018 16:51:33 -0200 Message-Id: <20180208185133.9092-1-guicc@profusion.mobi> Subject: [Fuego] [PATCH] Allow ftc script to properly use Jenkins configured port List-Id: Mailing list for the Fuego test framework List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: fuego@lists.linuxfoundation.org Hello, Tim. Please see my modifications below. I was looking for an utils directory/submodule with existing python stuff where I could store the newly added read_conf function, but haven't found any. Given that the function file is very straightforward, I just left it in here, right next to your other utility function. Please let me know if you'd rather have it moved somewhere else. Anyway, I think it would be nice if we could keep these and other python utility funcions in a separate submodule in the future, so that they can be easily imported by different python scripts. Please let me know what you think about that. Thanks -- Commit Message: With the possibility of configuring jenkins porth through fuego/ro/conf/fuego.conf, a change on ftc script is needed so that it uses the configured port and not the default one (8080). This patch solves that issue by using the ${jenkins_port} environment variable (set on entrypoint.sh) instead of the hardcoded 8080. Signed-off-by: Guilherme Campos Camargo --- engine/scripts/ftc | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/engine/scripts/ftc b/engine/scripts/ftc index 06dadcf..2cf0019 100755 --- a/engine/scripts/ftc +++ b/engine/scripts/ftc @@ -60,19 +60,33 @@ import glob # MAJOR, MINOR, REVISION VERSION = (1,2,1) -# define these as globals -log = None -tail_fd = None - # here's a utility routine to print a variable with it's name and value def pvar(name): caller = sys._getframe(1) print "DEBUG: python var %s=%s" % (name, caller.f_locals[name]) +# here's a utility routine that reads from a configuration file where configs +# are stored as KEY=VALUE pairs (as .env files) +def read_conf(fname): + def split_pair(line): + return line.strip().split('=', 1) + with open(fname) as f: + pairs = [split_pair(line) for line in f.readlines()] + return dict(pairs) + +# define these as globals +log = None +tail_fd = None + +FUEGO_CFG_PATH = '/fuego-ro/conf/fuego.conf' +fuego_config = read_conf(FUEGO_CFG_PATH) +jenkins_port = fuego_config.get('jenkins_port', 8080) +fuego_url = 'http://localhost:' + str(jenkins_port) + '/fuego' + quiet = 0 verbose = 0 use_statusouput = 1 -server = jenkins.Jenkins('http://localhost:8080/fuego') +server = jenkins.Jenkins(fuego_url) # keep configuration file in /fuego-ro/conf area config_dir = "/fuego-ro" @@ -413,7 +427,7 @@ class config_class: # fuegotest.com is at: 52.88.166.49 self.SERVER_URL_BASE = "http://52.88.166.49/server/Fuego_Server?action=Fuego." - self.JENKINS_URL = "http://localhost:8080/fuego" + self.JENKINS_URL = fuego_url # end of default configs @@ -1159,7 +1173,7 @@ timeout --signal=9 {timeout} /bin/bash $FUEGO_CORE/engine/scripts/main.sh job_name=board+"."+test.spec+"."+test.name print("Creating job " + job_name) try: - subprocess.call('java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080/fuego create-job ' + + subprocess.call('java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -s' + fuego_url + 'create-job ' + job_name + ' < ' + tmp, shell=True) os.unlink(tmp) except Exception as e: @@ -1207,7 +1221,7 @@ def create_batch_job(board, testplan, plan_tests): print("Creating batch job ") try: job_name = board+'.'+testplan+'.batch' - subprocess.call('java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080/fuego create-job ' + + subprocess.call('java -jar /var/cache/jenkins/war/WEB-INF/jenkins-cli.jar -s' + fuego_url + 'create-job ' + job_name + '< ' + tmp, shell=True) os.unlink(tmp) except Exception as e: -- 2.16.1