Skip to content

Commit

Permalink
Prepare for 7.9.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
ezimuel committed Oct 6, 2020
1 parent d86e1f8 commit 38e821f
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .ci/test-matrix.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
STACK_VERSION:
- 7.x-SNAPSHOT

- 7.9.2
PHP_VERSION:
- 7.4-cli
- 7.3-cli
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## Release 7.9.1

- Fixed using object instead of array in onFailure transport event
[#1066](https://github.com/elastic/elasticsearch-php/pull/1066)
- Fixed reset custom header after endpoint call
[#1065](https://github.com/elastic/elasticsearch-php/pull/1065)
- Show generic error messages when server returns no response
[#1056](https://github.com/elastic/elasticsearch-php/pull/1056)

## Release 7.9.0

- Updated endpoints and namespaces for Elasticsearch 7.9
Expand Down
40 changes: 40 additions & 0 deletions util/ActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class ActionTest
const TEMPLATE_SET_VARIABLE = __DIR__ . '/template/test/set-variable';
const TEMPLATE_TRANSFORM_AND_SET = __DIR__ . '/template/test/transform-and-set';
const TEMPLATE_WARNINGS = __DIR__ . '/template/test/warnings';
const TEMPLATE_GT = __DIR__ . '/template/test/gt';
const TEMPLATE_GTE = __DIR__ . '/template/test/gte';
const TEMPLATE_LT = __DIR__ . '/template/test/lt';
const TEMPLATE_LTE = __DIR__ . '/template/test/lte';
const TAB14 = ' ';
const SUPPORTED_FEATURES = ['xpack', 'no_xpack', 'headers', 'node_selector', 'warnings', 'catch_unauthorized', 'transform_and_set'];

Expand Down Expand Up @@ -324,6 +328,42 @@ private function teardown(array $actions)
return $this->do($actions);
}

private function gt(array $actions)
{
$key = key($actions);
return YamlTests::render(self::TEMPLATE_GT, [
':expected' => $actions[$key],
':value' => $this->convertResponseField($key)
]);
}

private function gte(array $actions)
{
$key = key($actions);
return YamlTests::render(self::TEMPLATE_GTE, [
':expected' => $actions[$key],
':value' => $this->convertResponseField($key)
]);
}

private function lt(array $actions)
{
$key = key($actions);
return YamlTests::render(self::TEMPLATE_LT, [
':expected' => $actions[$key],
':value' => $this->convertResponseField($key)
]);
}

private function lte(array $actions)
{
$key = key($actions);
return YamlTests::render(self::TEMPLATE_LTE, [
':expected' => $actions[$key],
':value' => $this->convertResponseField($key)
]);
}

/**
* ---------- FEATURE FUNCTIONS (END) ----------
*/
Expand Down
109 changes: 75 additions & 34 deletions util/GenerateEndpoints.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,42 @@
use Elasticsearch\Util\ClientEndpoint;
use Elasticsearch\Util\Endpoint;
use Elasticsearch\Util\NamespaceEndpoint;
use Elasticsearch\Tests\Utility;

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



removeDirectory(__DIR__ . '/../src/Elasticsearch/Endpoints', [
__DIR__ . '/../src/Elasticsearch/Endpoints/AbstractEndpoint.php',
]);
removeDirectory(__DIR__ . '/../src/Elasticsearch/Namespaces', [
__DIR__ . '/../src/Elasticsearch/Namespaces/AbstractNamespace.php',
__DIR__ . '/../src/Elasticsearch/Namespaces/BooleanRequestWrapper.php',
__DIR__ . '/../src/Elasticsearch/Namespaces/NamespaceBuilderInterface.php'
]);

die();
printf ("Generating endpoints for Elasticsearch\n");
printf ("---\n");

$start = microtime(true);
if (!isset($argv[1])) {
print_usage_msg();
exit(1);
}
if ($argv[1] < '7.3.0') {
printf("Error: the version must be >= 7.4.0\n");

$client = Utility::getClient();

$serverInfo = $client->info();
$version = $serverInfo['version']['number'];
$buildHash = $serverInfo['version']['build_hash'];

if (version_compare($version, '7.4.0', '<')) {
printf("Error: the ES version must be >= 7.4.0\n");
exit(1);
}

$ver = $argv[1];
$version = 'v' . $ver;

$gitWrapper = new GitWrapper();
$git = $gitWrapper->workingCopy(dirname(__DIR__) . '/util/elasticsearch');

$git->run('fetch', ['--all']);
$tags = explode("\n", $git->run('tag'));
if (!in_array($version, $tags)) {
$branches = explode("\n", $git->run('branch', ['-r']));
array_walk($branches, function(&$value, &$key) {
$value = trim($value);
});
$version = "origin/$ver";
if (!in_array($version, $branches)) {
printf("Error: the version %s specified doesnot exist\n", $version);
exit(1);
}
}

$git->run('checkout', [$version]);
$git->run('checkout', [$buildHash]);
$result = $git->run(
'ls-files',
[
Expand All @@ -61,7 +63,7 @@
]
);
$files = explode("\n", $result);
$outputDir = __DIR__ . "/output/$ver";
$outputDir = __DIR__ . "/output/$version";

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

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

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

foreach ($namespaces as $name => $endpoints) {
if (empty($name)) {
$clientEndpoint = new ClientEndpoint(array_keys($namespaces), $ver);
$clientEndpoint = new ClientEndpoint(array_keys($namespaces), $version);
foreach ($endpoints as $ep) {
$clientEndpoint->addEndpoint($ep);
}
Expand All @@ -120,7 +122,7 @@
$countNamespace++;
continue;
}
$namespace = new NamespaceEndpoint($name, $ver);
$namespace = new NamespaceEndpoint($name, $version);
foreach ($endpoints as $ep) {
$namespace->addEndpoint($ep);
}
Expand All @@ -131,9 +133,24 @@
$countNamespace++;
}

# Clean
$end = microtime(true);
printf("\nGenerated %d endpoints and %d namespaces in %.3f seconds\n.", $countEndpoint, $countNamespace, $end - $start);
printf ("---\n");

printf("Backup Endpoints and Namespaces in /src");

$file = Client::Version;

$zip = new ZipArchive();
$ret = $zip->open('application.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
if ($ret !== TRUE) {
printf('Failed with code %d', $ret);
} else {
$options = array('add_path' => 'sources/', 'remove_all_path' => TRUE);
$zip->addGlob('*.{php,txt}', GLOB_BRACE, $options);
$zip->close();
}
// End

function print_usage_msg(): void
Expand All @@ -143,17 +160,41 @@ function print_usage_msg(): void
}

// Remove directory recursively
function removeDirectory($directory)
function removeDirectory($directory, array $omit = [])
{
foreach(glob("{$directory}/*") as $file)
{
if(is_dir($file)) {
removeDirectory($file);
if (!in_array($file, $omit)) {
//removeDirectory($file);
printf("Elimino directory %s\n", $file);
}
} else {
unlink($file);
if (!in_array($file, $omit)) {
//unlink($file);
printf("Elimino file %s\n", $file);
}
}
}
if (is_dir($directory)) {
rmdir($directory);
if (is_dir($directory) && empty($omit)) {
//rmdir($directory);
printf("Elimino directory %s\n", $directory);
}
}
}

# Copy files and directory recursively
function copyAll(string $src, string $dst) {
$dir = opendir($src);
@mkdir($dst);
while(false !== ( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' )) {
if ( is_dir($src . '/' . $file) ) {
copyAll($src . '/' . $file, $dst . '/' . $file);
}
else {
copy($src . '/' . $file, $dst . '/' . $file);
}
}
}
closedir($dir);
}
2 changes: 1 addition & 1 deletion util/elasticsearch

0 comments on commit 38e821f

Please sign in to comment.