public void TestParallelStepsLimitOfTest() { bool isOnlyOneRender = true; int runningRendersCount = 0; VisualGridRunner runner = new VisualGridRunner(); Configuration config = new Configuration(); config.AddBrowser(new IosDeviceInfo(IosDeviceName.iPhone_7)); ConfigurationProvider configurationProvider = new ConfigurationProvider(config); VisualGridEyes eyes = new VisualGridEyes(configurationProvider, runner); eyes.SetLogHandler(TestUtils.InitLogHandler()); eyes.EyesConnectorFactory = new MockEyesConnectorFactory(); IWebDriver driver = SeleniumUtils.CreateChromeDriver(); try { driver.Url = "http://applitools.github.io/demo"; eyes.Open(driver, "Eyes SDK", "UFG Server Concurrency", new RectangleSize(800, 800)); MockEyesConnector mockEyesConnector = (MockEyesConnector)eyes.eyesConnector_; mockEyesConnector.BeforeRender += (renderRequests) => { int runningRendersCountBeforeInc = runningRendersCount; Interlocked.Increment(ref runningRendersCount); if (runningRendersCountBeforeInc >= RunningTest.PARALLEL_STEPS_LIMIT) { isOnlyOneRender = false; } Thread.Sleep(1000); if (renderRequests.Length != 1) { isOnlyOneRender = false; } }; mockEyesConnector.AfterRender += (results, renderRequests) => { Interlocked.Decrement(ref runningRendersCount); }; for (int i = 0; i < 10; i++) { eyes.Check(Target.Window().Fully()); } eyes.CloseAsync(false); } finally { eyes.AbortAsync(); driver.Quit(); runner.GetAllTestResults(false); } Assert.IsTrue(isOnlyOneRender); }
public void TestRetryWhenServerConcurrencyLimitReached() { Configuration config = new Configuration(); config.AddBrowser(new IosDeviceInfo(IosDeviceName.iPhone_7)); ConfigurationProvider configurationProvider = new ConfigurationProvider(config); VisualGridRunner runner = new VisualGridRunner(new RunnerOptions().TestConcurrency(3)); VisualGridEyes eyes = new VisualGridEyes(configurationProvider, runner); eyes.SetLogHandler(TestUtils.InitLogHandler()); int counter = 0; bool wasConcurrencyFull = false; eyes.EyesConnectorFactory = new MockEyesConnectorFactory() { Events = new Events() { BeforeStartSession = () => { if (Interlocked.Increment(ref counter) < 4) { RunningSession newSession = new RunningSession(); newSession.ConcurrencyFull = true; return(newSession); } return(null); } } }; eyes.AfterServerConcurrencyLimitReachedQueried += (concurrecnyReached) => { if (concurrecnyReached) { wasConcurrencyFull = true; } }; IWebDriver driver = SeleniumUtils.CreateChromeDriver(); driver.Url = "http://applitools.github.io/demo"; try { eyes.Open(driver, "Eyes SDK", "UFG Runner Concurrency", new Size(800, 800)); eyes.Check(Target.Window().Fully()); eyes.CloseAsync(true); } finally { eyes.AbortAsync(); driver.Quit(); runner.GetAllTestResults(false); } Assert.IsTrue(wasConcurrencyFull); Assert.IsFalse(((IVisualGridEyes)eyes).IsServerConcurrencyLimitReached()); Assert.AreEqual(4, counter); }
public void TestResetContent() { Configuration config = new Configuration(); config.AddBrowser(new IosDeviceInfo(IosDeviceName.iPhone_7)); ConfigurationProvider configurationProvider = new ConfigurationProvider(config); VisualGridRunner runner = new VisualGridRunner(new RunnerOptions().TestConcurrency(3)); VisualGridEyes eyes = new VisualGridEyes(configurationProvider, runner); eyes.SetLogHandler(TestUtils.InitLogHandler()); IWebDriver driver = SeleniumUtils.CreateChromeDriver(); driver.Url = "http://applitools.github.io/demo"; try { eyes.Open(driver, "Eyes SDK", "UFG Runner Concurrency", new Size(800, 800)); eyes.Check(Target.Window().Fully()); eyes.CloseAsync(true); } finally { eyes.AbortAsync(); driver.Quit(); runner.GetAllTestResults(false); } foreach (ResourceFuture resourceFuture in ((IVisualGridRunner)runner).CachedResources.Values) { RGridResource resource = resourceFuture.GetResource(); Assert.IsNotNull(resource); Assert.IsNull(resource.Content); } }
public void TestRunnerConcurrency() { Configuration config = new Configuration(); config.AddBrowser(new IosDeviceInfo(IosDeviceName.iPhone_7)); config.AddDeviceEmulation(DeviceName.Galaxy_S5, ScreenOrientation.Landscape); config.AddBrowser(new DesktopBrowserInfo(800, 800, BrowserType.CHROME)); config.AddBrowser(new DesktopBrowserInfo(800, 800, BrowserType.FIREFOX)); config.AddBrowser(new DesktopBrowserInfo(800, 800, BrowserType.SAFARI)); ConfigurationProvider configurationProvider = new ConfigurationProvider(config); VisualGridRunner runner = new VisualGridRunner(new RunnerOptions().TestConcurrency(3)); VisualGridEyes eyes = new VisualGridEyes(configurationProvider, runner); eyes.SetLogHandler(TestUtils.InitLogHandler()); int currentlyOpenTests = 0; bool isFail = false; eyes.EyesConnectorFactory = new MockEyesConnectorFactory() { Events = new Events() { BeforeStartSession = () => { if (Interlocked.Increment(ref currentlyOpenTests) > 3) { isFail = true; } Thread.Sleep(3000); if (currentlyOpenTests > 3) { isFail = true; } return(null); }, AfterEndSession = () => { Interlocked.Decrement(ref currentlyOpenTests); } } }; IWebDriver driver = SeleniumUtils.CreateChromeDriver(); driver.Url = "http://applitools.github.io/demo"; try { eyes.Open(driver, "Eyes SDK", "UFG Runner Concurrency", new Size(800, 800)); eyes.Check(Target.Window().Fully()); eyes.CloseAsync(true); } finally { eyes.AbortAsync(); driver.Quit(); runner.GetAllTestResults(false); } Assert.IsFalse(isFail, "Number of open tests was higher than the concurrency limit"); }