Skip to content

Commit

Permalink
Added experimental php 8.0 and elasticsearch 8.0 (#2123)
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-andreyev authored Apr 4, 2023
1 parent 87a8bf5 commit 96f8c9d
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 13 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ jobs:
runs-on: 'ubuntu-20.04'
name: 'PHPUnit (PHP ${{ matrix.php }}, ES ${{ matrix.elasticsearch }})'
timeout-minutes: 10
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
php:
- '8.0'
- '8.1'
- '8.2'
experimental:
- false
dependencies:
- 'highest'
elasticsearch:
Expand All @@ -43,6 +46,10 @@ jobs:
- dependencies: 'lowest'
php: '8.0'
elasticsearch: '7.15.2'
experimental: false
- php: '8.1'
elasticsearch: '8.0.0'
experimental: true
fail-fast: false
steps:
- name: 'Checkout'
Expand All @@ -67,16 +74,21 @@ jobs:
vendor/bin/phpunit --group unit --coverage-clover=build/coverage/unit-coverage.xml
- name: 'Setup Elasticsearch'
env:
ES_VERSION: "${{ matrix.elasticsearch }}"
run: |
sudo swapoff -a
sudo sysctl -w vm.swappiness=1
sudo sysctl -w fs.file-max=262144
sudo sysctl -w vm.max_map_count=262144
ES_VERSION=${{ matrix.elasticsearch }} docker-compose --file=docker/docker-compose.proxy.yml --file=docker/docker-compose.es.yml up --detach
docker compose --file=docker/docker-compose.proxy.yml --file=docker/docker-compose.es.yml up --detach
docker run --rm --network=docker_elastic curlimages/curl --max-time 120 --retry-max-time 120 --retry 120 --retry-delay 5 --retry-all-errors --show-error --silent http://es01:9200
docker run --rm --network=docker_elastic curlimages/curl --max-time 120 --retry-max-time 120 --retry 120 --retry-delay 5 --retry-all-errors --show-error --silent http://es02:9200
- name: 'Run functional tests'
env:
ES_VERSION: "${{ matrix.elasticsearch }}"
run: |
vendor/bin/phpunit --group functional --coverage-clover=build/coverage/functional-coverage.xml
Expand All @@ -85,6 +97,11 @@ jobs:
with:
files: build/coverage/unit-coverage.xml,build/coverage/functional-coverage.xml

- name: Elasticsearch Logs
if: always()
run: |
docker compose --file=docker/docker-compose.proxy.yml --file=docker/docker-compose.es.yml logs es01 es02
phpstan:
runs-on: 'ubuntu-20.04'
name: 'PHPStan'
Expand Down
14 changes: 9 additions & 5 deletions docker/docker-compose.es.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
version: '3.4'
version: '3.8'

services:
es01:
image: &image docker.elastic.co/elasticsearch/elasticsearch:${ES_VERSION:-7.15.2}
command: &command >
/bin/sh -c "./bin/elasticsearch-plugin list | grep -q ingest-attachment
|| ./bin/elasticsearch-plugin install --batch ingest-attachment;
chown elasticsearch /usr/share/elasticsearch/repository;
/usr/local/bin/docker-entrypoint.sh"
/bin/sh -c "(./bin/elasticsearch-plugin list | grep -q ingest-attachment || ./bin/elasticsearch-plugin install --batch ingest-attachment) && /usr/local/bin/docker-entrypoint.sh"
environment: &environment
node.name: es01
cluster.name: es-docker-cluster
cluster.initial_master_nodes: es01
discovery.seed_hosts: es01
bootstrap.memory_lock: 'true'
xpack.security.enabled: 'false'
action.destructive_requires_name: 'false'
indices.id_field_data.enabled: 'true'
ES_JAVA_OPTS: -Xms512m -Xmx512m
path.repo: /usr/share/elasticsearch/repository
ulimits: &ulimits
Expand Down Expand Up @@ -42,6 +42,10 @@ volumes:
data01:
data02:
esrepo:
driver_opts:
type: tmpfs
device: tmpfs
o: "uid=1000,gid=0"

networks:
elastic:
Expand Down
6 changes: 4 additions & 2 deletions tests/Aggregation/RangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function testRangeAggregation(): void
$query->addAggregation($agg);
$results = $this->_getIndexForTest()->search($query)->getAggregation('range');

$this->assertEquals(2, $results['buckets'][0]['doc_count']);
$this->assertEquals(3, $results['buckets'][0]['doc_count']);
}

/**
Expand Down Expand Up @@ -88,11 +88,13 @@ protected function _getIndexForTest(): Index
$index = $this->_createIndex();

$index->addDocuments([
// this is not a mistake, dynamic mapping will take first type
// and if we want to have decimal as type, it should go first
new Document('5', ['price' => 1.5]),
new Document('1', ['price' => 5]),
new Document('2', ['price' => 8]),
new Document('3', ['price' => 1]),
new Document('4', ['price' => 3]),
new Document('5', ['price' => 1.5]),
new Document('6', ['price' => 2]),
]);

Expand Down
8 changes: 8 additions & 0 deletions tests/Cluster/SettingsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class SettingsTest extends BaseTest
*/
public function testSetTransient(): void
{
if (\version_compare($_SERVER['ES_VERSION'], '7.0.0', '>=')) {
$this->markTestSkipped('discovery.zen.minimum_master_nodes is deprecated, ignored in 7.x and removed in 8.x, see: https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking-changes-8.0');
}

$index = $this->_createIndex();

if (\count($index->getClient()->getCluster()->getNodes()) < 2) {
Expand All @@ -39,6 +43,10 @@ public function testSetTransient(): void
*/
public function testSetPersistent(): void
{
if (\version_compare($_SERVER['ES_VERSION'], '7.0.0', '>=')) {
$this->markTestSkipped('discovery.zen.minimum_master_nodes is deprecated, ignored in 7.x and removed in 8.x, see: https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking-changes-8.0');
}

$index = $this->_createIndex();

if (\count($index->getClient()->getCluster()->getNodes()) < 2) {
Expand Down
10 changes: 7 additions & 3 deletions tests/MappingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,16 @@ public function testMappingExample(): void
{
$index = $this->_createIndex();

// The boost parameter on field mappings has been removed.
// @see https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking-changes-8.0
$isEs8 = \version_compare($_SERVER['ES_VERSION'], '8.0.0', '>=');

$mapping = new Mapping([
'note' => [
'properties' => [
'titulo' => ['type' => 'text', 'copy_to' => 'testall', 'boost' => 1.0],
'contenido' => ['type' => 'text', 'copy_to' => 'testall', 'boost' => 1.0],
'testall' => ['type' => 'text', 'boost' => 1.0],
'titulo' => ['type' => 'text', 'copy_to' => 'testall'] + (!$isEs8 ? ['boost' => 1.0] : []),
'contenido' => ['type' => 'text', 'copy_to' => 'testall'] + (!$isEs8 ? ['boost' => 1.0] : []),
'testall' => ['type' => 'text'] + (!$isEs8 ? ['boost' => 1.0] : []),
],
],
]);
Expand Down
6 changes: 6 additions & 0 deletions tests/ReindexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ public function testReindexWithQueryOption(): void
*/
public function testReindexWithSizeOption(): void
{
// @see https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking-changes-8.0
$isEs8 = \version_compare($_SERVER['ES_VERSION'], '8.0.0', '>=');
if ($isEs8) {
$this->markTestSkipped('In the reindex, delete by query, and update by query APIs, the size parameter has been renamed.');
}

$oldIndex = $this->_createIndex('idx1', true, 2);
$this->_addDocs($oldIndex, 10);

Expand Down
6 changes: 6 additions & 0 deletions tests/ResponseFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ public function testGetDataEmpty(): void
$index = $this->_createIndex();
$gotException = false;

// @see https://www.elastic.co/guide/en/elasticsearch/reference/master/migrating-8.0.html#breaking-changes-8.0
$isEs8 = \version_compare($_SERVER['ES_VERSION'], '8.0.0', '>=');
if ($isEs8) {
$this->markTestSkipped('REST API endpoints containing mapping types have been removed.');
}

try {
$index->request(
'non-existent-type/_mapping',
Expand Down
2 changes: 1 addition & 1 deletion tests/Transport/GuzzleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function testBodyReuse(): void

$this->assertEquals(0, $resultSet->getTotalHits());

$response = $index->request('/_search', 'POST');
$response = $index->request('_search', 'POST');

$builder = new DefaultBuilder();
$resultSet = $builder->buildResultSet($response, Query::create([]));
Expand Down
2 changes: 1 addition & 1 deletion tests/Transport/HttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function testBodyReuse(): void

$this->assertEquals(0, $resultSet->getTotalHits());

$response = $index->request('/_search', 'POST');
$response = $index->request('_search', 'POST');

$builder = new DefaultBuilder();
$resultSet = $builder->buildResultSet($response, Query::create([]));
Expand Down

0 comments on commit 96f8c9d

Please sign in to comment.