Merge pull request #20686 from overleaf/jpa-faster-e2e

[server-pro] tests: faster reconfiguring

GitOrigin-RevId: 8e9254f5a9e30f7a815eb25a6f226095b7e16c29
This commit is contained in:
Jakob Ackermann 2024-10-02 16:09:20 +02:00 committed by Copybot
parent 2b72d89171
commit ecfc8a1f9a

View file

@ -253,9 +253,10 @@ app.post(
function maybeResetData(resetData, callback) { function maybeResetData(resetData, callback) {
if (!resetData) return callback() if (!resetData) return callback()
previousConfig = ''
runDockerCompose( runDockerCompose(
'stop', 'down',
['--timeout=0', 'sharelatex'], ['--timeout=0', '--volumes', 'mongo', 'redis', 'sharelatex'],
(error, stdout, stderr) => { (error, stdout, stderr) => {
if (error) return callback(error, stdout, stderr) if (error) return callback(error, stdout, stderr)
@ -264,13 +265,7 @@ function maybeResetData(resetData, callback) {
} catch (error) { } catch (error) {
return callback(error) return callback(error)
} }
callback()
previousConfig = ''
runDockerCompose(
'down',
['--timeout=0', '--volumes', 'mongo', 'redis'],
callback
)
} }
) )
} }
@ -294,6 +289,12 @@ app.post(
maybeResetData(resetData, (error, stdout, stderr) => { maybeResetData(resetData, (error, stdout, stderr) => {
if (error) return res.json({ error, stdout, stderr }) if (error) return res.json({ error, stdout, stderr })
const previousConfigServer = previousConfig
const newConfig = JSON.stringify(req.body)
if (previousConfig === newConfig) {
return res.json({ previousConfigServer })
}
try { try {
setVarsDockerCompose({ pro, version, vars, withDataDir }) setVarsDockerCompose({ pro, version, vars, withDataDir })
} catch (error) { } catch (error) {
@ -305,8 +306,7 @@ app.post(
'up', 'up',
['--detach', '--wait', 'sharelatex'], ['--detach', '--wait', 'sharelatex'],
(error, stdout, stderr) => { (error, stdout, stderr) => {
const previousConfigServer = previousConfig previousConfig = newConfig
previousConfig = JSON.stringify(req.body)
res.json({ error, stdout, stderr, previousConfigServer }) res.json({ error, stdout, stderr, previousConfigServer })
} }
) )