nolint:paralleltest // Measures timing as part of the test.
(t *testing.T)
| 107 | |
| 108 | //nolint:paralleltest // Measures timing as part of the test. |
| 109 | func Test_Runner_Timing(t *testing.T) { |
| 110 | testutil.SkipIfNotTiming(t) |
| 111 | //nolint:paralleltest |
| 112 | t.Run("Direct+Hold", func(t *testing.T) { |
| 113 | client, agentID := setupRunnerTest(t) |
| 114 | |
| 115 | runner := agentconn.NewRunner(client, agentconn.Config{ |
| 116 | AgentID: agentID, |
| 117 | ConnectionMode: agentconn.ConnectionModeDirect, |
| 118 | HoldDuration: httpapi.Duration(testutil.WaitShort), |
| 119 | }) |
| 120 | |
| 121 | ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) |
| 122 | defer cancel() |
| 123 | |
| 124 | logs := bytes.NewBuffer(nil) |
| 125 | start := time.Now() |
| 126 | err := runner.Run(ctx, "1", logs) |
| 127 | logStr := logs.String() |
| 128 | t.Log("Runner logs:\n\n" + logStr) |
| 129 | require.NoError(t, err) |
| 130 | |
| 131 | require.WithinRange(t, |
| 132 | time.Now(), |
| 133 | start.Add(testutil.WaitShort-time.Second), |
| 134 | start.Add(testutil.WaitShort+5*time.Second), |
| 135 | ) |
| 136 | |
| 137 | require.Contains(t, logStr, "Opening connection to workspace agent") |
| 138 | require.Contains(t, logStr, "Using direct connection") |
| 139 | require.Contains(t, logStr, "Disco ping attempt 1/10...") |
| 140 | require.Contains(t, logStr, "Direct connection check 1/30...") |
| 141 | require.Contains(t, logStr, "Connection established") |
| 142 | require.Contains(t, logStr, "Verify connection attempt 1/30...") |
| 143 | require.Contains(t, logStr, "Connection verified") |
| 144 | require.NotContains(t, logStr, "Performing initial service connections") |
| 145 | require.NotContains(t, logStr, "Starting connection loops") |
| 146 | require.Contains(t, logStr, fmt.Sprintf("Waiting for %s", testutil.WaitShort)) |
| 147 | }) |
| 148 | |
| 149 | //nolint:paralleltest |
| 150 | t.Run("Derp+Hold+Services", func(t *testing.T) { |
| 151 | client, agentID := setupRunnerTest(t) |
| 152 | service1URL, service1Count := testServer(t) |
| 153 | service2URL, service2Count := testServer(t) |
| 154 | service3URL, service3Count := testServer(t) |
| 155 | |
| 156 | runner := agentconn.NewRunner(client, agentconn.Config{ |
| 157 | AgentID: agentID, |
| 158 | ConnectionMode: agentconn.ConnectionModeDerp, |
| 159 | HoldDuration: httpapi.Duration(testutil.WaitShort), |
| 160 | Connections: []agentconn.Connection{ |
| 161 | { |
| 162 | URL: service1URL, |
| 163 | // No interval. |
| 164 | Timeout: httpapi.Duration(time.Second), |
| 165 | }, |
| 166 | { |
nothing calls this directly
no test coverage detected