From 3ce4ec5cf9848788f51ac7d4991f6b9f29073e06 Mon Sep 17 00:00:00 2001 From: Qstick Date: Wed, 18 Sep 2019 23:00:24 -0400 Subject: [PATCH] fixup! Ensure Lidarr process is killed, exptend process start time --- .../AutomationTest.cs | 17 +++++++------- .../BrowserStackAutomationTest.cs | 23 +++++++++++++------ .../BrowserStackFixture.cs | 18 --------------- .../PageModel/PageBase.cs | 2 +- 4 files changed, 26 insertions(+), 34 deletions(-) delete mode 100644 src/NzbDrone.Automation.Test/BrowserStackFixture.cs diff --git a/src/NzbDrone.Automation.Test/AutomationTest.cs b/src/NzbDrone.Automation.Test/AutomationTest.cs index c53f2cd0a..b1cf448dd 100644 --- a/src/NzbDrone.Automation.Test/AutomationTest.cs +++ b/src/NzbDrone.Automation.Test/AutomationTest.cs @@ -25,6 +25,15 @@ namespace NzbDrone.Automation.Test public AutomationTest() { + string username = Environment.GetEnvironmentVariable("BROWSERSTACK_USERNAME"); + string accessKey = Environment.GetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY"); + string testType = this.GetType().Name; + + if (username.IsNotNullOrWhiteSpace() && accessKey.IsNotNullOrWhiteSpace() && !testType.Contains("BrowserStack")) + { + Assert.Ignore("BrowserStack Tests Enabled, Don't Run Normal Automation Tests"); + } + new StartupContext(); LogManager.Configuration = new LoggingConfiguration(); @@ -36,14 +45,6 @@ namespace NzbDrone.Automation.Test [OneTimeSetUp] public virtual void SmokeTestSetup() { - string username = Environment.GetEnvironmentVariable("BROWSERSTACK_USERNAME"); - string accessKey = Environment.GetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY"); - - if (username.IsNotNullOrWhiteSpace() && accessKey.IsNotNullOrWhiteSpace()) - { - Assert.Ignore("BrowserStack Tests Enabled, Don't Run Normal Automation Tests"); - } - var options = new FirefoxOptions(); options.AddArguments("--headless"); driver = new FirefoxDriver(options); diff --git a/src/NzbDrone.Automation.Test/BrowserStackAutomationTest.cs b/src/NzbDrone.Automation.Test/BrowserStackAutomationTest.cs index 1771b3efb..ff2ca707c 100644 --- a/src/NzbDrone.Automation.Test/BrowserStackAutomationTest.cs +++ b/src/NzbDrone.Automation.Test/BrowserStackAutomationTest.cs @@ -19,10 +19,14 @@ using OpenQA.Selenium.Remote; namespace NzbDrone.Automation.Test { - [TestFixture] - [AutomationTest] + [TestFixture("", "Windows", "10", "Chrome", "63", 9901)] + [TestFixture("", "Windows", "10", "Firefox", "67", 9902)] + [TestFixture("", "Windows", "10", "Edge", "18", 9903)] + [TestFixture("", "OS X", "Mojave", "Safari", "12.1", 9904)] + // [TestFixture("iPhone X", "", "11", "iPhone", "", 9905)] + // [TestFixture("Samsung Galaxy S9 Plus", "", "9.0", "android", "", 9906)] [Parallelizable(ParallelScope.Fixtures)] - public abstract class BrowserStackAutomationTest : MainPagesTest + public class BrowserStackAutomationTest : MainPagesTest { protected string browser; protected string browserVersion; @@ -77,7 +81,7 @@ namespace NzbDrone.Automation.Test capabilities.SetCapability("browserstack.localIdentifier", browserstackLocalIdentifier); capabilities.SetCapability("browserstack.debug", "true"); capabilities.SetCapability("browserstack.console", "verbose"); - capabilities.SetCapability("name", "Functional Tests: " + serverOs + " - " + browser); + capabilities.SetCapability("name", string.Format("Functional Tests: {0} - {1}", serverOs, browser)); capabilities.SetCapability("project", "Lidarr"); capabilities.SetCapability("build", buildName); @@ -125,7 +129,12 @@ namespace NzbDrone.Automation.Test public override void SmokeTestTearDown() { driver?.Quit(); - _browserStackLocalProcess?.Kill(); + + if (_browserStackLocalProcess != null && !_browserStackLocalProcess.HasExited) + { + _browserStackLocalProcess.Kill(); + } + _runner?.Kill(); } @@ -178,9 +187,9 @@ namespace NzbDrone.Automation.Test } }); - if (!processStarted.Wait(5000)) + if (!processStarted.Wait(10000)) { - Assert.Fail("Failed to start browserstack within 5 sec"); + Assert.Fail("Failed to start browserstack within 10 sec"); } TestContext.Progress.WriteLine($"Successfully started browserstacklocal pid {process.Id}"); diff --git a/src/NzbDrone.Automation.Test/BrowserStackFixture.cs b/src/NzbDrone.Automation.Test/BrowserStackFixture.cs deleted file mode 100644 index 9df904127..000000000 --- a/src/NzbDrone.Automation.Test/BrowserStackFixture.cs +++ /dev/null @@ -1,18 +0,0 @@ -using NUnit.Framework; - -namespace NzbDrone.Automation.Test -{ - [TestFixture("", "Windows", "10", "Chrome", "63", 9901)] - [TestFixture("", "Windows", "10", "Firefox", "67", 9902)] - [TestFixture("", "Windows", "10", "Edge", "18", 9903)] - [TestFixture("", "OS X", "Mojave", "Safari", "12.1", 9904)] - // [TestFixture("iPhone X", "", "11", "iPhone", "", 9905)] - // [TestFixture("Samsung Galaxy S9 Plus", "", "9.0", "android", "", 9906)] - public class BrowserStackFixture : BrowserStackAutomationTest - { - public BrowserStackFixture(string device, string os, string osVersion, string browser, string browserVersion, int port) : - base(device, os, osVersion, browser, browserVersion, port) - { - } - } -} diff --git a/src/NzbDrone.Automation.Test/PageModel/PageBase.cs b/src/NzbDrone.Automation.Test/PageModel/PageBase.cs index 36e56a00c..3e78dcb53 100644 --- a/src/NzbDrone.Automation.Test/PageModel/PageBase.cs +++ b/src/NzbDrone.Automation.Test/PageModel/PageBase.cs @@ -50,7 +50,7 @@ namespace NzbDrone.Automation.Test.PageModel { try { - IWebElement element = d.FindElement(By.Id("followingBalls")); + IWebElement element = d.FindElement(By.CssSelector("div[class*='LoadingIndicator']")); return !element.Displayed; } catch (NoSuchElementException)