fix(tests): Ensure ldap server can be reached in integration tests on GitHub Actions and other improvments

* Run integration tests for every pull request
* Also print docker logs of service containers (ldap, redis)
* Ensure consistent `datadir` for test assertions
* Test openldap features separatly
* Only the LDAP tests rely on `/dev/shm` while `federated.feature` rely on real directory access

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen 2023-10-29 18:51:33 +01:00 committed by Joas Schilling
parent b64d032795
commit 52cc18efc0
No known key found for this signature in database
GPG Key ID: 74434EFE0D2E2205
5 changed files with 34 additions and 9 deletions

View File

@ -2,10 +2,6 @@ name: Integration sqlite
on:
pull_request:
paths:
# Only running on PR for this file to save CI time (otherwise pgsql only)
- '.github/workflows/integration-sqlite.yml'
push:
branches:
- main
@ -63,6 +59,8 @@ jobs:
- 'federation_features'
- '--tags ~@large files_features'
- 'filesdrop_features'
- 'openldap_features'
- 'openldap_numerical_features'
- 'ldap_features'
- 'remoteapi_features'
- 'setup_features'
@ -85,6 +83,8 @@ jobs:
- 6379:6379
openldap:
image: ghcr.io/nextcloud/continuous-integration-openldap:openldap-7
ports:
- 389:389
env:
SLAPD_DOMAIN: nextcloud.ci
SLAPD_ORGANIZATION: Nextcloud
@ -129,15 +129,13 @@ jobs:
run: composer i --no-dev
- name: Set up Nextcloud
env:
DB_PORT: 4444
run: |
mkdir data
./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin
./occ maintenance:install --verbose ${{ contains(matrix.test-suite,'ldap') && '--data-dir=/dev/shm/nc_int' || '' }} --database=sqlite --database-name=nextcloud --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin
./occ config:system:set hashing_default_password --value=true --type=boolean
- name: Configure caching
if: ${{ matrix.test-suite == 'ldap_features' }}
if: ${{ contains(matrix.test-suite,'ldap') }}
run: |
./occ config:system:set redis host --value=localhost
./occ config:system:set redis port --value=6379 --type=integer
@ -147,12 +145,16 @@ jobs:
- name: Run integration
working-directory: build/integration
env:
LDAP_HOST: localhost
run: bash run.sh ${{ matrix.test-suite }} no-tail-log
- name: Print logs
if: always()
run: |
cat data/nextcloud.log
docker ps -a
docker ps -aq | while read container ; do IMAGE=$(docker inspect --format='{{.Config.Image}}' $container); echo $IMAGE; docker logs $container; echo "\n\n" ; done
summary:
permissions:

View File

@ -192,6 +192,26 @@ default:
- admin
- admin
regular_user_password: 123456
openldap_numerical:
paths:
- "%paths.base%/../openldap_numerical_features"
contexts:
- LDAPContext:
baseUrl: http://localhost:8080
admin:
- admin
- admin
regular_user_password: 123456
openldap:
paths:
- "%paths.base%/../openldap_features"
contexts:
- LDAPContext:
baseUrl: http://localhost:8080
admin:
- admin
- admin
regular_user_password: 123456
remoteapi:
paths:
- "%paths.base%/../remoteapi_features"

View File

@ -104,7 +104,7 @@ class LDAPContext implements Context {
$this->asAn('admin');
$this->creatingAnLDAPConfigurationAt('/apps/user_ldap/api/v1/config');
$data = new TableNode([
['configData[ldapHost]', 'openldap'],
['configData[ldapHost]', getenv('LDAP_HOST') ?: 'openldap'],
['configData[ldapPort]', '389'],
['configData[ldapBase]', 'dc=nextcloud,dc=ci'],
['configData[ldapAgentName]', 'cn=admin,dc=nextcloud,dc=ci'],
@ -141,6 +141,9 @@ class LDAPContext implements Context {
$this->asAn('admin');
$configData = $table->getRows();
foreach ($configData as &$row) {
if (str_contains($row[0], 'Host') && getenv('LDAP_HOST')) {
$row[1] = str_replace('openldap', getenv('LDAP_HOST'), $row[1]);
}
$row[0] = 'configData[' . $row[0] . ']';
}
$this->settingTheLDAPConfigurationTo(new TableNode($configData));