From 39f43799d2f5904cec78e050ee2df6c8ddd74c43 Mon Sep 17 00:00:00 2001 From: skjnldsv Date: Wed, 21 Aug 2024 12:41:03 +0200 Subject: [PATCH] chore(cypress): enable redis Signed-off-by: skjnldsv --- cypress/dockerNode.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/cypress/dockerNode.ts b/cypress/dockerNode.ts index 33c2829c9d0bb..ab9651059c652 100644 --- a/cypress/dockerNode.ts +++ b/cypress/dockerNode.ts @@ -117,12 +117,40 @@ 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) + // Setup redis + await runExec(container, ['service', 'redis-server', 'start'], true, 'root') + await runExec(container, ['php', 'occ', 'config:system:set', 'memcache.distributed', '--value', '\\OC\\Memcache\\Redis'], true) + await runExec(container, ['php', 'occ', 'config:system:set', 'memcache.locking', '--value', '\\OC\\Memcache\\Redis'], true) + await runExec(container, ['php', 'occ', 'config:system:set', 'redis', 'host', '--value', 'localhost'], true) + await runExec(container, ['php', 'occ', 'config:system:set', 'redis', 'port', '--value', '6379', '--type', 'integer'], true) + + // 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 🎉') } +export const createSnapshot = async function(): Promise { + console.log('\nSaving Nextcloud DB...') + const randomString = Math.random().toString(36).substring(7) + const container = docker.getContainer(CONTAINER_NAME) + await runExec(container, ['cp', '/var/www/html/data/owncloud.db', '/var/www/html/data/owncloud.db-' + randomString], true) + console.log('└─ Done') + return randomString +} + +export const restoreSnapshot = async function(snapshot: string) { + console.log('\nRestoring Nextcloud DB...') + const container = docker.getContainer(CONTAINER_NAME) + await runExec(container, ['cp', '/var/www/html/data/owncloud.db-' + snapshot, '/var/www/html/data/owncloud.db'], true) + console.log('└─ Done') +} + /** * Applying local changes to the container * Only triggered if we're not in CI. Otherwise the