diff --git a/.env.dist b/.env.dist index badbe7a..8775efa 100644 --- a/.env.dist +++ b/.env.dist @@ -1 +1 @@ -SCHEMA_REGISTRY_HOST="http://172.68.0.103:8081" +SCHEMA_REGISTRY_HOST="http://192.168.104.103:8081" diff --git a/.travis.yml b/.travis.yml index d065006..d448eca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,19 +15,25 @@ env: matrix: - DEPENDENCIES="low" - DEPENDENCIES="stable" + - DEPENDENCIES="stable" INTEGRATION_TEST="enabled" CONFLUENT_VERSION="3.2.4" + - DEPENDENCIES="stable" INTEGRATION_TEST="enabled" CONFLUENT_VERSION="3.3.2" + - DEPENDENCIES="stable" INTEGRATION_TEST="enabled" CONFLUENT_VERSION="4.0.2" + - DEPENDENCIES="stable" INTEGRATION_TEST="enabled" CONFLUENT_VERSION="4.1.2" + - DEPENDENCIES="stable" INTEGRATION_TEST="enabled" CONFLUENT_VERSION="5.0.1" before_script: - make install-phars -- if [ "$INTEGRATION_TEST" == "enabled" ]; then sudo rm /usr/local/bin/docker-compose; fi; +- if [ "$INTEGRATION_TEST" == "enabled" ]; then sudo rm -f /usr/local/bin/docker-compose; fi; - if [ "$INTEGRATION_TEST" == "enabled" ]; then curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose; fi; - if [ "$INTEGRATION_TEST" == "enabled" ]; then chmod +x docker-compose; fi; - if [ "$INTEGRATION_TEST" == "enabled" ]; then sudo mv docker-compose /usr/local/bin; fi; +- if [ "$INTEGRATION_TEST" == "enabled" ]; then make platform; fi; - composer self-update - if [ "$DEPENDENCIES" == "stable" ]; then composer update --prefer-stable; fi; - if [ "$DEPENDENCIES" == "low" ]; then composer update --prefer-lowest --prefer-stable; fi; script: -- COMPOSER=composer PHP=php make ci-local +- if [ "$INTEGRATION_TEST" == "enabled" ]; then COMPOSER=composer PHP=php make phpunit-integration ; else COMPOSER=composer PHP=php make ci-local; fi; jobs: include: diff --git a/Makefile b/Makefile index 6aa475e..843f8ae 100644 --- a/Makefile +++ b/Makefile @@ -3,43 +3,15 @@ MAKEFLAGS =+ -rR --warn-undefined-variables .PHONY: composer-install composer-update phpstan cs-fixer examples docker run -ifndef CONFLUENT_VERSION - CONFLUENT_VERSION := latest -endif - -ifndef CONFLUENT_NETWORK_SUBNET - CONFLUENT_NETWORK_SUBNET := 172.68.0.0/24 -endif - -ifndef SCHEMA_REGISTRY_IPV4 - SCHEMA_REGISTRY_IPV4 := 172.68.0.103 -endif - -ifndef KAFKA_BROKER_IPV4 - KAFKA_BROKER_IPV4 := 172.68.0.102 -endif - -ifndef ZOOKEEPER_IPV4 - ZOOKEEPER_IPV4 := 172.68.0.101 -endif - -ifndef COMPOSER - COMPOSER := bin/composer.phar -endif - -ifndef PHP - PHP := bin/php -endif - -ifndef PHP_VERSION - PHP_VERSION := 7.1 -endif - -ifndef XDEBUG_VERSION - XDEBUG_VERSION := 2.6.1 -endif - --include variables.mk +CONFLUENT_VERSION ?= latest +CONFLUENT_NETWORK_SUBNET ?= 192.168.104.0/24 +SCHEMA_REGISTRY_IPV4 ?= 192.168.104.103 +KAFKA_BROKER_IPV4 ?= 192.168.104.102 +ZOOKEEPER_IPV4 ?= 192.168.104.101 +COMPOSER ?= bin/composer.phar +PHP ?= bin/php +PHP_VERSION ?= 7.2 +XDEBUG_VERSION ?= 2.6.1 export docker: @@ -68,11 +40,15 @@ cs-fixer-modify: --path-mode=intersection --allow-risky=yes src test phpunit: - PHP_VERSION=$(PHP_VERSION) $(PHP) vendor/bin/phpunit + PHP_VERSION=$(PHP_VERSION) $(PHP) vendor/bin/phpunit --exclude-group integration + +phpunit-integration: + PHP_VERSION=$(PHP_VERSION) $(PHP) vendor/bin/phpunit --group integration coverage: mkdir -p build - PHP_VERSION=$(PHP_VERSION) $(PHP) vendor/bin/phpunit --coverage-clover=build/coverage.clover --coverage-text + PHP_VERSION=$(PHP_VERSION) $(PHP) vendor/bin/phpunit --exclude-group integration \ + --coverage-clover=build/coverage.clover --coverage-text PHP_VERSION=$(PHP_VERSION) $(PHP) bin/ocular.phar code-coverage:upload --format=php-clover \ --repository=g/flix-tech/avro-serde-php build/coverage.clover @@ -93,7 +69,7 @@ install-phars: platform: docker-compose down docker-compose up -d - sleep 15 + sleep 20 clean: rm -rf build diff --git a/composer.json b/composer.json index d7f85e0..610274e 100644 --- a/composer.json +++ b/composer.json @@ -25,8 +25,8 @@ "require": { "php": "^7.1", "beberlei/assert": "~2.7", - "flix-tech/avro-php": "^2.0", - "flix-tech/confluent-schema-registry-api": "^5.0", + "wikimedia/avro": "dev-master@dev", + "flix-tech/confluent-schema-registry-api": "^5.0.3", "widmogrod/php-functional": "^4.2|^5.0" }, "require-dev": { @@ -50,6 +50,9 @@ "suggest": { "symfony/serializer": "To integrate avro-serde-php into symfony ecosystem" }, + "replace": { + "flix-tech/avro-php": "*" + }, "autoload-dev": { "psr-4": { "FlixTech\\AvroSerializer\\Test\\": "test/", diff --git a/docker-compose.yml b/docker-compose.yml index 8dd79f6..c9371a3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,7 +23,7 @@ services: environment: KAFKA_BROKER_ID: 1 KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181' - KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT://172.68.0.102:9092' + KAFKA_ADVERTISED_LISTENERS: 'PLAINTEXT://${KAFKA_BROKER_IPV4}:9092' networks: avro-serializer-net: ipv4_address: ${KAFKA_BROKER_IPV4} diff --git a/test/Objects/RecordSerializerIntegrationTest.php b/test/Objects/RecordSerializerIntegrationTest.php new file mode 100644 index 0000000..58984b0 --- /dev/null +++ b/test/Objects/RecordSerializerIntegrationTest.php @@ -0,0 +1,68 @@ +encodeRecord('test-value', $this->avroSchema, self::TEST_RECORD); + $decoded = $serializer->decodeMessage($encoded); + + $this->assertEquals(self::TEST_RECORD, $decoded); + + return $serializer; + } + + /** + * @test + * + * @depends it_encodes_valid_records + * + * @expectedException \FlixTech\SchemaRegistryApi\Exception\IncompatibleAvroSchemaException + * + * @param \FlixTech\AvroSerializer\Objects\RecordSerializer $serializer + * + * @throws \FlixTech\SchemaRegistryApi\Exception\SchemaRegistryException + */ + public function it_cannot_evolve_incompatible_schema(RecordSerializer $serializer): void + { + $serializer->encodeRecord('test-value', $this->invalidSchema, self::TEST_RECORD); + } + + /** + * @test + * + * @depends it_encodes_valid_records + * + * @param \FlixTech\AvroSerializer\Objects\RecordSerializer $serializer + * + * @return \FlixTech\AvroSerializer\Objects\RecordSerializer + * + * @throws \FlixTech\SchemaRegistryApi\Exception\SchemaRegistryException + */ + public function it_decodes_with_readers_schema(RecordSerializer $serializer): RecordSerializer + { + $encoded = $serializer->encodeRecord('test-value', $this->avroSchema, self::TEST_RECORD); + $decoded = $serializer->decodeMessage($encoded, $this->readersSchema); + + $this->assertEquals(self::READERS_TEST_RECORD, $decoded); + + return $serializer; + } +} diff --git a/test/bootstrap.php b/test/bootstrap.php index d21c14d..7d5af00 100644 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -1,3 +1,5 @@ load(); diff --git a/variables.mk.dist b/variables.mk.dist deleted file mode 100644 index 8de191b..0000000 --- a/variables.mk.dist +++ /dev/null @@ -1,7 +0,0 @@ -PHP_VERSION=7.1 -XDEBUG_VERSION=2.6.1 -CONFLUENT_VERSION=4.1.2 -CONFLUENT_NETWORK_SUBNET=172.68.0.0/24 -SCHEMA_REGISTRY_IPV4=172.68.0.103 -KAFKA_BROKER_IPV4=172.68.0.102 -ZOOKEEPER_IPV4=172.68.0.101