Pārlūkot izejas kodu

Fix test case: don't attempt port forwards in DisableApi mode

Rod Hynes 9 gadi atpakaļ
vecāks
revīzija
7abb3dd551
1 mainītis faili ar 29 papildinājumiem un 25 dzēšanām
  1. 29 25
      psiphon/controller_test.go

+ 29 - 25
psiphon/controller_test.go

@@ -682,40 +682,44 @@ func controllerRun(t *testing.T, runConfig *controllerRunConfig) {
 			}
 		}
 
-		// Test: fetch website through tunnel
+		// Cannot establish port forwards in DisableApi mode
+		if !runConfig.disableApi {
 
-		// Allow for known race condition described in NewHttpProxy():
-		time.Sleep(1 * time.Second)
+			// Test: fetch website through tunnel
 
-		fetchAndVerifyWebsite(t, httpProxyPort)
+			// Allow for known race condition described in NewHttpProxy():
+			time.Sleep(1 * time.Second)
 
-		// Test: run for duration, periodically using the tunnel to
-		// ensure failed tunnel detection, and ultimately hitting
-		// impaired protocol checks.
+			fetchAndVerifyWebsite(t, httpProxyPort)
 
-		startTime := monotime.Now()
+			// Test: run for duration, periodically using the tunnel to
+			// ensure failed tunnel detection, and ultimately hitting
+			// impaired protocol checks.
 
-		for {
+			startTime := monotime.Now()
 
-			time.Sleep(1 * time.Second)
-			useTunnel(t, httpProxyPort)
+			for {
 
-			if startTime.Add(runConfig.runDuration).Before(monotime.Now()) {
-				break
-			}
-		}
+				time.Sleep(1 * time.Second)
+				useTunnel(t, httpProxyPort)
 
-		// Test: with disruptNetwork, impaired protocols should be exercised
+				if startTime.Add(runConfig.runDuration).Before(monotime.Now()) {
+					break
+				}
+			}
 
-		if runConfig.runDuration > 0 && runConfig.disruptNetwork {
-			count := atomic.LoadInt32(&impairedProtocolCount)
-			if count <= 0 {
-				t.Fatalf("unexpected impaired protocol count: %d", count)
-			} else {
-				impairedProtocolClassification.RLock()
-				t.Logf("impaired protocol classification: %+v",
-					impairedProtocolClassification.classification)
-				impairedProtocolClassification.RUnlock()
+			// Test: with disruptNetwork, impaired protocols should be exercised
+
+			if runConfig.runDuration > 0 && runConfig.disruptNetwork {
+				count := atomic.LoadInt32(&impairedProtocolCount)
+				if count <= 0 {
+					t.Fatalf("unexpected impaired protocol count: %d", count)
+				} else {
+					impairedProtocolClassification.RLock()
+					t.Logf("impaired protocol classification: %+v",
+						impairedProtocolClassification.classification)
+					impairedProtocolClassification.RUnlock()
+				}
 			}
 		}
 	}