client = Utility::getClient(); if (!Utility::isOpenSearchVersionAtLeast($this->client, '2.4.0')) { $this->markTestSkipped('Point-in-time tests require OpenSearch >= 2.4.0'); } $this->client->create([ 'index' => self::INDEX, 'id' => 100, 'body' => [ 'title' => 'Remember the Titans', 'director' => 'Boaz Yakin', 'year' => 2000 ] ]); } protected function tearDown(): void { parent::tearDown(); $this->client->indices()->delete([ 'index' => self::INDEX, ]); } public function testDeletePointInTimeSingle() { // Arrange $result = $this->client->createPointInTime([ 'index' => self::INDEX, 'keep_alive' => '10m', ]); $pitId = $result['pit_id']; // Act $result = $this->client->deletePointInTime([ 'body' => [ 'pit_id' => $pitId, ], ]); // Assert $this->assertCount(1, $result['pits']); $pit = $result['pits'][0]; $this->assertTrue($pit['successful']); $this->assertSame($pitId, $pit['pit_id']); } public function testDeletePointInTimeMultiple() { // Arrange $result = $this->client->createPointInTime([ 'index' => self::INDEX, 'keep_alive' => '10m', ]); $pitId1 = $result['pit_id']; $result = $this->client->createPointInTime([ 'index' => self::INDEX, 'keep_alive' => '1h', ]); $pitId2 = $result['pit_id']; // Act $result = $this->client->deletePointInTime([ 'body' => [ 'pit_id' => [$pitId1, $pitId2], ], ]); // Assert $this->assertCount(2, $result['pits']); foreach ($result['pits'] as $pit) { $this->assertTrue($pit['successful']); $this->assertTrue(in_array($pit['pit_id'], [$pitId1, $pitId2])); } } }