Skip to content

Commit 76bac53

Browse files
authored
[FT] Add new Schema Registry compatibility modes (#23)
* [CI] Simplifying `Makefile` * [CI] Enable PHP 7.3 docker build and use xdebug 2.7.0 * [CI] Upgrade `.php_cs.dist` file to support new cs-fixer versions * [FT] Add new SR compatibility modes * [CI] Use `-l 7` for low compat reasons * [FX] Add return types to `ExceptionMapTest`
1 parent 2b96e25 commit 76bac53

File tree

8 files changed

+132
-62
lines changed

8 files changed

+132
-62
lines changed

.php_cs.dist

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ return PhpCsFixer\Config::create()
1010
->setRules(
1111
[
1212
'no_unused_imports' => true,
13-
'ordered_imports' => true,
13+
'ordered_imports' => [
14+
'sort_algorithm' => 'alpha',
15+
'imports_order' => ['class', 'const', 'function'],
16+
],
1417
'phpdoc_summary' => false,
1518
'phpdoc_to_comment' => false,
1619
'concat_space' => ['spacing' => 'one'],

.travis.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ services:
88
php:
99
- '7.1'
1010
- '7.2'
11+
- '7.3'
1112

1213
env:
1314
global:
@@ -32,13 +33,13 @@ script:
3233
jobs:
3334
include:
3435
- stage: coverage
35-
php: 7.2
36+
php: '7.2'
3637
env:
3738
- DEPENDENCIES="stable"
3839
script:
3940
- PHP=php make coverage
4041
- stage: integration
41-
php: 7.2
42+
php: '7.2'
4243
env:
4344
- DEPENDENCIES="stable"
4445
- INTEGRATION_TEST="enabled"
@@ -47,7 +48,7 @@ jobs:
4748
- make platform
4849
- PHP=php make phpunit-integration
4950
- stage: integration
50-
php: 7.2
51+
php: '7.2'
5152
env:
5253
- DEPENDENCIES="stable"
5354
- INTEGRATION_TEST="enabled"
@@ -56,7 +57,7 @@ jobs:
5657
- make platform
5758
- PHP=php make phpunit-integration
5859
- stage: integration
59-
php: 7.2
60+
php: '7.2'
6061
env:
6162
- DEPENDENCIES="stable"
6263
- INTEGRATION_TEST="enabled"
@@ -65,7 +66,7 @@ jobs:
6566
- make platform
6667
- PHP=php make phpunit-integration
6768
- stage: integration
68-
php: 7.2
69+
php: '7.2'
6970
env:
7071
- DEPENDENCIES="stable"
7172
- INTEGRATION_TEST="enabled"
@@ -74,7 +75,7 @@ jobs:
7475
- make platform
7576
- PHP=php make phpunit-integration
7677
- stage: integration
77-
php: 7.2
78+
php: '7.2'
7879
env:
7980
- DEPENDENCIES="stable"
8081
- INTEGRATION_TEST="enabled"
@@ -83,7 +84,7 @@ jobs:
8384
- make platform
8485
- PHP=php make phpunit-integration
8586
- stage: integration
86-
php: 7.2
87+
php: '7.2'
8788
env:
8889
- DEPENDENCIES="stable"
8990
- INTEGRATION_TEST="enabled"

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ ARG PHP_VERSION=7.1
22

33
FROM php:${PHP_VERSION}-cli-alpine
44

5-
ARG XDEBUG_VERSION=2.6.1
5+
ARG XDEBUG_VERSION=2.7.0RC1
66

7-
RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS zlib-dev \
8-
&& apk add --no-cache --virtual .runtime-deps git \
7+
RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS \
8+
&& apk add --no-cache --virtual .runtime-deps git libzip-dev \
99
&& docker-php-ext-install zip \
1010
&& pecl install xdebug-$XDEBUG_VERSION \
1111
&& docker-php-ext-enable xdebug \

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# no buildin rules and variables
22
MAKEFLAGS =+ -rR --warn-undefined-variables
33

4-
.PHONY: composer-install composer-update phpstan cs-fixer examples docker run
4+
.PHONY: composer-install composer-update phpstan cs-fixer cs-fixer-modify examples coverage docker run ci-local platform
55

66
CONFLUENT_VERSION ?= latest
77
CONFLUENT_NETWORK_SUBNET ?= 172.68.0.0/24
88
SCHEMA_REGISTRY_IPV4 ?= 172.68.0.103
99
KAFKA_BROKER_IPV4 ?= 172.68.0.102
1010
ZOOKEEPER_IPV4 ?= 172.68.0.101
1111
COMPOSER ?= bin/composer.phar
12-
COMPOSER_VERSION ?= 1.7.2
12+
COMPOSER_VERSION ?= 1.8.3
1313
PHP ?= bin/php
1414
PHP_VERSION ?= 7.2
15-
XDEBUG_VERSION ?= 2.6.1
15+
XDEBUG_VERSION ?= 2.7.0RC1
1616

1717
export
1818

@@ -72,7 +72,7 @@ install-phars:
7272
platform:
7373
docker-compose down
7474
docker-compose up -d
75-
sleep 20
75+
sleep 25
7676

7777
clean:
7878
rm -rf build

src/Constants/Constants.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
const COMPATIBILITY_NONE = 'NONE';
66
const COMPATIBILITY_BACKWARD = 'BACKWARD';
7+
const COMPATIBILITY_BACKWARD_TRANSITIVE = 'BACKWARD_TRANSITIVE';
78
const COMPATIBILITY_FORWARD = 'FORWARD';
9+
const COMPATIBILITY_FORWARD_TRANSITIVE = 'FORWARD_TRANSITIVE';
810
const COMPATIBILITY_FULL = 'FULL';
11+
const COMPATIBILITY_FULL_TRANSITIVE = 'FULL_TRANSITIVE';
912

1013
const VERSION_LATEST = 'latest';

src/Requests/Functions.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
use GuzzleHttp\UriTemplate;
88
use Psr\Http\Message\RequestInterface;
99
use const FlixTech\SchemaRegistryApi\Constants\COMPATIBILITY_BACKWARD;
10+
use const FlixTech\SchemaRegistryApi\Constants\COMPATIBILITY_BACKWARD_TRANSITIVE;
1011
use const FlixTech\SchemaRegistryApi\Constants\COMPATIBILITY_FORWARD;
12+
use const FlixTech\SchemaRegistryApi\Constants\COMPATIBILITY_FORWARD_TRANSITIVE;
1113
use const FlixTech\SchemaRegistryApi\Constants\COMPATIBILITY_FULL;
14+
use const FlixTech\SchemaRegistryApi\Constants\COMPATIBILITY_FULL_TRANSITIVE;
1215
use const FlixTech\SchemaRegistryApi\Constants\COMPATIBILITY_NONE;
1316
use const FlixTech\SchemaRegistryApi\Constants\VERSION_LATEST;
1417

@@ -154,7 +157,16 @@ function prepareJsonSchemaForTransfer(string $schema): string
154157
function validateCompatibilityLevel(string $compatibilityVersion): string
155158
{
156159
Assert::that($compatibilityVersion)->inArray(
157-
[COMPATIBILITY_NONE, COMPATIBILITY_BACKWARD, COMPATIBILITY_FORWARD, COMPATIBILITY_FULL],
160+
[
161+
COMPATIBILITY_NONE,
162+
COMPATIBILITY_BACKWARD,
163+
COMPATIBILITY_BACKWARD_TRANSITIVE,
164+
COMPATIBILITY_FORWARD,
165+
COMPATIBILITY_FORWARD_TRANSITIVE,
166+
COMPATIBILITY_FULL,
167+
COMPATIBILITY_FULL_TRANSITIVE,
168+
169+
],
158170
'$level must be one of "NONE", "BACKWARD", "FORWARD" or "FULL"'
159171
);
160172

test/Exception/ExceptionMapTest.php

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ExceptionMapTest extends TestCase
2727
/**
2828
* @test
2929
*/
30-
public function it_should_handle_InvalidAvroSchema_code()
30+
public function it_should_handle_InvalidAvroSchema_code(): void
3131
{
3232
$this->assertSchemaRegistryException(
3333
InvalidAvroSchemaException::class,
@@ -50,7 +50,7 @@ public function it_should_handle_InvalidAvroSchema_code()
5050
/**
5151
* @test
5252
*/
53-
public function it_should_handle_IncompatibleAvroSchema_code()
53+
public function it_should_handle_IncompatibleAvroSchema_code(): void
5454
{
5555
$this->assertSchemaRegistryException(
5656
IncompatibleAvroSchemaException::class,
@@ -73,7 +73,7 @@ public function it_should_handle_IncompatibleAvroSchema_code()
7373
/**
7474
* @test
7575
*/
76-
public function it_should_handle_BackendDataStore_code()
76+
public function it_should_handle_BackendDataStore_code(): void
7777
{
7878
$this->assertSchemaRegistryException(
7979
BackendDataStoreException::class,
@@ -96,7 +96,7 @@ public function it_should_handle_BackendDataStore_code()
9696
/**
9797
* @test
9898
*/
99-
public function it_should_handle_InvalidCompatibilityLevel_code()
99+
public function it_should_handle_InvalidCompatibilityLevel_code(): void
100100
{
101101
$this->assertSchemaRegistryException(
102102
InvalidCompatibilityLevelException::class,
@@ -119,7 +119,7 @@ public function it_should_handle_InvalidCompatibilityLevel_code()
119119
/**
120120
* @test
121121
*/
122-
public function it_should_handle_InvalidVersion_code()
122+
public function it_should_handle_InvalidVersion_code(): void
123123
{
124124
$this->assertSchemaRegistryException(
125125
InvalidVersionException::class,
@@ -142,7 +142,7 @@ public function it_should_handle_InvalidVersion_code()
142142
/**
143143
* @test
144144
*/
145-
public function it_should_handle_MasterProxy_code()
145+
public function it_should_handle_MasterProxy_code(): void
146146
{
147147
$this->assertSchemaRegistryException(
148148
MasterProxyException::class,
@@ -165,7 +165,7 @@ public function it_should_handle_MasterProxy_code()
165165
/**
166166
* @test
167167
*/
168-
public function it_should_handle_OperationTimedOut_code()
168+
public function it_should_handle_OperationTimedOut_code(): void
169169
{
170170
$this->assertSchemaRegistryException(
171171
OperationTimedOutException::class,
@@ -188,7 +188,7 @@ public function it_should_handle_OperationTimedOut_code()
188188
/**
189189
* @test
190190
*/
191-
public function it_should_handle_SchemaNotFound_code()
191+
public function it_should_handle_SchemaNotFound_code(): void
192192
{
193193
$this->assertSchemaRegistryException(
194194
SchemaNotFoundException::class,
@@ -211,7 +211,7 @@ public function it_should_handle_SchemaNotFound_code()
211211
/**
212212
* @test
213213
*/
214-
public function it_should_handle_SubjectNotFound_code()
214+
public function it_should_handle_SubjectNotFound_code(): void
215215
{
216216
$this->assertSchemaRegistryException(
217217
SubjectNotFoundException::class,
@@ -234,7 +234,7 @@ public function it_should_handle_SubjectNotFound_code()
234234
/**
235235
* @test
236236
*/
237-
public function it_should_handle_VersionNotFound_code()
237+
public function it_should_handle_VersionNotFound_code(): void
238238
{
239239
$this->assertSchemaRegistryException(
240240
VersionNotFoundException::class,
@@ -260,7 +260,7 @@ public function it_should_handle_VersionNotFound_code()
260260
* @expectedException \RuntimeException
261261
* @expectedExceptionMessage RequestException has no response to inspect
262262
*/
263-
public function it_should_not_process_exceptions_with_missing_response()
263+
public function it_should_not_process_exceptions_with_missing_response(): void
264264
{
265265
(ExceptionMap::instance())(
266266
new RequestException(
@@ -275,7 +275,7 @@ public function it_should_not_process_exceptions_with_missing_response()
275275
*
276276
* @expectedException \LogicException
277277
*/
278-
public function it_will_check_for_invalid_schema_registry_exceptions_not_defining_a_code()
278+
public function it_will_check_for_invalid_schema_registry_exceptions_not_defining_a_code(): void
279279
{
280280
InvalidNewSchemaRegistryException::errorCode();
281281
}
@@ -286,7 +286,7 @@ public function it_will_check_for_invalid_schema_registry_exceptions_not_definin
286286
* @expectedException \RuntimeException
287287
* @expectedExceptionMessage Invalid message body received - cannot find "error_code" field in response body
288288
*/
289-
public function it_should_not_process_exceptions_with_missing_error_codes()
289+
public function it_should_not_process_exceptions_with_missing_error_codes(): void
290290
{
291291
(ExceptionMap::instance())(
292292
new RequestException(
@@ -307,7 +307,7 @@ public function it_should_not_process_exceptions_with_missing_error_codes()
307307
* @expectedException \RuntimeException
308308
* @expectedExceptionMessage Unknown error code "99999"
309309
*/
310-
public function it_should_not_process_unknown_error_codes()
310+
public function it_should_not_process_unknown_error_codes(): void
311311
{
312312
(ExceptionMap::instance())(
313313
new RequestException(
@@ -327,7 +327,8 @@ private function assertSchemaRegistryException(
327327
string $expectedMessage,
328328
int $errorCode,
329329
SchemaRegistryException $exception
330-
) {
330+
): void
331+
{
331332
$this->assertInstanceOf($exceptionClass, $exception);
332333
$this->assertEquals($errorCode, $exception->getCode());
333334
$this->assertEquals($expectedMessage, $exception->getMessage());

0 commit comments

Comments
 (0)