From 35540f53d702cf26a98cecce7ff14a040a0ea26a Mon Sep 17 00:00:00 2001 From: Nadiya Syvokonenko Date: Mon, 2 Nov 2020 10:28:10 -0600 Subject: [PATCH] MCLOUD-7193: Add ES to compatibility service version validator --- .../Validator/Deploy/ServiceVersion.php | 3 +- .../Validator/Deploy/ServiceVersionTest.php | 45 ++++++++++++------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/Config/Validator/Deploy/ServiceVersion.php b/src/Config/Validator/Deploy/ServiceVersion.php index 43ab96cb2..2aca3e2e8 100644 --- a/src/Config/Validator/Deploy/ServiceVersion.php +++ b/src/Config/Validator/Deploy/ServiceVersion.php @@ -71,7 +71,8 @@ public function validate(): Validator\ResultInterface $services = [ ServiceInterface::NAME_RABBITMQ, ServiceInterface::NAME_REDIS, - ServiceInterface::NAME_DB + ServiceInterface::NAME_DB, + ServiceInterface::NAME_ELASTICSEARCH ]; $errors = []; diff --git a/src/Test/Unit/Config/Validator/Deploy/ServiceVersionTest.php b/src/Test/Unit/Config/Validator/Deploy/ServiceVersionTest.php index 3d0a2db76..08b23ce58 100644 --- a/src/Test/Unit/Config/Validator/Deploy/ServiceVersionTest.php +++ b/src/Test/Unit/Config/Validator/Deploy/ServiceVersionTest.php @@ -72,33 +72,39 @@ protected function setUp() public function testValidate(): void { - $service1 = $this->createMock(ServiceInterface::class); - $service1->expects($this->once()) + $serviceRmq = $this->createMock(ServiceInterface::class); + $serviceRmq->expects($this->once()) ->method('getVersion') ->willReturn('0'); - $service2 = $this->createMock(ServiceInterface::class); - $service2->expects($this->once()) + $serviceRedis = $this->createMock(ServiceInterface::class); + $serviceRedis->expects($this->once()) ->method('getVersion') ->willReturn('3.2'); - $service3 = $this->createMock(ServiceInterface::class); - $service3->expects($this->once()) + $serviceDB = $this->createMock(ServiceInterface::class); + $serviceDB->expects($this->once()) ->method('getVersion') ->willReturn('10.2'); - $this->serviceFactory->expects($this->exactly(3)) + $serviceES = $this->createMock(ServiceInterface::class); + $serviceES->expects($this->once()) + ->method('getVersion') + ->willReturn('7.7'); + $this->serviceFactory->expects($this->exactly(4)) ->method('create') - ->willReturnOnConsecutiveCalls($service1, $service2, $service3); - $this->loggerMock->expects($this->exactly(3)) + ->willReturnOnConsecutiveCalls($serviceRmq, $serviceRedis, $serviceDB, $serviceES); + $this->loggerMock->expects($this->exactly(4)) ->method('info') ->withConsecutive( ['Version of service \'rabbitmq\' is not detected', []], ['Version of service \'redis\' is 3.2', []], - ['Version of service \'mysql\' is 10.2', []] + ['Version of service \'mysql\' is 10.2', []], + ['Version of service \'elasticsearch\' is 7.7', []] ); - $this->serviceVersionValidatorMock->expects($this->exactly(2)) + $this->serviceVersionValidatorMock->expects($this->exactly(3)) ->method('validateService') ->withConsecutive( [ServiceInterface::NAME_REDIS, '3.2'], - [ServiceInterface::NAME_DB, '10.2'] + [ServiceInterface::NAME_DB, '10.2'], + [ServiceInterface::NAME_ELASTICSEARCH, '7.7'] ) ->willReturn(''); $this->resultFactoryMock->expects($this->once()) @@ -109,7 +115,7 @@ public function testValidate(): void public function testValidateWithErrors(): void { - $errorMessages = ['error message 1', 'error message 2', 'error message 3']; + $errorMessages = ['error message 1', 'error message 2', 'error message 3', 'error message 4']; $service1 = $this->createMock(ServiceInterface::class); $service1->expects($this->once()) ->method('getVersion') @@ -122,15 +128,20 @@ public function testValidateWithErrors(): void $service3->expects($this->once()) ->method('getVersion') ->willReturn('5.7'); - $this->serviceFactory->expects($this->exactly(3)) + $service4 = $this->createMock(ServiceInterface::class); + $service4->expects($this->once()) + ->method('getVersion') + ->willReturn('7.7'); + $this->serviceFactory->expects($this->exactly(4)) ->method('create') - ->willReturnOnConsecutiveCalls($service1, $service2, $service3); - $this->serviceVersionValidatorMock->expects($this->exactly(3)) + ->willReturnOnConsecutiveCalls($service1, $service2, $service3, $service4); + $this->serviceVersionValidatorMock->expects($this->exactly(4)) ->method('validateService') ->withConsecutive( [ServiceInterface::NAME_RABBITMQ, '1.5'], [ServiceInterface::NAME_REDIS, '2.2'], - [ServiceInterface::NAME_DB, '5.7'] + [ServiceInterface::NAME_DB, '5.7'], + [ServiceInterface::NAME_ELASTICSEARCH, '7.7'] ) ->willReturnOnConsecutiveCalls(...$errorMessages); $this->resultFactoryMock->expects($this->once())