Skip to content
New issue

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

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

Already on GitHub? # to your account

[cypress] Database Unix Sockets for System Tests #44092

Merged
merged 6 commits into from
Oct 24, 2024

Conversation

muhme
Copy link
Contributor

@muhme muhme commented Sep 16, 2024

Summary of Changes

Currently, Unix sockets do not work in Cypress System Tests. This enhancement is aimed at enabling their functionality.

See backend | Global Configuration | Server Database:
screen

Check if db_host is a Unix socket by verifying the unix:/ prefix. All JavaScript drivers does not handle this prefix, it needs to be stripped. This approach maintains compatibility with the PHP drivers and allows to have Cypress.config.mjs working for installation step (PHP driver) and custom database commands (JavaScript driver).

This change has already been tested with the NPM module pg replacment from #44084.

Testing Instructions

One option for testing is using JBT >= 1.0.24, as described here. Doing installation with MariaDB and MySQLi driver, test one spec with database custom commands. Installation step is already executed == tested with scripts/created or scripts/database. Watching progress and errors with noVNC:

scripts/create 44 mariadbi socket
scripts/test 44 system novnc administrator/components/com_users/Users.cy.js 

Repeat for the other four database variants:

foreach variant in "mysqli" "mysql" "mariadb" "pgsql"; do
  scripts/database 44 $variant socket
  scripts/test 44 system novnc administrator/components/com_users/Users.cy.js 
done

Install Joomla Patch Tester and "Apply Patch" 44092 in backend

scripts/patchtester 

And repeat the tests:

foreach variant in "mariadbi"  "mysqli" "mysql" "mariadb" "pgsql"; do
  scripts/database 44 $variant socket
  scripts/test 44 system novnc administrator/components/com_users/Users.cy.js 
done

Final run overall System Tests suite for one database variant:

scripts/test 44 system

Actual result BEFORE applying this Pull Request

The administrator/components/com_users/Users.cy.js 4 of the 6 tests fail with e.g.
getaddrinfo ENOTFOUND unix:/jbt/run/mariadb-socket/mysqld.sock

Expected result AFTER applying this Pull Request

Installation step and System Tests with custom database commands work for all database variants.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@richard67
Copy link
Member

Drone reports JavaScript code style issues: https://ci.joomla.org/joomla/joomla-cms/78953/1/33

@muhme
Copy link
Contributor Author

muhme commented Sep 16, 2024

Thank you for notice 👍 and I am wondering that Drone is running on DRAFT PR

@richard67
Copy link
Member

Yes, no difference between draft and not draft for ci tests.

@muhme muhme changed the title [cypress] Sockets for system tests [cypress] Database Unix Sockets for System Tests Sep 17, 2024
@muhme muhme marked this pull request as ready for review September 17, 2024 08:33
@alikon
Copy link
Contributor

alikon commented Sep 28, 2024

I have tested this item ✅ successfully on ce35190


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/44092.

@laoneo
Copy link
Member

laoneo commented Oct 20, 2024

Can you rebase this one to 5.2?

Check if db_host is a Unix socket by verifying the "unix:/" prefix.
JavaScript drivers does not handle this prefix, it needs to be stripped.
This approach maintains compatibility with the PHP drivers and allows
to have Cypress.config.mjs working for installation step (PHP driver)
and custom database commands (JavaScript driver).
@muhme muhme changed the base branch from 4.4-dev to 5.2-dev October 22, 2024 15:26
@muhme
Copy link
Contributor Author

muhme commented Oct 22, 2024

Rebased to 5.2-dev and tested on macOS with mariadbi using Unix sockets in creating instance from PR branch:

scripts/create 52 socket https://github.com/muhme/joomla-cms:sockets-for-system-tests
scripts/test 52 system

Used as db_host is unix:/var/run/mariadb-socket/mysqld.sock. System Tests are passed succesfully. ✅

@laoneo
Copy link
Member

laoneo commented Oct 23, 2024

Can you fix the conflicts?

@muhme
Copy link
Contributor Author

muhme commented Oct 23, 2024

Fixed the merge conflicts and tested again, this time with PostgreSQL Unix sockets and using the new pg NPM module:

scripts/create 52 pgsql socket https://github.com/muhme/joomla-cms:sockets-for-system-tests
scripts/test 52 system

Verified pg is used in branch_52/tests/System/plugins/db.mjs and db_host is set asunix:/var/run/postgresql-socket. System Tests are passed succesfully. ✅

tests/System/plugins/db.mjs Outdated Show resolved Hide resolved
@laoneo laoneo merged commit 3b358b8 into joomla:5.2-dev Oct 24, 2024
3 checks passed
@laoneo
Copy link
Member

laoneo commented Oct 24, 2024

Thanks!

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants