]> source.dussan.org Git - nextcloud-server.git/commitdiff
chore(cypress): enable apcu
authorskjnldsv <skjnldsv@protonmail.com>
Thu, 22 Aug 2024 06:59:19 +0000 (08:59 +0200)
committerJohn Molakvoæ <skjnldsv@users.noreply.github.com>
Thu, 22 Aug 2024 11:32:59 +0000 (13:32 +0200)
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
cypress/dockerNode.ts

index 14ca7b936b1764db873d0c0856c4e43f256dbe14..2c8aa6c510911a88bf5a5ea0d3dff39e15f8262e 100644 (file)
@@ -41,10 +41,6 @@ export const startNextcloud = async function(branch: string = getCurrentGitBranc
                                // https://github.com/apocas/dockerode/issues/357
                                docker.modem.followProgress(stream, onFinished)
 
-                               /**
-                                *
-                                * @param err
-                                */
                                function onFinished(err) {
                                        if (!err) {
                                                resolve(true)
@@ -91,6 +87,7 @@ export const startNextcloud = async function(branch: string = getCurrentGitBranc
                        },
                        Env: [
                                `BRANCH=${branch}`,
+                               'APCU=1',
                        ],
                })
                await container.start()
@@ -129,9 +126,28 @@ export const configureNextcloud = async function() {
        await runExec(container, ['php', 'occ', 'config:system:set', 'default_locale', '--value', 'en_US'], true)
        await runExec(container, ['php', 'occ', 'config:system:set', 'force_locale', '--value', 'en_US'], true)
        await runExec(container, ['php', 'occ', 'config:system:set', 'enforce_theme', '--value', 'light'], true)
+
        // Speed up test and make them less flaky. If a cron execution is needed, it can be triggered manually.
        await runExec(container, ['php', 'occ', 'background:cron'], true)
 
+       // Checking apcu
+       const distributed = await runExec(container, ['php', 'occ', 'config:system:get', 'memcache.distributed'])
+       const local = await runExec(container, ['php', 'occ', 'config:system:get', 'memcache.local'])
+       const hashing = await runExec(container, ['php', 'occ', 'config:system:get', 'hashing_default_password'])
+
+       console.log('β”œβ”€ Checking APCu configuration... πŸ‘€')
+       if (!distributed.trim().includes('\\OC\\Memcache\\APCu')
+               || !local.trim().includes('\\OC\\Memcache\\APCu')
+               || !hashing.trim().includes('true')) {
+               console.log('└─ APCu is not properly configured πŸ›‘')
+               throw new Error('APCu is not properly configured')
+       }
+       console.log('β”‚  β””─ OK !')
+
+       // Saving DB state
+       console.log('β”œβ”€ Creating init DB snapshot...')
+       await runExec(container, ['cp', '/var/www/html/data/owncloud.db', '/var/www/html/data/owncloud.db-init'], true)
+
        console.log('└─ Nextcloud is now ready to use πŸŽ‰')
 }
 
@@ -261,7 +277,7 @@ const runExec = async function(
        command: string[],
        verbose = false,
        user = 'www-data',
-) {
+): Promise<string> {
        const exec = await container.exec({
                Cmd: command,
                AttachStdout: true,
@@ -270,6 +286,7 @@ const runExec = async function(
        })
 
        return new Promise((resolve, reject) => {
+               let output = ''
                exec.start({}, (err, stream) => {
                        if (err) {
                                reject(err)
@@ -277,11 +294,12 @@ const runExec = async function(
                        if (stream) {
                                stream.setEncoding('utf-8')
                                stream.on('data', str => {
+                                       output += str
                                        if (verbose && str.trim() !== '') {
                                                console.log(`β”œβ”€ ${str.trim().replace(/\n/gi, '\nβ”œβ”€ ')}`)
                                        }
                                })
-                               stream.on('end', resolve)
+                               stream.on('end', () => resolve(output))
                        }
                })
        })