From 815c589d7f5cd912f0785da2f4d4f1e88a343242 Mon Sep 17 00:00:00 2001
From: Sree Kuchibhotla <sreek@google.com>
Date: Fri, 25 Mar 2016 15:03:50 -0700
Subject: [PATCH] Pass gcp_project_id via command line. Makes it easier to run
 on different projects with the same configuration

---
 tools/run_tests/stress_test/configs/opt-tsan.json |  1 -
 tools/run_tests/stress_test/run_on_gke.py         | 12 ++++++------
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/tools/run_tests/stress_test/configs/opt-tsan.json b/tools/run_tests/stress_test/configs/opt-tsan.json
index dab78e5f4c..e0e487333a 100644
--- a/tools/run_tests/stress_test/configs/opt-tsan.json
+++ b/tools/run_tests/stress_test/configs/opt-tsan.json
@@ -98,7 +98,6 @@
     },
 
     "globalSettings": {
-      "projectId": "sreek-gce",
       "buildDockerImages": true,
       "pollIntervalSecs": 60,
       "testDurationSecs": 120,
diff --git a/tools/run_tests/stress_test/run_on_gke.py b/tools/run_tests/stress_test/run_on_gke.py
index c301cf441a..4ef53f1d86 100755
--- a/tools/run_tests/stress_test/run_on_gke.py
+++ b/tools/run_tests/stress_test/run_on_gke.py
@@ -307,9 +307,9 @@ class Gke:
 
 class Config:
 
-  def __init__(self, config_filename):
+  def __init__(self, config_filename, gcp_project_id):
     config_dict = self.load_config(config_filename)
-    self.global_settings = self.parse_global_settings(config_dict)
+    self.global_settings = self.parse_global_settings(config_dict, gcp_project_id)
     self.docker_images_dict = self.parse_docker_images(
         config_dict, self.global_settings.gcp_project_id)
     self.client_templates_dict = self.parse_client_templates(config_dict)
@@ -320,9 +320,9 @@ class Config:
         config_dict, self.docker_images_dict, self.client_templates_dict,
         self.server_pod_specs_dict)
 
-  def parse_global_settings(self, config_dict):
+  def parse_global_settings(self, config_dict, gcp_project_id):
     global_settings_dict = config_dict['globalSettings']
-    return GlobalSettings(global_settings_dict['projectId'],
+    return GlobalSettings(gcp_project_id,
                           global_settings_dict['buildDockerImages'],
                           global_settings_dict['pollIntervalSecs'],
                           global_settings_dict['testDurationSecs'],
@@ -564,7 +564,7 @@ def run_tests(config):
 argp = argparse.ArgumentParser(
     description='Launch stress tests in GKE',
     formatter_class=argparse.ArgumentDefaultsHelpFormatter)
-argp.add_argument('--project_id',
+argp.add_argument('--gcp_project_id',
                   required=True,
                   help='The Google Cloud Platform Project Id')
 argp.add_argument('--config_file',
@@ -574,5 +574,5 @@ argp.add_argument('--config_file',
 
 if __name__ == '__main__':
   args = argp.parse_args()
-  config = Config(args.config_file)
+  config = Config(args.config_file, args.gcp_project_id)
   run_tests(config)
-- 
GitLab