Skip to content

Commit 5bdda20

Browse files
authored
Merge pull request #62 from aligent/feature/adapter-clean-up
🚧 Fix adapter proxy and update CI
2 parents dadffed + 5422ab6 commit 5bdda20

File tree

5 files changed

+100
-52
lines changed

5 files changed

+100
-52
lines changed

.github/workflows/api-functional-tests.yml

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,21 @@ on:
77

88
jobs:
99
api-functional-test:
10-
runs-on: "ubuntu-latest"
10+
runs-on: "ubuntu-latest"
1111

1212
# Only run api tests on feature branches. Simple documentation updates, formatting can be ignored
1313
if: contains(github.head_ref, 'feature')
14+
name: ${{ matrix.job_title }}
1415
strategy:
1516
fail-fast: true
1617
matrix:
17-
magento: ["magento/project-community-edition:>=2.4.4 <2.4.5", "magento/project-community-edition:>=2.4.5 <2.4.6", "magento/project-community-edition:>=2.4.6 <2.4.7"]
18+
magento:
19+
[
20+
"magento/project-community-edition:>=2.4.4 <2.4.5",
21+
"magento/project-community-edition:>=2.4.5 <2.4.6",
22+
"magento/project-community-edition:>=2.4.6 <2.4.7",
23+
"magento/project-community-edition:>=2.4.7 <2.4.8",
24+
]
1825
include:
1926
- magento: magento/project-community-edition:>=2.4.4 <2.4.5
2027
php: 8.1
@@ -23,26 +30,34 @@ jobs:
2330
elasticsearch: "elasticsearch:7.16.3"
2431
rabbitmq: "rabbitmq:3.9-management"
2532
redis: "redis:6.2"
26-
varnish: "varnish:7.0"
27-
nginx: "nginx:1.18"
33+
job_title: "2.4.4"
34+
2835
- magento: magento/project-community-edition:>=2.4.5 <2.4.6
2936
php: 8.1
3037
composer: 2
3138
mysql: "mysql:8.0"
3239
elasticsearch: "elasticsearch:7.16.3"
3340
rabbitmq: "rabbitmq:3.9-management"
3441
redis: "redis:6.2"
35-
varnish: "varnish:7.0"
36-
nginx: "nginx:1.18"
42+
job_title: "2.4.5"
43+
3744
- magento: magento/project-community-edition:>=2.4.6 <2.4.7
38-
php: 8.1
39-
composer: 2
45+
php: 8.2
46+
composer: 2.2
4047
mysql: "mysql:8.0"
4148
elasticsearch: "elasticsearch:7.17.9"
42-
rabbitmq: "rabbitmq:3.9-management"
49+
rabbitmq: "rabbitmq:3.12-management"
4350
redis: "redis:7.0"
44-
varnish: "varnish:7.1"
45-
nginx: "nginx:1.18"
51+
job_title: "2.4.6"
52+
53+
- magento: magento/project-community-edition:>=2.4.7 <2.4.8
54+
php: 8.3
55+
composer: 2.7
56+
mysql: "mariadb:10.6"
57+
elasticsearch: "elasticsearch:7.17.9"
58+
rabbitmq: "rabbitmq:3.12-management"
59+
redis: "redis:7.2"
60+
job_title: "2.4.7"
4661

4762
services:
4863
elasticsearch:
@@ -58,7 +73,7 @@ jobs:
5873
- 9200:9200
5974

6075
mysql:
61-
image: ${{ matrix.mysql }}
76+
image: ${{ matrix.mysql }}
6277
env:
6378
MYSQL_DATABASE: magento_functional_tests
6479
MYSQL_USER: user
@@ -77,7 +92,7 @@ jobs:
7792
- 5672:5672
7893
- 15672:15672
7994
steps:
80-
- uses: actions/checkout@v3
95+
- uses: actions/checkout@v4
8196
- name: Set PHP Version
8297
uses: shivammathur/setup-php@v2
8398
with:
@@ -94,43 +109,43 @@ jobs:
94109
- uses: graycoreio/github-actions-magento2/get-magento-version@main
95110
id: magento-version
96111
with:
97-
working-directory: "../magento2"
112+
working-directory: "../magento2"
98113

99114
- name: Get Composer Cache Directory
100115
shell: bash
101-
working-directory: "../magento2"
116+
working-directory: "../magento2"
102117
id: composer-cache
103118
run: |
104119
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
105120
106121
- name: "Cache Composer Packages"
107-
uses: actions/cache@v3
122+
uses: actions/cache@v4
108123
with:
109124
key: "composer | v5 | '' | ${{ hashFiles('composer.lock') }}"
110125
path: ${{ steps.composer-cache.outputs.dir }}
111126

112127
- run: composer config repositories.local path $GITHUB_WORKSPACE
113128
name: Add Github Repo for Testing
114-
working-directory: "../magento2"
129+
working-directory: "../magento2"
115130
shell: bash
116131

117132
- run: |
118133
composer config --no-interaction allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
119134
composer config --no-interaction allow-plugins.laminas/laminas-dependency-plugin true
120135
composer config --no-interaction allow-plugins.magento/* true
121136
name: Fixup Composer Plugins
122-
working-directory: "../magento2"
137+
working-directory: "../magento2"
123138
124139
- run: composer require aligent/async-events "@dev" --no-update && composer install
125140
name: Require and attempt install
126-
working-directory: "../magento2"
141+
working-directory: "../magento2"
127142
shell: bash
128143
env:
129144
COMPOSER_CACHE_DIR: ${{ steps.composer-cache.outputs.dir }}
130145
COMPOSER_AUTH: ${{ secrets.composer_auth }}
131146

132147
- name: Replace Configuration Settings for env
133-
working-directory: ../magento2/dev/tests/api-functional
148+
working-directory: ../magento2/dev/tests/api-functional
134149
run: |
135150
cp phpunit_rest.xml.dist phpunit_rest.xml
136151
cp config/install-config-mysql.php.dist config/install-config-mysql.php
@@ -148,5 +163,5 @@ jobs:
148163
php -S 127.0.0.1:8082 -t ./pub/ ./phpserver/router.php &
149164
sleep 5
150165
vendor/bin/phpunit -c $(pwd)/dev/tests/api-functional/phpunit_rest.xml vendor/aligent/async-events/Test/Api
151-
working-directory: ../magento2
166+
working-directory: ../magento2
152167
name: Run API Functional Tests

.github/workflows/integration-tests.yml

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,21 @@ on:
77

88
jobs:
99
integration-test:
10-
runs-on: "ubuntu-latest"
10+
runs-on: "ubuntu-latest"
1111

1212
# Only run integration tests on feature branches. Simple documentation updates, formatting can be ignored
1313
if: contains(github.head_ref, 'feature')
14+
name: ${{ matrix.job_title }}
1415
strategy:
1516
fail-fast: true
1617
matrix:
17-
magento: ["magento/project-community-edition:>=2.4.4 <2.4.5", "magento/project-community-edition:>=2.4.5 <2.4.6", "magento/project-community-edition:>=2.4.6 <2.4.7"]
18+
magento:
19+
[
20+
"magento/project-community-edition:>=2.4.4 <2.4.5",
21+
"magento/project-community-edition:>=2.4.5 <2.4.6",
22+
"magento/project-community-edition:>=2.4.6 <2.4.7",
23+
"magento/project-community-edition:>=2.4.7 <2.4.8",
24+
]
1825
include:
1926
- magento: magento/project-community-edition:>=2.4.4 <2.4.5
2027
php: 8.1
@@ -23,26 +30,34 @@ jobs:
2330
elasticsearch: "elasticsearch:7.16.3"
2431
rabbitmq: "rabbitmq:3.9-management"
2532
redis: "redis:6.2"
26-
varnish: "varnish:7.0"
27-
nginx: "nginx:1.18"
33+
job_title: "2.4.4"
34+
2835
- magento: magento/project-community-edition:>=2.4.5 <2.4.6
2936
php: 8.1
3037
composer: 2
3138
mysql: "mysql:8.0"
3239
elasticsearch: "elasticsearch:7.16.3"
3340
rabbitmq: "rabbitmq:3.9-management"
3441
redis: "redis:6.2"
35-
varnish: "varnish:7.0"
36-
nginx: "nginx:1.18"
42+
job_title: "2.4.5"
43+
3744
- magento: magento/project-community-edition:>=2.4.6 <2.4.7
38-
php: 8.1
39-
composer: 2
45+
php: 8.2
46+
composer: 2.2
4047
mysql: "mysql:8.0"
4148
elasticsearch: "elasticsearch:7.17.9"
42-
rabbitmq: "rabbitmq:3.9-management"
49+
rabbitmq: "rabbitmq:3.12-management"
4350
redis: "redis:7.0"
44-
varnish: "varnish:7.1"
45-
nginx: "nginx:1.18"
51+
job_title: "2.4.6"
52+
53+
- magento: magento/project-community-edition:>=2.4.7 <2.4.8
54+
php: 8.3
55+
composer: 2.7
56+
mysql: "mariadb:10.6"
57+
elasticsearch: "elasticsearch:7.17.9"
58+
rabbitmq: "rabbitmq:3.12-management"
59+
redis: "redis:7.2"
60+
job_title: "2.4.7"
4661

4762
services:
4863
elasticsearch:
@@ -58,7 +73,7 @@ jobs:
5873
- 9200:9200
5974

6075
mysql:
61-
image: ${{ matrix.mysql }}
76+
image: ${{ matrix.mysql }}
6277
env:
6378
MYSQL_DATABASE: magento_integration_tests
6479
MYSQL_USER: user
@@ -77,7 +92,7 @@ jobs:
7792
- 5672:5672
7893
- 15672:15672
7994
steps:
80-
- uses: actions/checkout@v3
95+
- uses: actions/checkout@v4
8196
- name: Set PHP Version
8297
uses: shivammathur/setup-php@v2
8398
with:
@@ -94,50 +109,53 @@ jobs:
94109
- uses: graycoreio/github-actions-magento2/get-magento-version@main
95110
id: magento-version
96111
with:
97-
working-directory: "../magento2"
112+
working-directory: "../magento2"
98113

99114
- name: Get Composer Cache Directory
100115
shell: bash
101-
working-directory: "../magento2"
116+
working-directory: "../magento2"
102117
id: composer-cache
103118
run: |
104119
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
105120
106121
- name: "Cache Composer Packages"
107-
uses: actions/cache@v3
122+
uses: actions/cache@v4
108123
with:
109124
key: "composer | v5 | '' | ${{ hashFiles('composer.lock') }}"
110125
path: ${{ steps.composer-cache.outputs.dir }}
111126

112127
- run: composer config repositories.local path $GITHUB_WORKSPACE
113128
name: Add Github Repo for Testing
114-
working-directory: "../magento2"
129+
working-directory: "../magento2"
115130
shell: bash
116131

117132
- run: |
118133
composer config --no-interaction allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
119134
composer config --no-interaction allow-plugins.laminas/laminas-dependency-plugin true
120135
composer config --no-interaction allow-plugins.magento/* true
121136
name: Fixup Composer Plugins
122-
working-directory: "../magento2"
137+
working-directory: "../magento2"
123138
124139
- run: composer require aligent/async-events "@dev" --no-update && composer install
125140
name: Require and attempt install
126-
working-directory: "../magento2"
141+
working-directory: "../magento2"
127142
shell: bash
128143
env:
129144
COMPOSER_CACHE_DIR: ${{ steps.composer-cache.outputs.dir }}
130145
COMPOSER_AUTH: ${{ secrets.composer_auth }}
131146

132147
- name: Replace Configuration Settings for env
133-
working-directory: ../magento2/dev/tests/integration
148+
working-directory: ../magento2/dev/tests/integration
134149
run: |
135150
sed -i "s/'db-host' => 'localhost'/'db-host' => '127.0.0.1'/" etc/install-config-mysql.php.dist
136151
sed -i "s/'db-user' => 'root'/'db-user' => 'user'/" etc/install-config-mysql.php.dist
137152
sed -i "s/'db-password' => '123123q'/'db-password' => 'password'/" etc/install-config-mysql.php.dist
138153
sed -i "s/'elasticsearch-host' => 'localhost'/'elasticsearch-host' => '127.0.0.1'/" etc/install-config-mysql.php.dist
139154
sed -i "s/'amqp-host' => 'localhost'/'amqp-host' => '127.0.0.1'/" etc/install-config-mysql.php.dist
155+
sed -i "s/'consumers-wait-for-messages' => '0'/'consumers-wait-for-messages' => '1'/" etc/install-config-mysql.php.dist
156+
mkdir etc/di/preferences/cli
157+
cp ../../../vendor/aligent/async-events/Test/_files/ce.php ./etc/di/preferences/cli
140158
141159
- run: ../../../vendor/bin/phpunit ../../../vendor/aligent/async-events/Test/Integration
142-
working-directory: ../magento2/dev/tests/integration
160+
working-directory: ../magento2/dev/tests/integration
143161
name: Run Integration Tests

Test/Integration/EventRetryTest.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ class EventRetryTest extends TestCase
2222
/** @var PublisherInterface|null */
2323
private ?PublisherInterface $publisher;
2424

25-
/** @var PublisherConsumerController|null */
26-
private ?PublisherConsumerController $publisherConsumerController;
27-
2825
/** @var Json|null */
2926
private ?Json $json;
3027

28+
/** @var ResourceConnection|null */
29+
private ?ResourceConnection $connection;
30+
3131
protected function setUp(): void
3232
{
3333
Bootstrap::getObjectManager()->configure([
@@ -54,7 +54,6 @@ protected function setUp(): void
5454
*
5555
* @magentoDataFixture Aligent_AsyncEvents::Test/_files/http_async_events.php
5656
* @magentoDbIsolation disabled
57-
* @magentoConfigFixture default/system/async_events/max_deaths 3
5857
*/
5958
public function testRetry()
6059
{
@@ -68,18 +67,23 @@ public function testRetry()
6867
]
6968
);
7069

71-
$this->publisherConsumerController = Bootstrap::getObjectManager()->create(
70+
$consumerInitParams = Bootstrap::getInstance()->getAppInitParams();
71+
72+
$consumerInitParams['TESTS_BASE_DIR'] = INTEGRATION_TESTS_DIR;
73+
$consumerInitParams['INTEGRATION_TESTS_CLI_AUTOLOADER'] = INTEGRATION_TESTS_DIR . '/framework/autoload.php';
74+
75+
$publisherConsumerController = Bootstrap::getObjectManager()->create(
7276
PublisherConsumerController::class,
7377
[
7478
'consumers' => ['event.trigger.consumer', 'event.retry.consumer'],
7579
'logFilePath' => TESTS_TEMP_DIR . "/MessageQueueTestLog.txt",
7680
'maxMessages' => 10,
77-
'appInitParams' => Bootstrap::getInstance()->getAppInitParams()
81+
'appInitParams' => $consumerInitParams
7882
]
7983
);
8084

8185
try {
82-
$this->publisherConsumerController->startConsumers();
86+
$publisherConsumerController->startConsumers();
8387
sleep(16);
8488
} catch (EnvironmentPreconditionException $e) {
8589
$this->markTestSkipped($e->getMessage());
@@ -88,7 +92,7 @@ public function testRetry()
8892
$e->getMessage()
8993
);
9094
} finally {
91-
$this->publisherConsumerController->stopConsumers();
95+
$publisherConsumerController->stopConsumers();
9296
}
9397

9498
$table = $this->connection->getTableName('async_event_subscriber_log');
@@ -100,8 +104,10 @@ public function testRetry()
100104

101105
$events = $connection->fetchAll($select);
102106

107+
$this->assertNotEmpty($events);
108+
103109
foreach ($events as $event) {
104-
// An uuid batch should be retired for 3 times after the first attempt. 1 + 3
110+
// A batch should be retired for 3 times after the first attempt. 1 + 3
105111
$this->assertEquals(4, $event['events']);
106112
}
107113
}

Test/_files/ce.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
/**
4+
* Swap out Config for TestConfig during queue consumer run so `example.event` is available in Integration tests.
5+
*/
6+
7+
return [
8+
\Aligent\AsyncEvents\Model\Config::class => \Aligent\AsyncEvents\Test\Integration\TestConfig::class
9+
];

etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101

102102
<type name="\Aligent\AsyncEvents\Model\Indexer\IndexStructure">
103103
<arguments>
104-
<argument name="adapter" xsi:type="object">\Magento\Elasticsearch\Model\Adapter\Elasticsearch\Proxy</argument>
104+
<argument name="adapter" xsi:type="object">dataMapperAdapter</argument>
105105
<argument name="scopeResolver" xsi:type="object" shared="false">\Aligent\AsyncEvents\Model\Resolver\AsyncEvent</argument>
106106
</arguments>
107107
</type>

0 commit comments

Comments
 (0)