Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[LDAP] Add ldap tests to github CI#39030

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
derrabus merged 2 commits intosymfony:4.4fromlucasaba:add-ldap-tests
Nov 16, 2020

Conversation

@lucasaba
Copy link
Contributor

QA
Branch?4.4
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#39028
LicenseMIT
Doc PR

Adds LDAP test on github actions pipeline and corrects sum bugs in the LDAP Component test

It also adds a bug resolution from@Nek- made in#38875

Nek- reacted with heart emojiNek- reacted with rocket emoji
@wouterj
Copy link
Member

Thank you for starting this PR! Adding LDAP integration tests to the already complex CI set-up of Symfony is a really brave task :)

Let's start with a big disclaimer: I've never used LDAP before, so my knowledge about it is very weak.

Can you maybe share why a custom docker image was used (instead of semi-official ones likebitnami/openldap)?
I think it would be good to explore how we can remove this "dependency" on a custom image, in order to reduce maintenance work (and depending on images maintained by a single author is a bit more "risky" than depending on an image maintained by a community or company).

derrabus reacted with thumbs up emoji

@jderussejderusse mentioned this pull requestNov 7, 2020
@lucasaba
Copy link
ContributorAuthor

Well, honestly I'm not into LDAP too. I've just used it for authentication. But I've made a PR which led to a bug that would have been avoided if I had been more accurate with tests. So... this is my way to ask forgiveness..

You're absolutely right: introducing a dependency on a custom image would absolutely be risky. I needed to do it because I needed to push some initial data to the LDAP server, namely, those inthe test env. And it is precisely what I do in my customDockerfile: I create a folder where I store the data and copy it there. Then, withthe env, I tell the image to load it.

I think, the best aproach would be to use the standard image and then, add a step in the action, that pushes the data to the server. In order to do that I should use some command line program likeldapadd. And thats where I'm stuck...

Another way would be to create a custom action, which would lead to tha same problem as having a custom docker image.

wouterj reacted with thumbs up emojiderrabus reacted with heart emoji

@derrabus
Copy link
Member

If we really need a custom image (which I'd like to avoid), we should move its maintenance this this repository or at least a repository within the Symfony organization.

@jderusse
Copy link
Member

If we really need a custom image (which I'd like to avoid), we should move its maintenance this this repository or at least a repository within the Symfony organization.

we even don't need a docker image. Github Action can run Dockerfile directly (https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/creating-a-docker-container-action)

@wouterj
Copy link
Member

wouterj commentedNov 7, 2020
edited
Loading

We can do this without a custom image I think. The following docker compose config (docker compose isn't needed here, it's just more readable than a docker run command imho) sets up the openldap image with our fixture data (as far as I can see):

version:'3.0'services:ldap:image:osixia/openldap:1.4.0ports:            -3389:389volumes:            -./src/Symfony/Component/Ldap/Tests/Fixtures/data/fixtures.ldif:/container/service/slapd/assets/config/bootstrap/ldif/50-bootstrap.ldifcommand:--copy-service --loglevel debugenvironment:LDAP_DOMAIN:symfony.comLDAP_BASE_DN:dc=symfony,dc=comLDAP_ADMIN_PASSWORD:'symfony'

Please note that I can't make the tests pass with this config, so something isn't quite right. But it at least is a start to get custom data in the openldap image without using a custom image.

@lucasaba
Copy link
ContributorAuthor

@wouterj I've tryed your suggestion. seemd promising! I've mounted a volume with the GHA:

openldap:image:osixia/openldap:1.4.0options:-v ${{ github.workspace }}/src/Symfony/Component/Ldap/Tests/Fixtures/data/fixtures.ldif:/ldif-dataports:        -3389:389env:LDAP_DOMAIN:"symfony.com"LDAP_ADMIN_PASSWORD:symfonyLDAP_BASE_DN:"dc=symfony,dc=com"LDAP_SEED_INTERNAL_LDIF_PATH:"/ldif-data"

But in theCheckout phase, GHAtryes to clean-up the workspace and, beeing the volume tied to the image, breaks the pipeline.

I'll try some alternatives and read the article pointed from@jderusse

@lucasaba
Copy link
ContributorAuthor

lucasaba commentedNov 8, 2020
edited
Loading

we even don't need a docker image. Github Action can run Dockerfile directly (https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/creating-a-docker-container-action)

At a first impression, that would move the problem. In the sense that, instead of maintaing a docker image, there should be a GHA to maintain.

@wouterj
Copy link
Member

Hmm, according toactions/checkout#211 (comment) the solution would be to run this command before the checkout action:

sudo chown -R $USER:$USER /home/runner/work/symfony/symfony/src/Symfony/Component/Ldap/Tests/Fixtures/data/fixtures.ldif

@lucasaba
Copy link
ContributorAuthor

we even don't need a docker image. Github Action can run Dockerfile directly (https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/creating-a-docker-container-action)

My bad@jderusse ! Indeed, we canuse a local action and not depenend on an external one.

@lucasabalucasaba changed the titleAdd ldap tests[LDAP] Add ldap tests to github CINov 10, 2020
@jderusse
Copy link
Member

I squashed your commits@lucasaba rebased, and puh a commit that fix the CI.
Please,pull --rebase before pushing another commit

PR is ready for review@derrabus@wouterj

@jderussejderusse marked this pull request as ready for reviewNovember 16, 2020 12:53
@chalasr
Copy link
Member

Rebase went wrong? It seems that an unrelated commit landed in this PR3510b67

derrabus reacted with thumbs up emoji

@lucasaba
Copy link
ContributorAuthor

lucasaba commentedNov 16, 2020
edited
Loading

Thanks@jderusse ! I didn't think about using actions in that way! Thank you very much!
The erros on Travis and appveyour seems unrelated.

@chalasr seems ok now. I had some error too. Maybe some cache on github....

@derrabus
Copy link
Member

@chalasr is right, that does not look right. The content of that commit looks okay, but message and author are from a different PR.

@jderusse
Copy link
Member

Rebase went wrong? It seems that an unrelated commit landed in this PR3510b67

Yeah, the commit was there in the original PR (lucasaba@9de6771) I can reword it or squash it if you want@derrabus

@derrabus
Copy link
Member

Right now, the commit message is misleading and I'm the author of that commit. I think, squashing it into the second commit and removing me as author would be good. 😃

jderusse reacted with thumbs up emoji

Adds ext-ldap on github-actions
Copy link
Member

@wouterjwouterj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don't really understand anything about what's happening here, but it seems to make the LDAP tests run successfully 👍

Should this also remove the - now unused -src/Symfony/Component/Ldap/Tests/Fixtures/conf/slapd.conf andsrc/Symfony/Component/Ldap/Tests/Fixtures/data/base.ldif files?

(unrelated, but I'm a bit scared by amount of integration tests that are skipped on our CI)

@jderusse
Copy link
Member

derstand anything about what's happening here, but it seems to make the LDAP

For the record. This PR update the CI to:

  • starts an openldap server as a service (like redis/memcache/...)
  • load fixtures
  • deletes the user created by the bitnami/openldap (I didn't found a way to start with basic root setup, BUT WITHOUT demo users generated by LDAP_USERS env variable)
  • remove LDAP calls from travis

Then it fixes tests:

  • restore states of database after successful/failed tests (otherwise, you can't run tests twice)
  • fix SSL bug in connection to LDAP
  • fix wrong exception expected

unrelated, but I'm a bit scared by amount of integration tests that are skipped on our CI

So do I.. Shall we run tests with option -vv to see the reason of skipped tests?

derrabus and wouterj reacted with thumbs up emoji

@derrabus
Copy link
Member

So do I.. Shall we run tests with option -vv to see the reason of skipped tests?

Yes, that would be good. Integration tests are often skipped if an external system is not available. If we have a CI run dedicated to integration tests, skipped tests are likely an accident.

@jderusse
Copy link
Member

So do I.. Shall we run tests with option -vv to see the reason of skipped tests?

Yes, that would be good. Integration tests are often skipped if an external system is not available. If we have a CI run dedicated to integration tests, skipped tests are likely an accident.

Done. We have ~200 skipped tests for the following reasons:

  • Testing expiration slows down the test suite
  • Not a pruneable cache pool.
  • Memcached cannot clear by prefix
  • REDIS_SENTINEL_HOSTS env var is not defined.
  • Memcached expects a TTL greater than 1 sec. Simulating a slow network is too hard

I'm checking for the REDIS_SENTINEL test.
Other skipped tests sounds legit to me.

derrabus reacted with thumbs up emoji

@derrabus
Copy link
Member

All right, none of them is related to LDAP, so this PR should be good.

@wouterj
Copy link
Member

wouterj commentedNov 16, 2020
edited
Loading

(fwiw, let's move the conversation of the skipped tests to another PR/issue, so we can merge this asap)

derrabus reacted with thumbs up emojiderrabus reacted with rocket emoji

@derrabus
Copy link
Member

Thanks@lucasaba.

@derrabusderrabus merged commit55707fb intosymfony:4.4Nov 16, 2020
@lucasaba
Copy link
ContributorAuthor

lucasaba commentedNov 16, 2020
edited
Loading

Thank you all guys. As usual, has been a pleasure and a privilege. Learned a lot!

jderusse and chalasr reacted with heart emoji

@derrabus
Copy link
Member

I'll merge this up to 5.1 now. Let's hope, the tests stay green. 😃

@derrabus
Copy link
Member

@derrabus
Copy link
Member

There was 1 error:1) Symfony\Component\Ldap\Tests\Adapter\ExtLdap\LdapManagerTest::testUpdateOperationsThrowsExceptionWhenAddedDuplicatedValueUndefined variable: con/home/runner/work/symfony/symfony/src/Symfony/Component/Ldap/Adapter/ExtLdap/EntryManager.php:155/home/runner/work/symfony/symfony/src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php:369

Anyone up for a quick fix before I move on to 5.2? 😁

@wouterj
Copy link
Member

thrownewUpdateOperationException(sprintf('Error executing UpdateOperation on "%s":',$dn).ldap_error($this->getConnectionResource()),ldap_errno($con));

$con should be$this->getConnectionResource(). Or we should do$con = $this->getConnectionResource(); (just like in other methods of this class)

@derrabus
Copy link
Member

That makes sense. I've extracted that variable on 4.4 already, in order to keep the diff small.#39094

derrabus added a commit that referenced this pull requestNov 16, 2020
This PR was merged into the 4.4 branch.Discussion----------[Ldap] Fix undefined variable $con| Q             | A| ------------- | ---| Branch?       | 4.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       |#39030 (comment)| License       | MIT| Doc PR        | N/AThis PR extracts the connection resource into a variable. This will fix an undefined variable error on 5.1.Commits-------15da316 [Ldap] Fix undefined variable $con.
@derrabus
Copy link
Member

The LDAP integration tests are now green on 5.1, 5.2 and 5.x. 🎉

lucasaba reacted with hooray emoji

@jderusse
Copy link
Member

thank you for your help@lucasaba .

It helped to detect issue in 5.1 if I understand well, and would have prevent bugs in previous PRs. 🎉

derrabus reacted with thumbs up emojilucasaba and derrabus reacted with heart emoji

@lucasaba
Copy link
ContributorAuthor

Ok, now I'm really flattered! You've made my day!!!!! ❤️

wouterj, jderusse, and chalasr reacted with heart emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@jderussejderussejderusse left review comments

@wouterjwouterjwouterj approved these changes

@derrabusderrabusderrabus approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

6 participants

@lucasaba@wouterj@derrabus@jderusse@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp