From 21e9fcde499066941db9bc098f8dd7ac52185e9b Mon Sep 17 00:00:00 2001 From: mgietzmann Date: Thu, 5 Apr 2018 11:49:25 -0400 Subject: [PATCH 1/2] rebranded the mission critical bits --- drive/drive.py | 14 +++++++------- drive/selenium_methods.py | 32 ++++++++++++++++---------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/drive/drive.py b/drive/drive.py index e73894b..c692843 100755 --- a/drive/drive.py +++ b/drive/drive.py @@ -55,8 +55,8 @@ USR_AGENT_OSX = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36" USR_AGENT_WIN = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36" USR_AGENT_LINUX = "??" -WINDOWS_SPARROW_LOCATION = 'C:\\Users\\%s\\AppData\\Local\\ViaSat\\Sparrow\\Application\\sparrow.exe' -MAC_SPARROW_LOCATION = '/Applications/Sparrow.app/Contents/MacOS/Sparrow' +WINDOWS_SPARROW_LOCATION = 'C:\\Program Files (x86)\\ViaSat\\Viasat Browser\\Application\\Viasat Browser.exe' +MAC_SPARROW_LOCATION = '/Applications/Viasat Browser.app/Contents/MacOS/Viasat Browser' class SparrowDriver(object): @@ -149,7 +149,7 @@ def json_config_parser(self, json_data): elif 'win' in sys.platform.lower(): self.binary_location = json_data.get('sparrow_location_windows', - WINDOWS_SPARROW_LOCATION % self.username) + WINDOWS_SPARROW_LOCATION) if 'cygwin' in sys.platform.lower(): cmd = ['wmic', 'datafile', 'where', r'name="%s"' % self.binary_location.replace('\\', '\\\\'), 'get', 'Version'] @@ -225,7 +225,7 @@ def add_options(self, chromiumlike, cache_state): driver_options.add_argument('--user-data-dir=%s' % self.sparrow_user_data_dir) for switch in self.sparrow_only_switches: driver_options.add_argument(switch) - logging.debug("Adding switch to sparrow only: %s" % switch) + logging.debug("Adding switch to Viasat Browser only: %s" % switch) # Passed from config file for switch in self.common_switches: @@ -255,7 +255,7 @@ def visit_sites(self, chromiumlike, cache_state): driver_options = self.add_options(chromiumlike, cache_state) selenium_methods.stop_sparrow() - # launch sparrow and initial tabs + # launch Viasat Browser and initial tabs remote, beerstatus_tab, content_tab = selenium_methods.start_remote(self.service.service_url, driver_options) # Used to verify that the current beer is unique and new @@ -348,7 +348,7 @@ def visit_sites(self, chromiumlike, cache_state): num_tries = 40 trys = 0 while (trys < num_tries): - remote.get("sparrow://beerstatus") + remote.get("viasat://beerstatus") if selenium_methods.check_beer_status(site, beer_status_dict, remote): break @@ -376,7 +376,7 @@ def run_service(self): if not os.path.exists('./screenshots'): os.mkdir( './screenshots', 0755 ); - # Loop forever togging between sparrow and chromiumlike modes if alternate_sparrow_chromium = True + # Loop forever togging between Viasat Browser and chromiumlike modes if alternate_sparrow_chromium = True # Alternate cold and warm cache between runs through the list clear_cache = True chromiumlike_mode = True if self.chromiumlike_only else False diff --git a/drive/selenium_methods.py b/drive/selenium_methods.py index 825c8e5..4fd5eb7 100644 --- a/drive/selenium_methods.py +++ b/drive/selenium_methods.py @@ -31,7 +31,7 @@ 'mac': '', 'linux': ''} -# Used to drive sparrow with 'on hover' when indicated in the feature file +# Used to drive Viasat Browser with 'on hover' when indicated in the feature file HYPERLINK_TEMPLATE_URL = "http://bizzbyster.github.io/sitelists/hyperlink_template.html" HOVER_TIME = 0.5 @@ -74,7 +74,7 @@ def runWebdriver(context, browser_name, op_sys): sparrow_version_info = browser_dict['controller'].getVersionInfo(skipVerifyingFlag=True) # sparrow_buildnum is inclulded in the test label sparrow_buildnum = sparrow_version_info.sparrowBuildnum - logging.info("Sparrow buildnum on %s is %s" % (cpe_ip, sparrow_buildnum)) + logging.info("Viasat Browser buildnum on %s is %s" % (cpe_ip, sparrow_buildnum)) else: sparrow_buildnum = 'chromiumlike' @@ -83,7 +83,7 @@ def runWebdriver(context, browser_name, op_sys): logging.info("setting test label for test running on %s now..." % cpe_ip) test_name = context.scenario.name.replace(' ', '') - # Add timestamp and either lift name or sparrow buildnum to test label + # Add timestamp and either lift name or Viasat Browser buildnum to test label label_identifier = context.common.liftName if context.common.liftName else sparrow_buildnum test_label = common_utils.createTestLabel(test_name, label_identifier) @@ -132,7 +132,7 @@ def generateCmdSwitches(context, row, test_name, browser_name, browser_dict=None cmdSwitches.append('--hinting-scope=' + context.common.testIds[browser_name].get('scope')) - # Some cmdSwitches passed through behave are only for sparrow with features enabled + # Some cmdSwitches passed through behave are only for Viasat Browser with features enabled if "chromiumlike" in browser_name.lower(): browser_version_info = browser_dict['controller'].getVersionInfo(skipVerifyingFlag=True) chromium_version = browser_version_info.chromiumVersion @@ -144,7 +144,7 @@ def generateCmdSwitches(context, row, test_name, browser_name, browser_dict=None cmdSwitches.append('--user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36"' % chromium_version) else: cmdSwitches.append('--ihs-hint-url=%s' % context.common.ihsGatewayUrl + '/hint') - cmdSwitches.append('--sparrow-force-fieldtrial') # disables sparrow field trials + cmdSwitches.append('--sparrow-force-fieldtrial') # disables Viasat Browser field trials if not [switch for switch in cmdSwitches if '--viasat-hint-prerequest=' in switch]: cmdSwitches.append('--viasat-hint-prerequest=http://www.google.com/') @@ -163,7 +163,7 @@ def runSelenium(context, browser_name, browser_dict, cpeLocation, cmdSwitches, o is_windows = op_sys == 'windows' sparrow_controller.stopSparrow() - # Cleanup leftover .dat files from --bb-on-beer; hopefully this is temporary, waiting on sparrow fix + # Cleanup leftover .dat files from --bb-on-beer; hopefully this is temporary, waiting on Viasat Browser fix sparrow_controller.removeLeftoverBBs() if not sparrow_controller.startWebdriver(exe_loc=WEBDRIVER_LOC[op_sys], whitelist_ip=context.common.jenkinsIp): @@ -199,7 +199,7 @@ def runSelenium(context, browser_name, browser_dict, cpeLocation, cmdSwitches, o context.numClicksTotal = context.listIterations * context.urlListLen context.numClicksPerSite = context.listIterations - logging.info("running webdriver test on %s with sparrow switches: %s now.." % (cpe_ip, "; ".join(cmdSwitches))) + logging.info("running webdriver test on %s with Viasat Browser switches: %s now.." % (cpe_ip, "; ".join(cmdSwitches))) logging.info("Running selenium webdriver on %s with sitelist: %s" % (cpe_ip, str(context.sitelist))) # k = url, v = beerID ; used to verify that the current beer is unique and new @@ -221,7 +221,7 @@ def runSelenium(context, browser_name, browser_dict, cpeLocation, cmdSwitches, o logging.info('Loading url: %s on cpe: %s' % (site, cpe_ip)) remote.switch_to_window(content_tab) - if site[0:15] == 'sparrow://crash': + if site[0:15] == 'viasat://crash': res = load_url_and_crash(site, remote) if cache_state.lower() == 'warm': sparrow_controller.removeDir(dir_path=user_data_warm) @@ -240,7 +240,7 @@ def runSelenium(context, browser_name, browser_dict, cpeLocation, cmdSwitches, o num_tries = 20 trys = 0 for i in range(num_tries): - load_url("sparrow://beerstatus/", remote) + load_url("viasat://beerstatus/", remote) if check_beer_status(site, beer_status_dict, remote): break @@ -307,10 +307,10 @@ def load_url_and_crash(url, remote): try: remote.get(url) # if we are here, we have not crash! - logging.info("Sparrow did not crash, error") + logging.info("Viasat Browser did not crash, error") return False except: - logging.info("Sparrow crashed as expected") + logging.info("Viasat Browser crashed as expected") return True @@ -325,13 +325,13 @@ def start_remote(cpe_location, driver_options, sparrow_controller=None): try: remote = webdriver.Remote(cpe_location, driver_options.to_capabilities()) #open two blank tabs to start, one for content, one for beer ack - remote.execute_script("window.open('about:blank', 'sparrow://beerstatus');") + remote.execute_script("window.open('about:blank', 'viasat://beerstatus');") all_tabs = remote.window_handles beerstatus_tab = all_tabs[0] content_tab = all_tabs[-1] remote.switch_to_window(beerstatus_tab) - remote.get("sparrow://beerstatus/") + remote.get("viasat://beerstatus/") break except Exception as e: @@ -350,10 +350,10 @@ def start_remote(cpe_location, driver_options, sparrow_controller=None): def stop_sparrow(): if "darwin" in sys.platform: - cmd = ["pkill", "-9", "Sparrow"] + cmd = ["pkill", "-9", "Viasat Browser"] elif "win" in sys.platform: - cmd = ["taskkill", "/IM", "Sparrow.exe", "/F"] + cmd = ["taskkill", "/IM", "Viasat Browser.exe", "/F"] # Best effort, not checking return p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -381,7 +381,7 @@ def check_beer_status(url, beer_status_dict, remote): logging.info("Beer Ack is misconfigured, will not check for Ack.") return True elif acked == '0': - logging.info("Sparrow did not receive beer ack for %s" % url) + logging.info("Viasat Browser did not receive beer ack for %s" % url) return True elif (acked == '1' and beer_dict.get('BEER for url') == url and From e894f7b9bf36937e95a90dd5289272638f71e1f3 Mon Sep 17 00:00:00 2001 From: mgietzmann Date: Thu, 5 Apr 2018 11:51:16 -0400 Subject: [PATCH 2/2] caught something weird --- drive/drive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drive/drive.py b/drive/drive.py index c692843..7202f73 100755 --- a/drive/drive.py +++ b/drive/drive.py @@ -374,7 +374,7 @@ def run_service(self): if self.save_screenshots: if not os.path.exists('./screenshots'): - os.mkdir( './screenshots', 0755 ); + os.mkdir('./screenshots', 0755) # Loop forever togging between Viasat Browser and chromiumlike modes if alternate_sparrow_chromium = True # Alternate cold and warm cache between runs through the list