Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(elasticsearch): re-introduce v7 support #6827

Draft
wants to merge 5 commits into
base: 4.1
Choose a base branch
from

Conversation

darthf1
Copy link
Contributor

@darthf1 darthf1 commented Nov 26, 2024

Q A
Branch? main
Tickets closes #6788
License MIT
Doc PR api-platform/docs#...

This PR re-introduces ES7 support, by simply introducing the v7 client namespaces.

@darthf1 darthf1 marked this pull request as draft November 26, 2024 08:41
@darthf1 darthf1 changed the title feat(elasticsearch): introduce v7 support feat(elasticsearch): re-introduce v7 support Nov 26, 2024
@darthf1 darthf1 force-pushed the feat/add-es-7-support branch from 79eb593 to 35160cf Compare December 22, 2024 07:43
@darthf1
Copy link
Contributor Author

darthf1 commented Dec 22, 2024

@soyuka i tried to add back ES v7 support, with as less changes as possible. I commented above the code whether it involves ES v7 or v8 and up, which should make maintenance a bit easier, also when ES 7 has been declared EOL. There were still some ES7 checks in the code, so i just added comments above them.

As for the phpstan errors; can I add them to the baseline? I get more errors locally than in CI, so I'm not sure if everything is setup correctly. In the phpstan.neon.dist keys like containerXmlPath and constantHassers are used, but those are phpstan v2 keys.

Behat tests fail, they give the following error:

In Validator.php line 61:
                                                                                                                                        
  Can not find a matching value for an argument `$client` of the method `ApiPlatform\Tests\Behat\ElasticsearchContext::__construct()`.  

I'm not a Behat user; do you maybe have some thoughts how to resolve this? I added a new behat job for ES v7, it looks like these are successful.

@darthf1 darthf1 marked this pull request as ready for review December 22, 2024 08:01
@darthf1
Copy link
Contributor Author

darthf1 commented Jan 13, 2025

@soyuka any thoughts on this PR? :)

@soyuka
Copy link
Member

soyuka commented Jan 13, 2025

Not many changes except namespaces, why not, could you target 4.1 and make the CI green?

@darthf1 darthf1 marked this pull request as draft January 14, 2025 13:47
@darthf1 darthf1 force-pushed the feat/add-es-7-support branch from 78184a0 to e0ccf50 Compare January 14, 2025 13:55
@darthf1 darthf1 changed the base branch from main to 4.1 January 14, 2025 13:59
@darthf1
Copy link
Contributor Author

darthf1 commented Jan 14, 2025

@soyuka Great! Ive rebased on 4.1

As for the phpstan errors; can I add them to the baseline? What would be the quickest way to do that? I get more errors locally than in CI, so I'm not sure if everything is setup correctly. In the phpstan.neon.dist keys like containerXmlPath and constantHassers are used, but those are phpstan v2 keys.

Behat tests fail, they give the following error:

In Validator.php line 61:
                                                                                                                                        
  Can not find a matching value for an argument `$client` of the method `ApiPlatform\Tests\Behat\ElasticsearchContext::__construct()`.  

I'm not a Behat user; do you maybe have some thoughts how to resolve this? I added a new behat job for ES v7, it looks like these are successful.

@soyuka
Copy link
Member

soyuka commented Jan 14, 2025

The 500 inside Behat is weird, I'll handle phpstan no problem.

@soyuka
Copy link
Member

soyuka commented Jan 17, 2025

can you check the 500? Run the tests using behat --stop-on-failure it should be an easy fix, thanks! You can always print a response using Then print last JSON response

@darthf1
Copy link
Contributor Author

darthf1 commented Jan 17, 2025

Tests fail before they've even begun:

vendor/bin/behat --out=std --format=progress --profile=elasticsearch --no-interaction
In Validator.php line 61:
                                                                                                                                        
  Can not find a matching value for an argument `$client` of the method `ApiPlatform\Tests\Behat\ElasticsearchContext::__construct()`.  
                                                                                                                                        

behat [-s|--suite SUITE] [-f|--format FORMAT] [-o|--out OUT] [--format-settings FORMAT-SETTINGS] [--init] [--lang LANG] [--name NAME] [--tags TAGS] [--role ROLE] [--story-syntax] [-d|--definitions DEFINITIONS] [--snippets-for [SNIPPETS-FOR]] [--snippets-type SNIPPETS-TYPE] [--append-snippets] [--no-snippets] [--strict] [--order ORDER] [--rerun] [--stop-on-failure] [--dry-run] [--] [<paths>]

Edit:

I was hoping something like this would do the trick:

diff --git a/behat.yml.dist b/behat.yml.dist
index 371bdd03f..efa2ead67 100644
--- a/behat.yml.dist
+++ b/behat.yml.dist
@@ -104,12 +104,16 @@ elasticsearch:
         - '%paths.base%/features/elasticsearch'
       contexts:
         - 'ApiPlatform\Tests\Behat\CommandContext'
-        - 'ApiPlatform\Tests\Behat\ElasticsearchContext'
+        - 'ApiPlatform\Tests\Behat\ElasticsearchContext':
+            client: '@elasticsearch_client'
         - 'ApiPlatform\Tests\Behat\JsonContext'
         - 'Behat\MinkExtension\Context\MinkContext'
         - 'behatch:context:rest'
       filters:
         tags: '@elasticsearch&&~@mercure&&~@query_parameter_validator'
+  extensions:
+    'FriendsOfBehat\SymfonyExtension': ~
 
 default-coverage:
   suites:

But then:

In Validator.php line 61:
                                                                                                                                                           
  Can not find a matching value for an argument `$elasticsearchMappingsPath` of the method `ApiPlatform\Tests\Behat\ElasticsearchContext::__construct()`.  

I'm quite lost here

@darthf1
Copy link
Contributor Author

darthf1 commented Jan 28, 2025

@soyuka what can I do to move this forward? :) do you know how to resolve the Behat issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Elasticsearch namespace reference error
2 participants