Skip to content

Commit

Permalink
openvidu-test-e2e: Crash STT service test
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloFuente committed Nov 15, 2022
1 parent 75eeda4 commit 14debd5
Showing 1 changed file with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1570,6 +1570,51 @@ void memoryLeakSttTest() throws Exception {
}
}

@Test
@DisplayName("Crash STT service test")
void crashSttServiceTest() throws Exception {

log.info("Crash STT service test");

restartOpenViduServerIfNecessary(false, null, OPENVIDU_PRO_SPEECH_TO_TEXT);

OpenViduTestappUser user = setupBrowserAndConnectToOpenViduTestapp("chromeFakeAudio");

user.getDriver().get(APP_URL);
user.getDriver().findElement(By.id("add-user-btn")).click();
user.getDriver().findElement(By.className("join-btn")).sendKeys(Keys.ENTER);

user.getEventManager().waitUntilEventReaches("connectionCreated", 1);
user.getEventManager().waitUntilEventReaches("accessAllowed", 1);
user.getEventManager().waitUntilEventReaches("streamCreated", 1);
user.getEventManager().waitUntilEventReaches("streamPlaying", 1);

this.sttSubUser(user, 0, 0, "en-US", true, false);

user.getEventManager().waitUntilEventReaches("speechToTextMessage", 4);

CountDownLatch latch = new CountDownLatch(1);
JsonObject[] exceptionEvent = new JsonObject[1];

user.getEventManager().on("exception", e -> {
exceptionEvent[0] = e;
latch.countDown();
});

this.killSttService();

latch.await();

user.getEventManager().waitUntilEventReaches("exception", 1);

Assert.assertEquals("Wrong exception event name", "SPEECH_TO_TEXT_DISCONNECTED",
exceptionEvent[0].get("name").getAsString());
Assert.assertEquals("Wrong exception event message", "Network closed for unknown reason",
exceptionEvent[0].get("message").getAsString());

// TODO: test that after STT container restarts, STT is possible again
}

// @Test
// @DisplayName("Mix STT test")
// void mixSttTest() throws Exception {
Expand Down Expand Up @@ -1710,4 +1755,13 @@ private void sttUnsubUser(OpenViduTestappUser user, int numberOfUser, int number
}
}

private void killSttService() {
// For local run
// String killCommand = "ps axf | grep \"speech-to-text-service\" | grep -v grep
// | awk '{print $1}' | xargs -I {} kill -9 {}";
// For DIND run
String killCommand = "ps axf | grep \"dist/bin/speech-to-text-service\" | grep -v grep | awk '{print $1}' | xargs -I {} kill -9 {}";
commandLine.executeCommand(killCommand, 10);
}

}

0 comments on commit 14debd5

Please sign in to comment.