Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore(cypress): enable apcu
Signed-off-by: skjnldsv <[email protected]>
  • Loading branch information
skjnldsv committed Aug 22, 2024
commit d3a0e8308bdc6937fa455800d02c496ab62450c4
30 changes: 24 additions & 6 deletions cypress/dockerNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -91,6 +87,7 @@ export const startNextcloud = async function(branch: string = getCurrentGitBranc
},
Env: [
`BRANCH=${branch}`,
'APCU=1',
],
})
await container.start()
Expand Down Expand Up @@ -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 🎉')
}

Expand Down Expand Up @@ -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,
Expand All @@ -270,18 +286,20 @@ const runExec = async function(
})

return new Promise((resolve, reject) => {
let output = ''
exec.start({}, (err, stream) => {
if (err) {
reject(err)
}
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))
}
})
})
Expand Down