(t *testing.T)
| 178 | } |
| 179 | |
| 180 | func TestServer_MultipleMessages(t *testing.T) { |
| 181 | t.Parallel() |
| 182 | |
| 183 | socketPath := filepath.Join(testutil.TempDirUnixSocket(t), "boundary.sock") |
| 184 | srv := boundarylogproxy.NewServer(testutil.Logger(t), socketPath, prometheus.NewRegistry()) |
| 185 | |
| 186 | ctx, cancel := context.WithCancel(context.Background()) |
| 187 | defer cancel() |
| 188 | |
| 189 | err := srv.Start() |
| 190 | require.NoError(t, err) |
| 191 | defer srv.Close() |
| 192 | |
| 193 | reporter := &fakeReporter{} |
| 194 | |
| 195 | forwarderDone := make(chan error, 1) |
| 196 | go func() { |
| 197 | forwarderDone <- srv.RunForwarder(ctx, reporter) |
| 198 | }() |
| 199 | |
| 200 | conn, err := net.Dial("unix", socketPath) |
| 201 | require.NoError(t, err) |
| 202 | defer conn.Close() |
| 203 | |
| 204 | // Send multiple messages and verify they are all received. |
| 205 | for range 5 { |
| 206 | req := &agentproto.ReportBoundaryLogsRequest{ |
| 207 | Logs: []*agentproto.BoundaryLog{ |
| 208 | { |
| 209 | Allowed: true, |
| 210 | Time: timestamppb.Now(), |
| 211 | Resource: &agentproto.BoundaryLog_HttpRequest_{ |
| 212 | HttpRequest: &agentproto.BoundaryLog_HttpRequest{ |
| 213 | Method: "POST", |
| 214 | Url: "https://example.com/api", |
| 215 | }, |
| 216 | }, |
| 217 | }, |
| 218 | }, |
| 219 | } |
| 220 | sendLogs(t, conn, req) |
| 221 | } |
| 222 | |
| 223 | require.Eventually(t, func() bool { |
| 224 | logs := reporter.getLogs() |
| 225 | return len(logs) == 5 |
| 226 | }, testutil.WaitShort, testutil.IntervalFast) |
| 227 | |
| 228 | cancel() |
| 229 | <-forwarderDone |
| 230 | } |
| 231 | |
| 232 | func TestServer_MultipleConnections(t *testing.T) { |
| 233 | t.Parallel() |
nothing calls this directly
no test coverage detected