| 97 | } |
| 98 | |
| 99 | func TestIPCReloadConfig(t *testing.T) { |
| 100 | defer goleak.VerifyNone(t) |
| 101 | vh, errs := setupTwoNodeHarness(t) |
| 102 | defer vh.Stop() |
| 103 | |
| 104 | time.Sleep(1 * time.Second) |
| 105 | |
| 106 | // Write the current central config to a temp file |
| 107 | cfgData, err := yaml.Marshal(&vh.Central) |
| 108 | require.NoError(t, err) |
| 109 | tmpFile := t.TempDir() + "/central.yaml" |
| 110 | require.NoError(t, os.WriteFile(tmpFile, cfgData, 0600)) |
| 111 | |
| 112 | a := vh.Nylons[vh.IndexOf("a")].Load() |
| 113 | a.ConfigPath = tmpFile |
| 114 | done := make(chan *protocol.IpcResponse, 1) |
| 115 | go func() { |
| 116 | resp := ipcCall(t, a, &protocol.IpcRequest{ |
| 117 | Request: &protocol.IpcRequest_Reload{Reload: &protocol.ReloadRequest{}}, |
| 118 | }) |
| 119 | done <- resp |
| 120 | }() |
| 121 | |
| 122 | select { |
| 123 | case resp := <-done: |
| 124 | assert.True(t, resp.Ok) |
| 125 | r := resp.GetReload() |
| 126 | assert.Contains(t, []protocol.ReloadResult{protocol.ReloadResult_APPLIED}, r.Result) |
| 127 | case err := <-errs: |
| 128 | t.Fatal(err) |
| 129 | case <-time.After(10 * time.Second): |
| 130 | t.Fatal("timeout") |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | func TestIPCProbeNonNeighbour(t *testing.T) { |
| 135 | defer goleak.VerifyNone(t) |