Skip to content

Commit 38e821f

Browse files
committed
Prepare for 7.9.1 release
1 parent d86e1f8 commit 38e821f

File tree

5 files changed

+127
-37
lines changed

5 files changed

+127
-37
lines changed

.ci/test-matrix.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
STACK_VERSION:
3-
- 7.x-SNAPSHOT
4-
3+
- 7.9.2
4+
55
PHP_VERSION:
66
- 7.4-cli
77
- 7.3-cli

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## Release 7.9.1
2+
3+
- Fixed using object instead of array in onFailure transport event
4+
[#1066](https://github.com/elastic/elasticsearch-php/pull/1066)
5+
- Fixed reset custom header after endpoint call
6+
[#1065](https://github.com/elastic/elasticsearch-php/pull/1065)
7+
- Show generic error messages when server returns no response
8+
[#1056](https://github.com/elastic/elasticsearch-php/pull/1056)
9+
110
## Release 7.9.0
211

312
- Updated endpoints and namespaces for Elasticsearch 7.9

util/ActionTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ class ActionTest
4747
const TEMPLATE_SET_VARIABLE = __DIR__ . '/template/test/set-variable';
4848
const TEMPLATE_TRANSFORM_AND_SET = __DIR__ . '/template/test/transform-and-set';
4949
const TEMPLATE_WARNINGS = __DIR__ . '/template/test/warnings';
50+
const TEMPLATE_GT = __DIR__ . '/template/test/gt';
51+
const TEMPLATE_GTE = __DIR__ . '/template/test/gte';
52+
const TEMPLATE_LT = __DIR__ . '/template/test/lt';
53+
const TEMPLATE_LTE = __DIR__ . '/template/test/lte';
5054
const TAB14 = ' ';
5155
const SUPPORTED_FEATURES = ['xpack', 'no_xpack', 'headers', 'node_selector', 'warnings', 'catch_unauthorized', 'transform_and_set'];
5256

@@ -324,6 +328,42 @@ private function teardown(array $actions)
324328
return $this->do($actions);
325329
}
326330

331+
private function gt(array $actions)
332+
{
333+
$key = key($actions);
334+
return YamlTests::render(self::TEMPLATE_GT, [
335+
':expected' => $actions[$key],
336+
':value' => $this->convertResponseField($key)
337+
]);
338+
}
339+
340+
private function gte(array $actions)
341+
{
342+
$key = key($actions);
343+
return YamlTests::render(self::TEMPLATE_GTE, [
344+
':expected' => $actions[$key],
345+
':value' => $this->convertResponseField($key)
346+
]);
347+
}
348+
349+
private function lt(array $actions)
350+
{
351+
$key = key($actions);
352+
return YamlTests::render(self::TEMPLATE_LT, [
353+
':expected' => $actions[$key],
354+
':value' => $this->convertResponseField($key)
355+
]);
356+
}
357+
358+
private function lte(array $actions)
359+
{
360+
$key = key($actions);
361+
return YamlTests::render(self::TEMPLATE_LTE, [
362+
':expected' => $actions[$key],
363+
':value' => $this->convertResponseField($key)
364+
]);
365+
}
366+
327367
/**
328368
* ---------- FEATURE FUNCTIONS (END) ----------
329369
*/

util/GenerateEndpoints.php

Lines changed: 75 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,42 @@
1919
use Elasticsearch\Util\ClientEndpoint;
2020
use Elasticsearch\Util\Endpoint;
2121
use Elasticsearch\Util\NamespaceEndpoint;
22+
use Elasticsearch\Tests\Utility;
2223

2324
require_once dirname(__DIR__) . '/vendor/autoload.php';
2425

26+
27+
28+
removeDirectory(__DIR__ . '/../src/Elasticsearch/Endpoints', [
29+
__DIR__ . '/../src/Elasticsearch/Endpoints/AbstractEndpoint.php',
30+
]);
31+
removeDirectory(__DIR__ . '/../src/Elasticsearch/Namespaces', [
32+
__DIR__ . '/../src/Elasticsearch/Namespaces/AbstractNamespace.php',
33+
__DIR__ . '/../src/Elasticsearch/Namespaces/BooleanRequestWrapper.php',
34+
__DIR__ . '/../src/Elasticsearch/Namespaces/NamespaceBuilderInterface.php'
35+
]);
36+
37+
die();
38+
printf ("Generating endpoints for Elasticsearch\n");
39+
printf ("---\n");
40+
2541
$start = microtime(true);
26-
if (!isset($argv[1])) {
27-
print_usage_msg();
28-
exit(1);
29-
}
30-
if ($argv[1] < '7.3.0') {
31-
printf("Error: the version must be >= 7.4.0\n");
42+
43+
$client = Utility::getClient();
44+
45+
$serverInfo = $client->info();
46+
$version = $serverInfo['version']['number'];
47+
$buildHash = $serverInfo['version']['build_hash'];
48+
49+
if (version_compare($version, '7.4.0', '<')) {
50+
printf("Error: the ES version must be >= 7.4.0\n");
3251
exit(1);
3352
}
3453

35-
$ver = $argv[1];
36-
$version = 'v' . $ver;
37-
3854
$gitWrapper = new GitWrapper();
3955
$git = $gitWrapper->workingCopy(dirname(__DIR__) . '/util/elasticsearch');
4056

41-
$git->run('fetch', ['--all']);
42-
$tags = explode("\n", $git->run('tag'));
43-
if (!in_array($version, $tags)) {
44-
$branches = explode("\n", $git->run('branch', ['-r']));
45-
array_walk($branches, function(&$value, &$key) {
46-
$value = trim($value);
47-
});
48-
$version = "origin/$ver";
49-
if (!in_array($version, $branches)) {
50-
printf("Error: the version %s specified doesnot exist\n", $version);
51-
exit(1);
52-
}
53-
}
54-
55-
$git->run('checkout', [$version]);
57+
$git->run('checkout', [$buildHash]);
5658
$result = $git->run(
5759
'ls-files',
5860
[
@@ -61,7 +63,7 @@
6163
]
6264
);
6365
$files = explode("\n", $result);
64-
$outputDir = __DIR__ . "/output/$ver";
66+
$outputDir = __DIR__ . "/output/$version";
6567

6668
// Remove the output directory
6769
printf ("Removing %s folder\n", $outputDir);
@@ -82,7 +84,7 @@
8284
}
8385
printf("Generation %s...", basename($file));
8486

85-
$endpoint = new Endpoint($file, $git->run('show', [':' . trim($file)]), $ver);
87+
$endpoint = new Endpoint($file, $git->run('show', [':' . trim($file)]), $version);
8688

8789
$dir = $endpointDir . NamespaceEndpoint::normalizeName($endpoint->namespace);
8890
if (!file_exists($dir)) {
@@ -109,7 +111,7 @@
109111

110112
foreach ($namespaces as $name => $endpoints) {
111113
if (empty($name)) {
112-
$clientEndpoint = new ClientEndpoint(array_keys($namespaces), $ver);
114+
$clientEndpoint = new ClientEndpoint(array_keys($namespaces), $version);
113115
foreach ($endpoints as $ep) {
114116
$clientEndpoint->addEndpoint($ep);
115117
}
@@ -120,7 +122,7 @@
120122
$countNamespace++;
121123
continue;
122124
}
123-
$namespace = new NamespaceEndpoint($name, $ver);
125+
$namespace = new NamespaceEndpoint($name, $version);
124126
foreach ($endpoints as $ep) {
125127
$namespace->addEndpoint($ep);
126128
}
@@ -131,9 +133,24 @@
131133
$countNamespace++;
132134
}
133135

136+
# Clean
134137
$end = microtime(true);
135138
printf("\nGenerated %d endpoints and %d namespaces in %.3f seconds\n.", $countEndpoint, $countNamespace, $end - $start);
139+
printf ("---\n");
140+
141+
printf("Backup Endpoints and Namespaces in /src");
136142

143+
$file = Client::Version;
144+
145+
$zip = new ZipArchive();
146+
$ret = $zip->open('application.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
147+
if ($ret !== TRUE) {
148+
printf('Failed with code %d', $ret);
149+
} else {
150+
$options = array('add_path' => 'sources/', 'remove_all_path' => TRUE);
151+
$zip->addGlob('*.{php,txt}', GLOB_BRACE, $options);
152+
$zip->close();
153+
}
137154
// End
138155

139156
function print_usage_msg(): void
@@ -143,17 +160,41 @@ function print_usage_msg(): void
143160
}
144161

145162
// Remove directory recursively
146-
function removeDirectory($directory)
163+
function removeDirectory($directory, array $omit = [])
147164
{
148165
foreach(glob("{$directory}/*") as $file)
149166
{
150167
if(is_dir($file)) {
151-
removeDirectory($file);
168+
if (!in_array($file, $omit)) {
169+
//removeDirectory($file);
170+
printf("Elimino directory %s\n", $file);
171+
}
152172
} else {
153-
unlink($file);
173+
if (!in_array($file, $omit)) {
174+
//unlink($file);
175+
printf("Elimino file %s\n", $file);
176+
}
154177
}
155178
}
156-
if (is_dir($directory)) {
157-
rmdir($directory);
179+
if (is_dir($directory) && empty($omit)) {
180+
//rmdir($directory);
181+
printf("Elimino directory %s\n", $directory);
158182
}
159-
}
183+
}
184+
185+
# Copy files and directory recursively
186+
function copyAll(string $src, string $dst) {
187+
$dir = opendir($src);
188+
@mkdir($dst);
189+
while(false !== ( $file = readdir($dir)) ) {
190+
if (( $file != '.' ) && ( $file != '..' )) {
191+
if ( is_dir($src . '/' . $file) ) {
192+
copyAll($src . '/' . $file, $dst . '/' . $file);
193+
}
194+
else {
195+
copy($src . '/' . $file, $dst . '/' . $file);
196+
}
197+
}
198+
}
199+
closedir($dir);
200+
}

util/elasticsearch

0 commit comments

Comments
 (0)