Просмотр исходного кода

Fix NoticeAlert/NoticeWarning rename cases

- NoticeCommonLogger still used "Alert"
- TestBoltResiliency notice checking both checked the wrong notice name and
  failed to handle missing expected notices
Rod Hynes 2 недель назад
Родитель
Сommit
3b62df8c35
4 измененных файлов с 14 добавлено и 6 удалено
  1. 6 0
      psiphon/config.go
  2. 6 4
      psiphon/dataStoreRecovery_test.go
  3. 1 1
      psiphon/dataStore_bolt.go
  4. 1 1
      psiphon/notice.go

+ 6 - 0
psiphon/config.go

@@ -1196,6 +1196,8 @@ type Config struct {
 	ServerEntryIteratorMaxMoveToFront   *int     `json:",omitempty"`
 	ServerEntryIteratorResetProbability *float64 `json:",omitempty"`
 
+	TunnelConnectTimeoutSeconds *int `json:",omitempty"`
+
 	// params is the active parameters.Parameters with defaults, config values,
 	// and, optionally, tactics applied.
 	//
@@ -3085,6 +3087,10 @@ func (config *Config) makeConfigParameters() map[string]interface{} {
 		applyParameters[parameters.EnableDSLFetcher] = *config.EnableDSLFetcher
 	}
 
+	if config.TunnelConnectTimeoutSeconds != nil {
+		applyParameters[parameters.TunnelConnectTimeout] = fmt.Sprintf("%ds", *config.TunnelConnectTimeoutSeconds)
+	}
+
 	// When adding new config dial parameters that may override tactics, also
 	// update setDialParametersHash.
 

+ 6 - 4
psiphon/dataStoreRecovery_test.go

@@ -58,8 +58,10 @@ func TestBoltResiliency(t *testing.T) {
         "ClientVersion" : "0000000000000000",
         "SponsorId" : "0000000000000000",
         "PropagationChannelId" : "0",
-        "ConnectionWorkerPoolSize" : 10,
-        "EstablishTunnelTimeoutSeconds" : 1,
+        "DisableTactics" : true,
+        "ConnectionWorkerPoolSize" : 1,
+        "TunnelConnectTimeoutSeconds" : 1,
+        "EstablishTunnelTimeoutSeconds" : 0,
         "EstablishTunnelPausePeriodSeconds" : 1
     }`
 
@@ -107,7 +109,7 @@ func TestBoltResiliency(t *testing.T) {
 				case noticeExiting <- struct{}{}:
 				default:
 				}
-			case "Alert":
+			case "Warning":
 				message := payload["message"].(string)
 				var channel chan struct{}
 				if strings.Contains(message, "tryDatastoreOpenDB: reset") {
@@ -135,7 +137,7 @@ func TestBoltResiliency(t *testing.T) {
 	drainNoticeChannel := func(channel chan struct{}) {
 		for {
 			select {
-			case channel <- struct{}{}:
+			case <-channel:
 			default:
 				return
 			}

+ 1 - 1
psiphon/dataStore_bolt.go

@@ -222,7 +222,7 @@ func (db *datastoreDB) isDatastoreFailed() bool {
 
 func (db *datastoreDB) setDatastoreFailed(r interface{}) {
 	atomic.StoreInt32(&db.isFailed, 1)
-	NoticeWarning("Datastore failed: %s", errors.Tracef("panic: %v", r))
+	NoticeWarning("%s: %s", errDatastoreFailed.Error(), errors.Tracef("panic: %v", r))
 }
 
 func (db *datastoreDB) close() error {

+ 1 - 1
psiphon/notice.go

@@ -1465,7 +1465,7 @@ func (log *commonLogTrace) Info(args ...interface{}) {
 }
 
 func (log *commonLogTrace) Warning(args ...interface{}) {
-	log.outputNotice("Alert", args...)
+	log.outputNotice("Warning", args...)
 }
 
 func (log *commonLogTrace) Error(args ...interface{}) {