From 8f8678d253a66a73b0e081b6e28d401f56360742 Mon Sep 17 00:00:00 2001 From: Vaadin Bot Date: Fri, 20 Dec 2024 09:03:19 +0100 Subject: [PATCH] test: disable shm usage for reload time test (#20761) (#20764) Prevents remote Chrome ERR_INSUFFICIENT_RESOURCES failures for tests loading hundreds of resources concurrently (CSS or JS). Co-authored-by: Marco Collovati --- .../example/SpringDevToolsReloadViewIT.java | 28 +++++++++++++++ .../example/SpringDevToolsReloadViewIT.java | 34 +++++++++++++++++-- .../example/SpringDevToolsReloadViewIT.java | 30 ++++++++++++++++ 3 files changed, 89 insertions(+), 3 deletions(-) diff --git a/flow-tests/vaadin-spring-tests/test-plain-spring-boot-reload-time/src/test/java/org/vaadin/example/SpringDevToolsReloadViewIT.java b/flow-tests/vaadin-spring-tests/test-plain-spring-boot-reload-time/src/test/java/org/vaadin/example/SpringDevToolsReloadViewIT.java index d529e01037f..da7e0a0460c 100644 --- a/flow-tests/vaadin-spring-tests/test-plain-spring-boot-reload-time/src/test/java/org/vaadin/example/SpringDevToolsReloadViewIT.java +++ b/flow-tests/vaadin-spring-tests/test-plain-spring-boot-reload-time/src/test/java/org/vaadin/example/SpringDevToolsReloadViewIT.java @@ -15,13 +15,22 @@ */ package org.vaadin.example; +import java.util.ArrayList; +import java.util.List; + import com.vaadin.flow.server.Version; import com.vaadin.flow.spring.test.SpringDevToolsReloadUtils; import com.vaadin.flow.testutil.ChromeBrowserTest; +import com.vaadin.testbench.annotations.BrowserConfiguration; +import com.vaadin.testbench.parallel.Browser; +import org.junit.After; import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; +import org.openqa.selenium.chrome.ChromeOptions; +import org.openqa.selenium.logging.Logs; +import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.support.ui.ExpectedConditions; /** @@ -50,6 +59,25 @@ public void testPlainSpringBootReloadTime_withHelloWorld() { getVaadinMajorMinorVersion(), result); } + @BrowserConfiguration + public List tuneChromeSettings() { + List list = new ArrayList<>(); + DesiredCapabilities desiredCapabilities = Browser.CHROME + .getDesiredCapabilities(); + ChromeOptions options = new ChromeOptions(); + options.addArguments("--disable-dev-shm-usage"); + list.add(desiredCapabilities.merge(options)); + return list; + } + + @After + public void dumpLogs() { + Logs logs = driver.manage().logs(); + logs.getAvailableLogTypes().stream() + .flatMap(level -> logs.get(level).getAll().stream()) + .forEach(System.out::println); + } + private void triggerReload() { findElement(By.id("start-button")).click(); // trigger for reload } diff --git a/flow-tests/vaadin-spring-tests/test-spring-boot-multimodule-reload-time/ui/src/test/java/org/vaadin/example/SpringDevToolsReloadViewIT.java b/flow-tests/vaadin-spring-tests/test-spring-boot-multimodule-reload-time/ui/src/test/java/org/vaadin/example/SpringDevToolsReloadViewIT.java index 490a1d1e972..730262e47df 100644 --- a/flow-tests/vaadin-spring-tests/test-spring-boot-multimodule-reload-time/ui/src/test/java/org/vaadin/example/SpringDevToolsReloadViewIT.java +++ b/flow-tests/vaadin-spring-tests/test-spring-boot-multimodule-reload-time/ui/src/test/java/org/vaadin/example/SpringDevToolsReloadViewIT.java @@ -15,15 +15,24 @@ */ package org.vaadin.example; -import com.vaadin.flow.server.Version; -import com.vaadin.flow.spring.test.SpringDevToolsReloadUtils; -import com.vaadin.flow.testutil.ChromeBrowserTest; +import java.util.ArrayList; +import java.util.List; +import org.junit.After; import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; +import org.openqa.selenium.chrome.ChromeOptions; +import org.openqa.selenium.logging.Logs; +import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.support.ui.ExpectedConditions; +import com.vaadin.flow.server.Version; +import com.vaadin.flow.spring.test.SpringDevToolsReloadUtils; +import com.vaadin.flow.testutil.ChromeBrowserTest; +import com.vaadin.testbench.annotations.BrowserConfiguration; +import com.vaadin.testbench.parallel.Browser; + /** * Class for testing reload time of "larger" (size is configurable and test is * meant for large apps) Vaadin app triggered by spring-boot Dev Tool. @@ -37,6 +46,25 @@ public void testSpringBootReloadTime_withLargerApp() { this::runTestReturnResult))); } + @BrowserConfiguration + public List tuneChromeSettings() { + List list = new ArrayList<>(); + DesiredCapabilities desiredCapabilities = Browser.CHROME + .getDesiredCapabilities(); + ChromeOptions options = new ChromeOptions(); + options.addArguments("--disable-dev-shm-usage"); + list.add(desiredCapabilities.merge(options)); + return list; + } + + @After + public void dumpLogs() { + Logs logs = driver.manage().logs(); + logs.getAvailableLogTypes().stream() + .flatMap(level -> logs.get(level).getAll().stream()) + .forEach(System.out::println); + } + private String runTestReturnResult() { if (hasRouteHierarchy()) { open("/catalog/prod/0"); diff --git a/flow-tests/vaadin-spring-tests/test-spring-boot-reload-time/src/test/java/org/vaadin/example/SpringDevToolsReloadViewIT.java b/flow-tests/vaadin-spring-tests/test-spring-boot-reload-time/src/test/java/org/vaadin/example/SpringDevToolsReloadViewIT.java index 42bae139bbf..81ce0f4f4a5 100644 --- a/flow-tests/vaadin-spring-tests/test-spring-boot-reload-time/src/test/java/org/vaadin/example/SpringDevToolsReloadViewIT.java +++ b/flow-tests/vaadin-spring-tests/test-spring-boot-reload-time/src/test/java/org/vaadin/example/SpringDevToolsReloadViewIT.java @@ -15,18 +15,29 @@ */ package org.vaadin.example; +import java.util.ArrayList; +import java.util.List; + import com.vaadin.flow.server.Version; import com.vaadin.flow.spring.test.SpringDevToolsReloadUtils; import com.vaadin.flow.testutil.ChromeBrowserTest; +import com.vaadin.testbench.annotations.BrowserConfiguration; +import com.vaadin.testbench.parallel.Browser; +import net.jcip.annotations.NotThreadSafe; +import org.junit.After; import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; +import org.openqa.selenium.chrome.ChromeOptions; +import org.openqa.selenium.logging.Logs; +import org.openqa.selenium.remote.DesiredCapabilities; /** * Class for testing reload time of tiny Vaadin app triggered by spring-boot Dev * Tool. */ +@NotThreadSafe public class SpringDevToolsReloadViewIT extends ChromeBrowserTest { @Test @@ -69,6 +80,25 @@ public void testSpringBootReloadTime_withHorizontalLayout() { optionalAssertByReloadThreshold(result); } + @BrowserConfiguration + public List tuneChromeSettings() { + List list = new ArrayList<>(); + DesiredCapabilities desiredCapabilities = Browser.CHROME + .getDesiredCapabilities(); + ChromeOptions options = new ChromeOptions(); + options.addArguments("--disable-dev-shm-usage"); + list.add(desiredCapabilities.merge(options)); + return list; + } + + @After + public void dumpLogs() { + Logs logs = driver.manage().logs(); + logs.getAvailableLogTypes().stream() + .flatMap(level -> logs.get(level).getAll().stream()) + .forEach(System.out::println); + } + private void triggerReload() { findElement(By.id("start-button")).click(); // trigger for reload }