Sfoglia il codice sorgente

Merge pull request #13107 from overleaf/em-reenable-swap-job-test

Reenable swap job test in git bridge

GitOrigin-RevId: 4fcef9d1b9a6ef169b14ec490b785daeb80ab418
Eric Mc Sween 3 anni fa
parent
commit
a5834a0f8c

+ 1 - 1
services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/swap/job/SwapJob.java

@@ -64,7 +64,7 @@ public interface SwapJob {
         if (!cfg.isPresent()) {
             return new NoopSwapJob();
         }
-        if (!swapStore.isSafe()) {
+        if (!swapStore.isSafe() && !cfg.get().getAllowUnsafeStores()) {
             Log.warn("Swap store '{}' is not safe; disabling swap job", swapStore.getClass().getSimpleName());
             return new NoopSwapJob();
         }

+ 8 - 1
services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/bridge/swap/job/SwapJobConfig.java

@@ -13,19 +13,22 @@ public class SwapJobConfig {
     private final int highGiB;
     private final long intervalMillis;
     private final String compressionMethod;
+    private final boolean allowUnsafeStores;
 
     public SwapJobConfig(
             int minProjects,
             int lowGiB,
             int highGiB,
             long intervalMillis,
-            String compressionMethod
+            String compressionMethod,
+            boolean allowUnsafeStores
     ) {
         this.minProjects = minProjects;
         this.lowGiB = lowGiB;
         this.highGiB = highGiB;
         this.intervalMillis = intervalMillis;
         this.compressionMethod = compressionMethod;
+        this.allowUnsafeStores = allowUnsafeStores;
     }
 
     public int getMinProjects() {
@@ -44,6 +47,10 @@ public class SwapJobConfig {
         return intervalMillis;
     }
 
+    public boolean getAllowUnsafeStores() {
+        return allowUnsafeStores;
+    }
+
     public SwapJob.CompressionMethod getCompressionMethod() {
       CompressionMethod result = SwapJob.stringToCompressionMethod(compressionMethod);
       if (result == null) {

+ 2 - 6
services/git-bridge/src/test/java/uk/ac/ic/wlgitbridge/application/WLGitBridgeIntegrationTest.java

@@ -662,11 +662,6 @@ public class WLGitBridgeIntegrationTest {
 
         }
 
-    // We skip this test because it now hangs. It relies on the in-memory swap
-    // job, but we disable the swap job when the noop or in-memory swap store
-    // are configured. We do that for safety. Such a configuration in a
-    // production environment would lead to data loss.
-    @Ignore
     @Test
     public void wlgbCanSwapProjects(
     ) throws IOException, GitAPIException, InterruptedException {
@@ -677,7 +672,7 @@ public class WLGitBridgeIntegrationTest {
         server.start();
         server.setState(states.get("wlgbCanSwapProjects").get("state"));
         wlgb = new GitBridgeApp(new String[] {
-                makeConfigFile(33874, 3874, new SwapJobConfig(1, 0, 0, 250, null))
+                makeConfigFile(33874, 3874, new SwapJobConfig(1, 0, 0, 250, null, true))
         });
         wlgb.run();
         File rootGitDir = new File(wlgb.config.getRootGitDirectory());
@@ -1099,6 +1094,7 @@ public class WLGitBridgeIntegrationTest {
                     "        \"s3BucketName\": \"com.overleaf.testbucket\"\n" +
                     "    },\n" +
                     "    \"swapJob\": {\n" +
+                    "        \"allowUnsafeStores\": true," +
                     "        \"minProjects\": " +
                     swapCfg.getMinProjects() +
                     ",\n" +