Forráskód Böngészése

test: wait for ports to be released instead of a fixed 3s CI sleep (#1197)

James Read 20 órája
szülő
commit
3903f59925
1 módosított fájl, 7 hozzáadás és 6 törlés
  1. 7 6
      integration-tests/runner.mjs

+ 7 - 6
integration-tests/runner.mjs

@@ -136,12 +136,13 @@ class OliveTinTestRunnerStartLocalProcess extends OliveTinTestRunner {
 
     this.ot = null
 
-    if (process.env.CI === 'true') {
-      // GitHub runners seem to need a bit more time to clean up
-      await new Promise((res) => setTimeout(res, 3000))
-    } else {
-      await new Promise((res) => setTimeout(res, 50))
-    }
+    // The next suite binds the same ports, so wait until they are released
+    // rather than sleeping for a guessed amount of time.
+    await waitOn({
+      resources: ['tcp:127.0.0.1:1337', 'tcp:127.0.0.1:1341'],
+      reverse: true,
+      timeout: 10000,
+    })
   }
 }