Skip to content

Commit

Permalink
test: disable shm usage for reload time test (#20761) (#20764)
Browse files Browse the repository at this point in the history
Prevents remote Chrome ERR_INSUFFICIENT_RESOURCES failures for tests
loading hundreds of resources concurrently (CSS or JS).

Co-authored-by: Marco Collovati <[email protected]>
  • Loading branch information
vaadin-bot and mcollovati authored Dec 20, 2024
1 parent 1e0ab0b commit 8f8678d
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -50,6 +59,25 @@ public void testPlainSpringBootReloadTime_withHelloWorld() {
getVaadinMajorMinorVersion(), result);
}

@BrowserConfiguration
public List<DesiredCapabilities> tuneChromeSettings() {
List<DesiredCapabilities> 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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -37,6 +46,25 @@ public void testSpringBootReloadTime_withLargerApp() {
this::runTestReturnResult)));
}

@BrowserConfiguration
public List<DesiredCapabilities> tuneChromeSettings() {
List<DesiredCapabilities> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -69,6 +80,25 @@ public void testSpringBootReloadTime_withHorizontalLayout() {
optionalAssertByReloadThreshold(result);
}

@BrowserConfiguration
public List<DesiredCapabilities> tuneChromeSettings() {
List<DesiredCapabilities> 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
}
Expand Down

0 comments on commit 8f8678d

Please sign in to comment.