|
@@ 185-209 (lines=25) @@
|
| 182 |
|
* |
| 183 |
|
* @return void |
| 184 |
|
*/ |
| 185 |
|
public function addCleaningNotRunningProcessWithoutExtra() |
| 186 |
|
{ |
| 187 |
|
$initialVersion = new ObjectID(); |
| 188 |
|
$initalTask = [ |
| 189 |
|
'_id' => 'testId', |
| 190 |
|
'hosts' => [HOSTNAME => ['9999999' => time() + 60]], |
| 191 |
|
'version' => $initialVersion, |
| 192 |
|
]; |
| 193 |
|
|
| 194 |
|
$this->collection->insertOne($initalTask); |
| 195 |
|
|
| 196 |
|
$this->assertTrue($this->registry->add($this->getProcess('testId'))); |
| 197 |
|
|
| 198 |
|
$this->assertSame(1, $this->collection->count()); |
| 199 |
|
$result = $this->collection->findOne(); |
| 200 |
|
|
| 201 |
|
$expected = [ |
| 202 |
|
'_id' => 'testId', |
| 203 |
|
'hosts' => [HOSTNAME => [getmypid() => ProcessRegistry::MONGO_INT32_MAX]], |
| 204 |
|
'version' => $result['version'], |
| 205 |
|
]; |
| 206 |
|
|
| 207 |
|
$this->assertSame($expected, $result); |
| 208 |
|
$this->assertNotSame((string)$initialVersion, (string)$result['version']); |
| 209 |
|
} |
| 210 |
|
|
| 211 |
|
/** |
| 212 |
|
* @test |
|
@@ 265-289 (lines=25) @@
|
| 262 |
|
* |
| 263 |
|
* @return void |
| 264 |
|
*/ |
| 265 |
|
public function addCleaningExpiredProcessWithoutExtra() |
| 266 |
|
{ |
| 267 |
|
$initialVersion = new ObjectID(); |
| 268 |
|
$initalTask = [ |
| 269 |
|
'_id' => 'testId', |
| 270 |
|
'hosts' => ['different host' => ['1' => strtotime('-1 hour')]], |
| 271 |
|
'version' => $initialVersion, |
| 272 |
|
]; |
| 273 |
|
|
| 274 |
|
$this->collection->insertOne($initalTask); |
| 275 |
|
|
| 276 |
|
$this->assertTrue($this->registry->add($this->getProcess('testId'))); |
| 277 |
|
|
| 278 |
|
$this->assertSame(1, $this->collection->count()); |
| 279 |
|
$result = $this->collection->findOne(); |
| 280 |
|
|
| 281 |
|
$expected = [ |
| 282 |
|
'_id' => 'testId', |
| 283 |
|
'hosts' => [HOSTNAME => [getmypid() => ProcessRegistry::MONGO_INT32_MAX]], |
| 284 |
|
'version' => $result['version'], |
| 285 |
|
]; |
| 286 |
|
|
| 287 |
|
$this->assertSame($expected, $result); |
| 288 |
|
$this->assertNotSame((string)$initialVersion, (string)$result['version']); |
| 289 |
|
} |
| 290 |
|
|
| 291 |
|
/** |
| 292 |
|
* @test |
|
@@ 338-362 (lines=25) @@
|
| 335 |
|
* |
| 336 |
|
* @return void |
| 337 |
|
*/ |
| 338 |
|
public function addCleaningRecycledProcessWithoutExtra() |
| 339 |
|
{ |
| 340 |
|
$initialVersion = new ObjectID(); |
| 341 |
|
$initalTask = [ |
| 342 |
|
'_id' => 'testId', |
| 343 |
|
'hosts' => [HOSTNAME => [getmypid() => time() + 60]], |
| 344 |
|
'version' => $initialVersion, |
| 345 |
|
]; |
| 346 |
|
|
| 347 |
|
$this->collection->insertOne($initalTask); |
| 348 |
|
|
| 349 |
|
$this->assertTrue($this->registry->add($this->getProcess('testId'))); |
| 350 |
|
|
| 351 |
|
$this->assertSame(1, $this->collection->count()); |
| 352 |
|
$result = $this->collection->findOne(); |
| 353 |
|
|
| 354 |
|
$expected = [ |
| 355 |
|
'_id' => 'testId', |
| 356 |
|
'hosts' => [HOSTNAME => [getmypid() => ProcessRegistry::MONGO_INT32_MAX]], |
| 357 |
|
'version' => $result['version'], |
| 358 |
|
]; |
| 359 |
|
|
| 360 |
|
$this->assertSame($expected, $result); |
| 361 |
|
$this->assertNotSame((string)$initialVersion, (string)$result['version']); |
| 362 |
|
} |
| 363 |
|
|
| 364 |
|
/** |
| 365 |
|
* @test |
|
@@ 595-619 (lines=25) @@
|
| 592 |
|
* |
| 593 |
|
* @return void |
| 594 |
|
*/ |
| 595 |
|
public function resetOverflowMinsBeforeExpire() |
| 596 |
|
{ |
| 597 |
|
$initialVersion = new ObjectID(); |
| 598 |
|
$initalTask = [ |
| 599 |
|
'_id' => 'testId', |
| 600 |
|
'hosts' => [HOSTNAME => [getmypid() => time() + 60]], |
| 601 |
|
'version' => $initialVersion, |
| 602 |
|
]; |
| 603 |
|
|
| 604 |
|
$this->collection->insertOne($initalTask); |
| 605 |
|
|
| 606 |
|
$this->registry->reset($this->getProcess('testId', PHP_INT_MAX)); |
| 607 |
|
|
| 608 |
|
$this->assertSame(1, $this->collection->count()); |
| 609 |
|
$result = $this->collection->findOne(); |
| 610 |
|
|
| 611 |
|
$expected = [ |
| 612 |
|
'_id' => 'testId', |
| 613 |
|
'hosts' => [HOSTNAME => [getmypid() => ProcessRegistry::MONGO_INT32_MAX]], |
| 614 |
|
'version' => $result['version'], |
| 615 |
|
]; |
| 616 |
|
|
| 617 |
|
$this->assertSame($expected, $result); |
| 618 |
|
$this->assertNotSame((string)$initialVersion, (string)$result['version']); |
| 619 |
|
} |
| 620 |
|
|
| 621 |
|
/** |
| 622 |
|
* Verify behavior of add() with too much concurrency. |