Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rebranded the mission critical bits #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions drive/drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -374,9 +374,9 @@ 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 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
Expand Down
32 changes: 16 additions & 16 deletions drive/selenium_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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'

Expand All @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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/')
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down