Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2020-06-25 17:50:58 +0300
committerGitHub <noreply@github.com>2020-06-25 17:50:58 +0300
commit9d6886be12e476c9a888e128637bc005b72c33cf (patch)
treeb2a6b4565292cfb92f77dccc1d5db9511f819bb6
parente519331919ca71a6316296a9a9c259476f5f937b (diff)
parent9f5bcaba0ba6d7f8ebade7fd16869abd2bb0aa00 (diff)
Merge pull request #3852 from nextcloud/backport/3845/stable19
[stable19] Enable fixed postgres tests again
-rw-r--r--.drone.yml263
-rw-r--r--tests/php/Signaling/BackendNotifierTest.php166
2 files changed, 197 insertions, 232 deletions
diff --git a/.drone.yml b/.drone.yml
index 24eb01024..5a279ca6d 100644
--- a/.drone.yml
+++ b/.drone.yml
@@ -270,134 +270,137 @@ trigger:
- pull_request
- push
-#---
-#kind: pipeline
-#name: unit-pgsql-php7.2
-#
-#steps:
-# - name: pgsql-php7.2
-# image: nextcloudci/php7.2:php7.2-13
-# environment:
-# APP_NAME: spreed
-# CORE_BRANCH: stable19
-# DATABASEHOST: pgsql
-# commands:
-# - bash tests/drone-run-php-tests.sh || exit 0
-# - wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh
-# - bash ./before_install.sh $APP_NAME $CORE_BRANCH $DATABASEHOST
-# - cd ../server
-# - ./occ app:enable $APP_NAME
-# - cd apps/$APP_NAME
-#
-# # Run phpunit tests
-# - cd tests/php/
-# - phpunit --configuration phpunit.xml
-#
-#services:
-# - name: cache
-# image: redis
-# - name: pgsql
-# image: postgres:10
-# environment:
-# POSTGRES_USER: oc_autotest
-# POSTGRES_DB: oc_autotest_dummy
-# POSTGRES_PASSWORD:
-# tmpfs:
-# - /var/lib/postgresql/data
-#
-#trigger:
-# branch:
-# - master
-# - stable*
-# event:
-# - pull_request
-# - push
-#
-#---
-#kind: pipeline
-#name: unit-pgsql-php7.3
-#
-#steps:
-# - name: pgsql-php7.3
-# image: nextcloudci/php7.3:php7.3-5
-# environment:
-# APP_NAME: spreed
-# CORE_BRANCH: stable19
-# DATABASEHOST: pgsql
-# commands:
-# - bash tests/drone-run-php-tests.sh || exit 0
-# - wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh
-# - bash ./before_install.sh $APP_NAME $CORE_BRANCH $DATABASEHOST
-# - cd ../server
-# - ./occ app:enable $APP_NAME
-# - cd apps/$APP_NAME
-#
-# # Run phpunit tests
-# - cd tests/php/
-# - phpunit --configuration phpunit.xml
-#
-#services:
-# - name: cache
-# image: redis
-# - name: pgsql
-# image: postgres:10
-# environment:
-# POSTGRES_USER: oc_autotest
-# POSTGRES_DB: oc_autotest_dummy
-# POSTGRES_PASSWORD:
-# tmpfs:
-# - /var/lib/postgresql/data
-#
-#trigger:
-# branch:
-# - master
-# - stable*
-# event:
-# - pull_request
-# - push
-#
-#---
-#kind: pipeline
-#name: unit-pgsql-php7.4
-#
-#steps:
-# - name: pgsql-php7.4
-# image: nextcloudci/php7.4:2
-# environment:
-# APP_NAME: spreed
-# CORE_BRANCH: stable19
-# DATABASEHOST: pgsql
-# commands:
-# - bash tests/drone-run-php-tests.sh || exit 0
-# - wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh
-# - bash ./before_install.sh $APP_NAME $CORE_BRANCH $DATABASEHOST
-# - cd ../server
-# - ./occ app:enable $APP_NAME
-# - cd apps/$APP_NAME
-#
-# # Run phpunit tests
-# - cd tests/php/
-# - phpunit --configuration phpunit.xml
-#
-#services:
-# - name: cache
-# image: redis
-# - name: pgsql
-# image: postgres:10
-# environment:
-# POSTGRES_USER: oc_autotest
-# POSTGRES_DB: oc_autotest_dummy
-# POSTGRES_PASSWORD:
-# tmpfs:
-# - /var/lib/postgresql/data
-#
-#trigger:
-# branch:
-# - master
-# - stable*
-# event:
-# - pull_request
-# - push
+---
+kind: pipeline
+name: unit-pgsql-php7.2
+
+steps:
+ - name: pgsql-php7.2
+ image: nextcloudci/php7.2:php7.2-13
+ environment:
+ APP_NAME: spreed
+ CORE_BRANCH: stable19
+ DATABASEHOST: pgsql
+ commands:
+ - bash tests/drone-run-php-tests.sh || exit 0
+ - wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh
+ - bash ./before_install.sh $APP_NAME $CORE_BRANCH $DATABASEHOST
+ - cd ../server
+ - ./occ app:enable $APP_NAME
+ - cd apps/$APP_NAME
+
+ # Run phpunit tests
+ - cd tests/php/
+ - phpunit --configuration phpunit.xml
+
+services:
+ - name: cache
+ image: redis
+ - name: pgsql
+ image: postgres:10
+ environment:
+ POSTGRES_USER: oc_autotest
+ POSTGRES_DB: oc_autotest_dummy
+ POSTGRES_HOST_AUTH_METHOD: trust
+ POSTGRES_PASSWORD:
+ tmpfs:
+ - /var/lib/postgresql/data
+
+trigger:
+ branch:
+ - master
+ - stable*
+ event:
+ - pull_request
+ - push
+
+---
+kind: pipeline
+name: unit-pgsql-php7.3
+
+steps:
+ - name: pgsql-php7.3
+ image: nextcloudci/php7.3:php7.3-5
+ environment:
+ APP_NAME: spreed
+ CORE_BRANCH: stable19
+ DATABASEHOST: pgsql
+ commands:
+ - bash tests/drone-run-php-tests.sh || exit 0
+ - wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh
+ - bash ./before_install.sh $APP_NAME $CORE_BRANCH $DATABASEHOST
+ - cd ../server
+ - ./occ app:enable $APP_NAME
+ - cd apps/$APP_NAME
+
+ # Run phpunit tests
+ - cd tests/php/
+ - phpunit --configuration phpunit.xml
+
+services:
+ - name: cache
+ image: redis
+ - name: pgsql
+ image: postgres:10
+ environment:
+ POSTGRES_USER: oc_autotest
+ POSTGRES_DB: oc_autotest_dummy
+ POSTGRES_HOST_AUTH_METHOD: trust
+ POSTGRES_PASSWORD:
+ tmpfs:
+ - /var/lib/postgresql/data
+
+trigger:
+ branch:
+ - master
+ - stable*
+ event:
+ - pull_request
+ - push
+
+---
+kind: pipeline
+name: unit-pgsql-php7.4
+
+steps:
+ - name: pgsql-php7.4
+ image: nextcloudci/php7.4:2
+ environment:
+ APP_NAME: spreed
+ CORE_BRANCH: stable19
+ DATABASEHOST: pgsql
+ commands:
+ - bash tests/drone-run-php-tests.sh || exit 0
+ - wget https://raw.githubusercontent.com/nextcloud/travis_ci/master/before_install.sh
+ - bash ./before_install.sh $APP_NAME $CORE_BRANCH $DATABASEHOST
+ - cd ../server
+ - ./occ app:enable $APP_NAME
+ - cd apps/$APP_NAME
+
+ # Run phpunit tests
+ - cd tests/php/
+ - phpunit --configuration phpunit.xml
+
+services:
+ - name: cache
+ image: redis
+ - name: pgsql
+ image: postgres:10
+ environment:
+ POSTGRES_USER: oc_autotest
+ POSTGRES_DB: oc_autotest_dummy
+ POSTGRES_HOST_AUTH_METHOD: trust
+ POSTGRES_PASSWORD:
+ tmpfs:
+ - /var/lib/postgresql/data
+
+trigger:
+ branch:
+ - master
+ - stable*
+ event:
+ - pull_request
+ - push
---
kind: pipeline
@@ -750,6 +753,7 @@ services:
environment:
POSTGRES_USER: oc_autotest
POSTGRES_DB: oc_autotest_dummy
+ POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_PASSWORD:
tmpfs:
- /var/lib/postgresql/data
@@ -793,6 +797,7 @@ services:
environment:
POSTGRES_USER: oc_autotest
POSTGRES_DB: oc_autotest_dummy
+ POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_PASSWORD:
tmpfs:
- /var/lib/postgresql/data
@@ -836,6 +841,7 @@ services:
environment:
POSTGRES_USER: oc_autotest
POSTGRES_DB: oc_autotest_dummy
+ POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_PASSWORD:
tmpfs:
- /var/lib/postgresql/data
@@ -879,6 +885,7 @@ services:
environment:
POSTGRES_USER: oc_autotest
POSTGRES_DB: oc_autotest_dummy
+ POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_PASSWORD:
tmpfs:
- /var/lib/postgresql/data
diff --git a/tests/php/Signaling/BackendNotifierTest.php b/tests/php/Signaling/BackendNotifierTest.php
index fcd990292..e4dbe10b0 100644
--- a/tests/php/Signaling/BackendNotifierTest.php
+++ b/tests/php/Signaling/BackendNotifierTest.php
@@ -186,18 +186,41 @@ class BackendNotifierTest extends \Test\TestCase {
return $body;
}
+ private function assertMessageWasSent(Room $room, array $message): void {
+ $requests = $this->controller->getRequests();
+ $bodies = array_map(function ($request) use ($room) {
+ return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true);
+ }, $requests);
+
+ $bodies = array_filter($bodies, function (array $body) use ($message) {
+ return $body['type'] === $message['type'];
+ });
+
+ $bodies = array_map([$this, 'sortParticipantUsers'], $bodies);
+ $message = $this->sortParticipantUsers($message);
+ $this->assertContains($message, $bodies);
+ }
+
+ private function sortParticipantUsers(array $message): array {
+ if ($message['type'] === 'participants') {
+ usort($message['participants']['users'], static function ($a, $b) {
+ return
+ [$a['userId'] ?? '', $a['participantType'], $a['sessionId'], $a['lastPing']]
+ <=>
+ [$b['userId'] ?? '', $b['participantType'], $b['sessionId'], $b['lastPing']]
+ ;
+ });
+ }
+ return $message;
+ }
+
public function testRoomInvite() {
$room = $this->manager->createPublicRoom();
$room->addUsers([
'userId' => $this->userId,
]);
- $requests = $this->controller->getRequests();
- $bodies = array_map(function ($request) use ($room) {
- return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true);
- }, $requests);
-
- $this->assertContains([
+ $this->assertMessageWasSent($room, [
'type' => 'invite',
'invite' => [
'userids' => [
@@ -215,7 +238,7 @@ class BackendNotifierTest extends \Test\TestCase {
'active-since' => null,
],
],
- ], $bodies);
+ ]);
}
public function testRoomDisinvite() {
@@ -231,11 +254,7 @@ class BackendNotifierTest extends \Test\TestCase {
->willReturn($this->userId);
$room->removeUser($testUser, Room::PARTICIPANT_REMOVED);
- $requests = $this->controller->getRequests();
- $bodies = array_map(function ($request) use ($room) {
- return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true);
- }, $requests);
- $this->assertContains([
+ $this->assertMessageWasSent($room, [
'type' => 'disinvite',
'disinvite' => [
'userids' => [
@@ -252,18 +271,14 @@ class BackendNotifierTest extends \Test\TestCase {
'active-since' => null,
],
],
- ], $bodies);
+ ]);
}
public function testRoomNameChanged() {
$room = $this->manager->createPublicRoom();
$room->setName('Test room');
- $requests = $this->controller->getRequests();
- $bodies = array_map(function ($request) use ($room) {
- return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true);
- }, $requests);
- $this->assertContains([
+ $this->assertMessageWasSent($room, [
'type' => 'update',
'update' => [
'userids' => [
@@ -277,18 +292,14 @@ class BackendNotifierTest extends \Test\TestCase {
'active-since' => null,
],
],
- ], $bodies);
+ ]);
}
public function testRoomPasswordChanged() {
$room = $this->manager->createPublicRoom();
$room->setPassword('password');
- $requests = $this->controller->getRequests();
- $bodies = array_map(function ($request) use ($room) {
- return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true);
- }, $requests);
- $this->assertContains([
+ $this->assertMessageWasSent($room, [
'type' => 'update',
'update' => [
'userids' => [
@@ -302,18 +313,14 @@ class BackendNotifierTest extends \Test\TestCase {
'active-since' => null,
],
],
- ], $bodies);
+ ]);
}
public function testRoomTypeChanged() {
$room = $this->manager->createPublicRoom();
$room->setType(Room::GROUP_CALL);
- $requests = $this->controller->getRequests();
- $bodies = array_map(function ($request) use ($room) {
- return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true);
- }, $requests);
- $this->assertContains([
+ $this->assertMessageWasSent($room, [
'type' => 'update',
'update' => [
'userids' => [
@@ -327,18 +334,14 @@ class BackendNotifierTest extends \Test\TestCase {
'active-since' => null,
],
],
- ], $bodies);
+ ]);
}
public function testRoomReadOnlyChanged() {
$room = $this->manager->createPublicRoom();
$room->setReadOnly(Room::READ_ONLY);
- $requests = $this->controller->getRequests();
- $bodies = array_map(function ($request) use ($room) {
- return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true);
- }, $requests);
- $this->assertContains([
+ $this->assertMessageWasSent($room, [
'type' => 'update',
'update' => [
'userids' => [
@@ -352,18 +355,14 @@ class BackendNotifierTest extends \Test\TestCase {
'active-since' => null,
],
],
- ], $bodies);
+ ]);
}
public function testRoomLobbyStateChanged() {
$room = $this->manager->createPublicRoom();
$room->setLobby(Webinary::LOBBY_NON_MODERATORS, null);
- $requests = $this->controller->getRequests();
- $bodies = array_map(function ($request) use ($room) {
- return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true);
- }, $requests);
- $this->assertContains([
+ $this->assertMessageWasSent($room, [
'type' => 'update',
'update' => [
'userids' => [
@@ -377,7 +376,7 @@ class BackendNotifierTest extends \Test\TestCase {
'active-since' => null,
],
],
- ], $bodies);
+ ]);
}
public function testRoomDelete() {
@@ -387,18 +386,14 @@ class BackendNotifierTest extends \Test\TestCase {
]);
$room->deleteRoom();
- $requests = $this->controller->getRequests();
- $bodies = array_map(function ($request) use ($room) {
- return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true);
- }, $requests);
- $this->assertContains([
+ $this->assertMessageWasSent($room, [
'type' => 'delete',
'delete' => [
'userids' => [
$this->userId,
],
],
- ], $bodies);
+ ]);
}
public function testRoomInCallChanged() {
@@ -411,11 +406,7 @@ class BackendNotifierTest extends \Test\TestCase {
$participant = $room->getParticipantBySession($userSession);
$room->changeInCall($participant, Participant::FLAG_IN_CALL | Participant::FLAG_WITH_AUDIO | Participant::FLAG_WITH_VIDEO);
- $requests = $this->controller->getRequests();
- $bodies = array_map(function ($request) use ($room) {
- return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true);
- }, $requests);
- $this->assertContains([
+ $this->assertMessageWasSent($room, [
'type' => 'incall',
'incall' => [
'incall' => 7,
@@ -438,18 +429,14 @@ class BackendNotifierTest extends \Test\TestCase {
],
],
],
- ], $bodies);
+ ]);
$this->controller->clearRequests();
$guestSession = $room->joinRoomGuest('');
$guestParticipant = $room->getParticipantBySession($guestSession);
$room->changeInCall($guestParticipant, Participant::FLAG_IN_CALL);
- $requests = $this->controller->getRequests();
- $bodies = array_map(function ($request) use ($room) {
- return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true);
- }, $requests);
- $this->assertContains([
+ $this->assertMessageWasSent($room, [
'type' => 'incall',
'incall' => [
'incall' => 1,
@@ -477,16 +464,12 @@ class BackendNotifierTest extends \Test\TestCase {
],
],
],
- ], $bodies);
+ ]);
$this->controller->clearRequests();
$room->changeInCall($participant, Participant::FLAG_DISCONNECTED);
- $requests = $this->controller->getRequests();
- $bodies = array_map(function ($request) use ($room) {
- return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true);
- }, $requests);
- $this->assertContains([
+ $this->assertMessageWasSent($room, [
'type' => 'incall',
'incall' => [
'incall' => 0,
@@ -508,7 +491,7 @@ class BackendNotifierTest extends \Test\TestCase {
],
],
],
- ], $bodies);
+ ]);
}
public function testRoomPropertiesEvent(): void {
@@ -524,12 +507,7 @@ class BackendNotifierTest extends \Test\TestCase {
$this->controller->clearRequests();
$room->setName('Test room');
- $requests = $this->controller->getRequests();
- $bodies = array_map(function ($request) use ($room) {
- return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true);
- }, $requests);
-
- $this->assertContains([
+ $this->assertMessageWasSent($room, [
'type' => 'update',
'update' => [
'userids' => [
@@ -545,7 +523,7 @@ class BackendNotifierTest extends \Test\TestCase {
'room' => $room->getToken(),
],
],
- ], $bodies);
+ ]);
}
public function testParticipantsTypeChanged() {
@@ -558,11 +536,7 @@ class BackendNotifierTest extends \Test\TestCase {
$participant = $room->getParticipantBySession($userSession);
$room->setParticipantType($participant, Participant::MODERATOR);
- $requests = $this->controller->getRequests();
- $bodies = array_map(function ($request) use ($room) {
- return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true);
- }, $requests);
- $this->assertContains([
+ $this->assertMessageWasSent($room, [
'type' => 'participants',
'participants' => [
'changed' => [
@@ -585,18 +559,14 @@ class BackendNotifierTest extends \Test\TestCase {
],
],
],
- ], $bodies);
+ ]);
$this->controller->clearRequests();
$guestSession = $room->joinRoomGuest('');
$guestParticipant = $room->getParticipantBySession($guestSession);
$room->setParticipantType($guestParticipant, Participant::GUEST_MODERATOR);
- $requests = $this->controller->getRequests();
- $bodies = array_map(function ($request) use ($room) {
- return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true);
- }, $requests);
- $this->assertContains([
+ $this->assertMessageWasSent($room, [
'type' => 'participants',
'participants' => [
'changed' => [
@@ -624,7 +594,7 @@ class BackendNotifierTest extends \Test\TestCase {
],
],
],
- ], $bodies);
+ ]);
$this->controller->clearRequests();
$notJoinedUserId = 'not-joined-user-id';
@@ -634,11 +604,7 @@ class BackendNotifierTest extends \Test\TestCase {
$notJoinedParticipant = $room->getParticipant($notJoinedUserId);
$room->setParticipantType($notJoinedParticipant, Participant::MODERATOR);
- $requests = $this->controller->getRequests();
- $bodies = array_map(function ($request) use ($room) {
- return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true);
- }, $requests);
- $this->assertContains([
+ $this->assertMessageWasSent($room, [
'type' => 'participants',
'participants' => [
'changed' => [
@@ -666,16 +632,12 @@ class BackendNotifierTest extends \Test\TestCase {
],
],
],
- ], $bodies);
+ ]);
$this->controller->clearRequests();
$room->setParticipantType($participant, Participant::USER);
- $requests = $this->controller->getRequests();
- $bodies = array_map(function ($request) use ($room) {
- return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true);
- }, $requests);
- $this->assertContains([
+ $this->assertMessageWasSent($room, [
'type' => 'participants',
'participants' => [
'changed' => [
@@ -711,16 +673,12 @@ class BackendNotifierTest extends \Test\TestCase {
],
],
],
- ], $bodies);
+ ]);
$this->controller->clearRequests();
$room->setParticipantType($guestParticipant, Participant::GUEST);
- $requests = $this->controller->getRequests();
- $bodies = array_map(function ($request) use ($room) {
- return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true);
- }, $requests);
- $this->assertContains([
+ $this->assertMessageWasSent($room, [
'type' => 'participants',
'participants' => [
'changed' => [
@@ -755,6 +713,6 @@ class BackendNotifierTest extends \Test\TestCase {
],
],
],
- ], $bodies);
+ ]);
}
}