From d49ec43236bc6f43eaacb430119c8e4564f6b090 Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Wed, 23 Nov 2022 22:59:43 +0100 Subject: [PATCH] Add massive session e2e test --- .../server/kurento/kms/KmsManager.java | 10 ++++--- .../test/e2e/OpenViduTestAppE2eTest.java | 30 +++++++++++++++++++ openvidu-testapp/package-lock.json | 20 ++++++------- openvidu-testapp/package.json | 10 +++---- openvidu-testapp/src/app/app.component.html | 6 ++-- .../test-scenarios.component.ts | 21 +++++++++++-- 6 files changed, 73 insertions(+), 24 deletions(-) diff --git a/openvidu-server/src/main/java/io/openvidu/server/kurento/kms/KmsManager.java b/openvidu-server/src/main/java/io/openvidu/server/kurento/kms/KmsManager.java index f74e833e..c519a3b0 100644 --- a/openvidu-server/src/main/java/io/openvidu/server/kurento/kms/KmsManager.java +++ b/openvidu-server/src/main/java/io/openvidu/server/kurento/kms/KmsManager.java @@ -393,14 +393,16 @@ public abstract class KmsManager { } public void nodeRecoveredHandler(Kms kms) { - log.info("According to Timer KMS with uri {} and KurentoClient [{}] is now reconnected", kms.getUri(), - kms.getKurentoClient().toString()); - - kms.getKurentoClientReconnectTimer().cancelTimer(); final boolean mustTriggerNodeRecoveredEvent = kms.hasTriggeredNodeCrashedEvent(); final long timeOfKurentoDisconnection = kms.getTimeOfKurentoClientDisconnection(); + log.info("According to Timer KMS with uri {} and KurentoClient [{}] is now reconnected after {} ms", + kms.getUri(), kms.getKurentoClient().toString(), + (System.currentTimeMillis() - timeOfKurentoDisconnection)); + + kms.getKurentoClientReconnectTimer().cancelTimer(); + kms.setKurentoClientConnected(true, true); if (kms.getKurentoSessions().isEmpty()) { diff --git a/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduTestAppE2eTest.java b/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduTestAppE2eTest.java index 6f373da5..7a7b505a 100644 --- a/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduTestAppE2eTest.java +++ b/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduTestAppE2eTest.java @@ -402,6 +402,36 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestappE2eTest { gracefullyLeaveParticipants(user, 4); } + @Test + @DisplayName("Massive session") + void massiveSessionTest() throws Exception { + isKurentoRestartTest = true; + + OpenViduTestappUser user = setupBrowserAndConnectToOpenViduTestapp("chrome"); + + log.info("Massive session"); + + final Integer NUMBER_OF_USERS = 7; + + user.getDriver().findElement(By.id("toolbar-scenarios")).sendKeys(Keys.ENTER); + + WebElement one2ManyInput = user.getDriver().findElement(By.id("one2many-input")); + one2ManyInput.clear(); + one2ManyInput.sendKeys(NUMBER_OF_USERS.toString()); + + user.getDriver().findElement(By.id("one2many-btn")).click(); + + user.getWaiter() + .until(ExpectedConditions.numberOfElementsToBe(By.tagName("video"), NUMBER_OF_USERS * NUMBER_OF_USERS)); + + user.getEventManager().waitUntilEventReaches("streamCreated", NUMBER_OF_USERS * NUMBER_OF_USERS); + user.getEventManager().waitUntilEventReaches("streamPlaying", NUMBER_OF_USERS * NUMBER_OF_USERS); + + this.stopMediaServer(false); + + user.getEventManager().waitUntilEventReaches("sessionDisconnected", NUMBER_OF_USERS); + } + @Test @DisplayName("Cross-Browser test") void crossBrowserTest() throws Exception { diff --git a/openvidu-testapp/package-lock.json b/openvidu-testapp/package-lock.json index 125c18cc..11ee6431 100644 --- a/openvidu-testapp/package-lock.json +++ b/openvidu-testapp/package-lock.json @@ -22,11 +22,11 @@ "@angular/router": "14.2.12", "colormap": "2.3.2", "core-js": "3.26.1", - "json-stringify-safe": "^5.0.1", + "json-stringify-safe": "5.0.1", "openvidu-browser": "2.24.0", "openvidu-node-client": "2.24.0", "rxjs": "7.5.7", - "tslib": "^2.4.1", + "tslib": "2.4.1", "zone.js": "0.12.0" }, "devDependencies": { @@ -40,8 +40,8 @@ "@types/node": "12.12.14", "codelyzer": "6.0.2", "ts-node": "8.5.4", - "tslint": "~6.1.3", - "typescript": "4.6.4" + "tslint": "6.1.3", + "typescript": "4.8.4" } }, "node_modules/@adobe/css-tools": { @@ -10987,9 +10987,9 @@ "dev": true }, "node_modules/typescript": { - "version": "4.6.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", - "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", + "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -19557,9 +19557,9 @@ "dev": true }, "typescript": { - "version": "4.6.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.4.tgz", - "integrity": "sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg==", + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", + "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", "dev": true }, "unicode-canonical-property-names-ecmascript": { diff --git a/openvidu-testapp/package.json b/openvidu-testapp/package.json index 3b4b697d..b65db1b3 100644 --- a/openvidu-testapp/package.json +++ b/openvidu-testapp/package.json @@ -13,11 +13,11 @@ "@angular/router": "14.2.12", "colormap": "2.3.2", "core-js": "3.26.1", - "json-stringify-safe": "^5.0.1", + "json-stringify-safe": "5.0.1", "openvidu-browser": "2.24.0", "openvidu-node-client": "2.24.0", "rxjs": "7.5.7", - "tslib": "^2.4.1", + "tslib": "2.4.1", "zone.js": "0.12.0" }, "devDependencies": { @@ -27,12 +27,12 @@ "@angular/language-service": "14.2.12", "@types/jasmine": "4.3.0", "@types/jasminewd2": "2.0.10", - "@types/json-stringify-safe": "^5.0.0", + "@types/json-stringify-safe": "5.0.0", "@types/node": "12.12.14", "codelyzer": "6.0.2", "ts-node": "8.5.4", - "tslint": "~6.1.3", - "typescript": "4.6.4" + "tslint": "6.1.3", + "typescript": "4.8.4" }, "license": "Apache-2.0", "name": "openvidu-testapp", diff --git a/openvidu-testapp/src/app/app.component.html b/openvidu-testapp/src/app/app.component.html index a0633a48..1bdab1a7 100644 --- a/openvidu-testapp/src/app/app.component.html +++ b/openvidu-testapp/src/app/app.component.html @@ -2,9 +2,9 @@
- SESSIONS - SCENARIOS - API REST + SESSIONS + SCENARIOS + API REST
diff --git a/openvidu-testapp/src/app/components/test-scenarios/test-scenarios.component.ts b/openvidu-testapp/src/app/components/test-scenarios/test-scenarios.component.ts index 713b2ae2..87a9f5dc 100644 --- a/openvidu-testapp/src/app/components/test-scenarios/test-scenarios.component.ts +++ b/openvidu-testapp/src/app/components/test-scenarios/test-scenarios.component.ts @@ -11,6 +11,7 @@ import { StreamManagerWrapper } from '../users-table/table-video.component'; import { MatDialog } from '@angular/material/dialog'; import { ConnectionEvent, OpenVidu, PublisherProperties, Session, + SessionDisconnectedEvent, StreamEvent, StreamManagerEvent } from 'openvidu-browser'; @@ -183,6 +184,10 @@ export class TestScenariosComponent implements OnInit, OnDestroy { const OV = new OpenVidu(); + OV.setAdvancedConfiguration({ + noStreamPlayingEventExceptionTimeout: 50000 + }); + if (this.turnConf === 'freeice') { OV.setAdvancedConfiguration({ iceServers: 'freeice' }); } else if (this.turnConf === 'manual') { @@ -199,8 +204,15 @@ export class TestScenariosComponent implements OnInit, OnDestroy { } }); + session.on('sessionDisconnected', (event: SessionDisconnectedEvent) => { + this.testFeedService.pushNewEvent({ user: 0, event }); + }); + if (user.subscribeTo) { session.on('streamCreated', (event: StreamEvent) => { + + this.testFeedService.pushNewEvent({ user: 0, event }); + const subscriber = session.subscribe(event.stream, undefined, (error) => { const subAux = this.subscribers .find(s => s.connectionId === session.connection.connectionId).subs @@ -233,6 +245,9 @@ export class TestScenariosComponent implements OnInit, OnDestroy { } subscriber.on('streamPlaying', (e: StreamManagerEvent) => { + + this.testFeedService.pushNewEvent({ user: 0, event: e }); + this.subscribers .find(s => s.connectionId === session.connection.connectionId).subs .find(s => s.streamManager.stream.connection.connectionId === subscriber.stream.connection.connectionId) @@ -253,10 +268,12 @@ export class TestScenariosComponent implements OnInit, OnDestroy { state: { 'connecting': (Date.now() - startTimeForUser) } }; - publisher.on('streamCreated', () => { + publisher.on('streamCreated', event => { + this.testFeedService.pushNewEvent({ user: 0, event }); publisherWrapper.state['connected'] = (Date.now() - startTimeForUser); }); - publisher.on('streamPlaying', () => { + publisher.on('streamPlaying', event => { + this.testFeedService.pushNewEvent({ user: 0, event }); publisherWrapper.state['playing'] = (Date.now() - startTimeForUser); }); session.publish(publisher).catch(() => {