(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestJSONLogging(t *testing.T) { |
| 13 | t.Parallel() |
| 14 | h := NewHarness(t) |
| 15 | |
| 16 | node1Key := state.GenerateKey() |
| 17 | node2Key := state.GenerateKey() |
| 18 | |
| 19 | node1IP := GetIP(h.Subnet, 10) |
| 20 | node2IP := GetIP(h.Subnet, 11) |
| 21 | |
| 22 | node1NylonIP := "10.0.0.1" |
| 23 | node2NylonIP := "10.0.0.2" |
| 24 | |
| 25 | configDir := h.SetupTestDir() |
| 26 | |
| 27 | central := state.CentralCfg{ |
| 28 | Routers: []state.RouterCfg{ |
| 29 | SimpleRouter("node1", node1Key.Pubkey(), node1NylonIP, node1IP), |
| 30 | SimpleRouter("node2", node2Key.Pubkey(), node2NylonIP, node2IP), |
| 31 | }, |
| 32 | Graph: []string{ |
| 33 | "node1, node2", |
| 34 | }, |
| 35 | Timestamp: time.Now().UnixNano(), |
| 36 | } |
| 37 | |
| 38 | centralPath := h.WriteConfig(configDir, "central.yaml", central) |
| 39 | |
| 40 | node1Cfg := SimpleLocal("node1", node1Key) |
| 41 | node1Path := h.WriteConfig(configDir, "node1.yaml", node1Cfg) |
| 42 | |
| 43 | node2Cfg := SimpleLocal("node2", node2Key) |
| 44 | node2Path := h.WriteConfig(configDir, "node2.yaml", node2Cfg) |
| 45 | |
| 46 | h.StartNodes( |
| 47 | NodeSpec{ |
| 48 | Name: "node1", |
| 49 | IP: node1IP, |
| 50 | CentralConfigPath: centralPath, |
| 51 | NodeConfigPath: node1Path, |
| 52 | ExtraArgs: []string{"--json"}, |
| 53 | }, |
| 54 | NodeSpec{ |
| 55 | Name: "node2", |
| 56 | IP: node2IP, |
| 57 | CentralConfigPath: centralPath, |
| 58 | NodeConfigPath: node2Path, |
| 59 | ExtraArgs: []string{"--json"}, |
| 60 | }, |
| 61 | ) |
| 62 | |
| 63 | t.Log("Waiting for JSON log pattern...") |
| 64 | h.WaitForMatch("node1", `\{"time":".*","level":".*","msg":".*"`) |
| 65 | h.WaitForMatch("node2", `\{"time":".*","level":".*","msg":".*"`) |
| 66 | } |
nothing calls this directly
no test coverage detected