From 58d37ea241dd0e8110bc29d3e5e87a3dfae1ddbf Mon Sep 17 00:00:00 2001 From: mekya Date: Sat, 18 Jan 2025 17:41:39 +0300 Subject: [PATCH] Add test code that server is not get started until high http load --- .../ConsoleAppRestServiceTest.java | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/src/test/java/io/antmedia/integration/ConsoleAppRestServiceTest.java b/src/test/java/io/antmedia/integration/ConsoleAppRestServiceTest.java index 21bd7d3ce..9a1636478 100644 --- a/src/test/java/io/antmedia/integration/ConsoleAppRestServiceTest.java +++ b/src/test/java/io/antmedia/integration/ConsoleAppRestServiceTest.java @@ -395,6 +395,92 @@ public String getStreamAppWar(String installLocation) return null; } + + boolean threadStarted = false; + boolean breakThread = false; + + @Test + public void testStartUnderHttpLoad() { + + + //give load to the server by sending http requests to m3u8 + + threadStarted = false; + Thread thread = new Thread() { + @Override + public void run() { + + threadStarted = true; + + log.info("Thread is started"); + + while (!breakThread) { + + try { + //send http request to m3u8 + String url = "http://127.0.0.1:5080/live/streams/stream.m3u8"; + + CloseableHttpClient client = HttpClients.custom().setRedirectStrategy(new LaxRedirectStrategy()).build(); + + + HttpUriRequest get = RequestBuilder.get().setUri(url) + .build(); + + client.execute(get); + + } catch (Exception e) { + e.printStackTrace(); + } + + + } + + log.info("Thread is finished"); + + } + }; + + thread.start(); + + Awaitility.await().atMost(10, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS).until(() -> { + return threadStarted; + }); + //restart the server + + Process process = AppFunctionalV2Test.execute("sudo service antmedia restart"); + assertEquals(0, process.exitValue()); + + //check that live is started + Awaitility.await().atMost(30, TimeUnit.SECONDS).pollInterval(3, TimeUnit.SECONDS) + .until(() -> + { + User user = new User(); + user.setEmail(TEST_USER_EMAIL); + user.setPassword(TEST_USER_PASS); + return callAuthenticateUser(user).isSuccess(); + }); + + Awaitility.await().atMost(30, TimeUnit.SECONDS).pollInterval(3, TimeUnit.SECONDS) + .until(() -> { + Applications applications = getApplications(); + if (applications.applications.length == 3) { + for (String app : applications.applications) { + if (app.equals("live")) { + return true; + } + } + } + else { + log.info("applications length is not 3: {}", applications.applications); + } + + return false; + }); + + //finish thread + this.breakThread = true; + + } @Test public void testCreateCustomApp()