|
75 | 75 | // recursive: true, |
76 | 76 | // }); |
77 | 77 | // }); |
| 78 | +<<<<<<< HEAD |
| 79 | +======= |
| 80 | +// describe('Starting the agent in the foreground', () => { |
| 81 | +// test( |
| 82 | +// 'should start the agent and clean up the lockfile when a kill signal is received', |
| 83 | +// async () => { |
| 84 | +// const agent = testUtils.pkExec([ |
| 85 | +// 'agent', |
| 86 | +// 'start', |
| 87 | +// '-np', |
| 88 | +// foregroundNodePath, |
| 89 | +// '--password-file', |
| 90 | +// passwordFile, |
| 91 | +// ]); |
| 92 | +// const status = new Status({ |
| 93 | +// statusPath: statusPath(foregroundNodePath), |
| 94 | +// fs, |
| 95 | +// logger, |
| 96 | +// }); |
| 97 | +// await status.waitFor('LIVE', waitForTimeout); |
| 98 | + |
| 99 | +// // Kill. |
| 100 | +// await killAgent(foregroundNodePath, passwordFile); |
| 101 | + |
| 102 | +// const agentResult = await agent; // Waiting for agent to finish running. |
| 103 | +// await status.waitFor('DEAD', waitForTimeout); |
| 104 | + |
| 105 | +// expect(agentResult.stdout.split(' ')).toHaveLength(24); |
| 106 | +// }, |
| 107 | +// global.polykeyStartupTimeout * 4, |
| 108 | +// ); |
| 109 | +// test( |
| 110 | +// 'should start with port and host information as flags', |
| 111 | +// async () => { |
| 112 | +// const agent = testUtils.pkStdio([ |
| 113 | +// 'agent', |
| 114 | +// 'start', |
| 115 | +// '-np', |
| 116 | +// foregroundNodePath, |
| 117 | +// '--password-file', |
| 118 | +// passwordFile, |
| 119 | +// '-ch', |
| 120 | +// '127.0.0.1', |
| 121 | +// '-cp', |
| 122 | +// '55556', |
| 123 | +// '-ih', |
| 124 | +// '127.0.0.2', |
| 125 | +// '127.0.0.3', |
| 126 | +// '-ip', |
| 127 | +// '55555', |
| 128 | +// ]); |
| 129 | +// const status = new Status({ |
| 130 | +// statusPath: statusPath(foregroundNodePath), |
| 131 | +// fs, |
| 132 | +// logger, |
| 133 | +// }); |
| 134 | +// const statusConfig = await status.waitFor('LIVE', waitForTimeout); |
| 135 | +// expect(statusConfig.data.clientHost).toEqual('127.0.0.1'); |
| 136 | +// expect(statusConfig.data.clientPort).toEqual(55556); |
| 137 | + |
| 138 | +// // Kill externally. |
| 139 | +// await killAgent(foregroundNodePath, passwordFile); |
| 140 | +// await agent; // Waiting for agent to finish running. |
| 141 | +// await status.waitFor('DEAD', waitForTimeout); |
| 142 | +// }, |
| 143 | +// global.polykeyStartupTimeout * 4, |
| 144 | +// ); |
| 145 | +// test( |
| 146 | +// 'should start with port and host information from env', |
| 147 | +// async () => { |
| 148 | +// const agent = testUtils.pkExec( |
| 149 | +// [ |
| 150 | +// 'agent', |
| 151 | +// 'start', |
| 152 | +// '-np', |
| 153 | +// foregroundNodePath, |
| 154 | +// '--password-file', |
| 155 | +// passwordFile, |
| 156 | +// ], |
| 157 | +// { |
| 158 | +// PK_CLIENT_HOST: '127.0.0.1', |
| 159 | +// PK_CLIENT_PORT: '55556', |
| 160 | +// PK_INGRESS_HOST: '127.0.0.2', |
| 161 | +// PK_INGRESS_PORT: '55555', |
| 162 | +// }, |
| 163 | +// ); |
| 164 | + |
| 165 | +// const status = new Status({ |
| 166 | +// statusPath: statusPath(foregroundNodePath), |
| 167 | +// fs, |
| 168 | +// logger, |
| 169 | +// }); |
| 170 | +// const statusConfig = await status.waitFor('LIVE', waitForTimeout); |
| 171 | +// expect(statusConfig.data.clientHost).toEqual('127.0.0.1'); |
| 172 | +// expect(statusConfig.data.clientPort).toEqual(55556); |
| 173 | + |
| 174 | +// // Kill externally. |
| 175 | +// await killAgent(foregroundNodePath, passwordFile); |
| 176 | +// await agent; // Waiting for agent to finish running. |
| 177 | +// await status.waitFor('DEAD', waitForTimeout); |
| 178 | +// }, |
| 179 | +// global.polykeyStartupTimeout * 4, |
| 180 | +// ); |
| 181 | +// test('should fail to start if an agent is already running at the path', async () => { |
| 182 | +// const result = await testUtils.pkStdio([ |
| 183 | +// 'agent', |
| 184 | +// 'start', |
| 185 | +// '-np', |
| 186 | +// activeNodePath, |
| 187 | +// '--password-file', |
| 188 | +// passwordFile, |
| 189 | +// ]); |
| 190 | +// expect(result.exitCode).toBe(75); |
| 191 | +// }); |
| 192 | +// }); |
| 193 | +// describe('Starting the agent in the background', () => { |
| 194 | +// test( |
| 195 | +// 'should start the agent and clean up the lockfile when a kill signal is received', |
| 196 | +// async () => { |
| 197 | +// const commands = [ |
| 198 | +// 'agent', |
| 199 | +// 'start', |
| 200 | +// '-b', |
| 201 | +// '-np', |
| 202 | +// backgroundNodePath, |
| 203 | +// '--password-file', |
| 204 | +// passwordFile, |
| 205 | +// ]; |
| 206 | + |
| 207 | +// // We can await this since it should finish after spawning the background agent. |
| 208 | +// const result = await testUtils.pkStdio(commands); |
| 209 | +// expect(result.exitCode).toBe(0); |
| 210 | + |
| 211 | +// const status = new Status({ |
| 212 | +// statusPath: statusPath(backgroundNodePath), |
| 213 | +// fs, |
| 214 | +// logger, |
| 215 | +// }); |
| 216 | +// await status.waitFor('LIVE', waitForTimeout); |
| 217 | + |
| 218 | +// // Kill it (with fire) externally. |
| 219 | +// await killAgent(backgroundNodePath, passwordFile); |
| 220 | +// await sleep(100); |
| 221 | +// await status.waitFor('DEAD', waitForTimeout); |
| 222 | + |
| 223 | +// expect(result.stdout).toContain('This is your recovery code'); |
| 224 | +// const code = result.stdout.split('\n')[3]; // Getting the recovery code line. |
| 225 | +// expect(code.split(' ')).toHaveLength(24); |
| 226 | + |
| 227 | +// // Checking that the status was removed. FIXME |
| 228 | +// // await poll(global.polykeyStartupTimeout * 2, async () => { |
| 229 | +// // const files = await fs.promises.readdir(backgroundNodePath); |
| 230 | +// // const test = files.includes('agent-status.json'); |
| 231 | +// // return !test; |
| 232 | +// // }); |
| 233 | +// }, |
| 234 | +// global.polykeyStartupTimeout * 5, |
| 235 | +// ); |
| 236 | +// test('Should fail to start if an agent is already running at the path', async () => { |
| 237 | +// const commands = [ |
| 238 | +// 'agent', |
| 239 | +// 'start', |
| 240 | +// '-b', |
| 241 | +// '-np', |
| 242 | +// activeNodePath, |
| 243 | +// '--password-file', |
| 244 | +// passwordFile, |
| 245 | +// ]; |
| 246 | +// // We can await this since it should finish after spawning the background agent. |
| 247 | +// const result = await testUtils.pkStdio(commands); |
| 248 | +// expect(result.exitCode).toBe(75); |
| 249 | +// }); |
| 250 | +// }); |
| 251 | +// test( |
| 252 | +// 'concurrent agent start', |
| 253 | +// async () => { |
| 254 | +// const nodePath = path.join(dataDir, 'third'); |
| 255 | +// const commands = [ |
| 256 | +// 'agent', |
| 257 | +// 'start', |
| 258 | +// '-np', |
| 259 | +// nodePath, |
| 260 | +// '--password-file', |
| 261 | +// passwordFile, |
| 262 | +// ]; |
| 263 | + |
| 264 | +// // We can await this since it should finish after spawning the background agent. |
| 265 | +// const prom1 = testUtils.pkExec(commands); |
| 266 | +// const prom2 = testUtils.pkExec(commands); |
| 267 | + |
| 268 | +// const status = new Status({ |
| 269 | +// statusPath: statusPath(nodePath), |
| 270 | +// fs, |
| 271 | +// logger, |
| 272 | +// }); |
| 273 | +// await status.waitFor('LIVE', waitForTimeout); |
| 274 | + |
| 275 | +// // Kill externally. |
| 276 | +// const results = await Promise.all([prom1, prom2]); // Waiting for agent to finish running. |
| 277 | +// const resultsString = JSON.stringify(results); |
| 278 | +// expect(resultsString).toContain(':75'); |
| 279 | +// expect(resultsString).toContain(':0'); |
| 280 | +// }, |
| 281 | +// global.defaultTimeout * 4, |
| 282 | +// ); |
| 283 | +// test( |
| 284 | +// 'concurrent agent start and bootstrap.', |
| 285 | +// async () => { |
| 286 | +// const nodePath = path.join(dataDir, 'third'); |
| 287 | +// const command1 = [ |
| 288 | +// 'agent', |
| 289 | +// 'start', |
| 290 | +// '-np', |
| 291 | +// nodePath, |
| 292 | +// '--password-file', |
| 293 | +// passwordFile, |
| 294 | +// ]; |
| 295 | +// const command2 = [ |
| 296 | +// 'bootstrap', |
| 297 | +// '-np', |
| 298 | +// nodePath, |
| 299 | +// '--password-file', |
| 300 | +// passwordFile, |
| 301 | +// ]; |
| 302 | + |
| 303 | +// // We can await this since it should finish after spawning the background agent. |
| 304 | +// const prom1 = testUtils.pkExec(command1); |
| 305 | +// const prom2 = testUtils.pkExec(command2); |
| 306 | + |
| 307 | +// const status = new Status({ |
| 308 | +// statusPath: statusPath(nodePath), |
| 309 | +// fs, |
| 310 | +// logger, |
| 311 | +// }); |
| 312 | +// try { |
| 313 | +// await status.waitFor('LIVE', 20000); |
| 314 | +// } catch (e) { |
| 315 | +// // Noop |
| 316 | +// } |
| 317 | +// // Kill externally. |
| 318 | +// await killAgent(nodePath, passwordFile); |
| 319 | + |
| 320 | +// const results = await Promise.all([prom1, prom2]); // Waiting for agent to finish running. |
| 321 | +// expect(results[0].exitCode).toBe(0); |
| 322 | +// expect(results[1].exitCode).toBe(64); |
| 323 | +// }, |
| 324 | +// global.defaultTimeout * 5, |
| 325 | +// ); |
| 326 | + |
| 327 | +>>>>>>> f09f815f (Fixing tests/bin/sessions, removed nested describes and concurrent test) |
78 | 328 | // describe('getting agent status', () => { |
79 | 329 | // test('should get the status of an online agent', async () => { |
80 | 330 | // const result = await testUtils.pkStdio([ |
|
0 commit comments