-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
756 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea | ||
/vendor/ | ||
.DS_Store | ||
.DS_Store | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Reatang\GrpcPHPAbstract\Client; | ||
|
||
class Options | ||
{ | ||
public const Metadata = "metadata"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
namespace Reatang\GrpcPHPAbstract\Exceptions; | ||
|
||
class GrpcPhpClientException extends \Exception{ } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Reatang\GrpcPHPAbstract\Tests\Features; | ||
|
||
use GuzzleHttp\RequestOptions; | ||
use Reatang\GrpcPHPAbstract\Client\Options; | ||
use Reatang\GrpcPHPAbstract\Metadata\Metadata; | ||
use Reatang\GrpcPHPAbstract\Tests\Mock\PB\PingRequest; | ||
use Reatang\GrpcPHPAbstract\Tests\Mock\TestServer; | ||
use Reatang\GrpcPHPAbstract\Tests\Mock\TestServerClient; | ||
use Reatang\GrpcPHPAbstract\Tests\TestCase; | ||
|
||
class BaseGatewayTest extends TestCase | ||
{ | ||
public function testPing() | ||
{ | ||
$response = $this->getMockGatewayClient()->Ping(new PingRequest(["ping" => "test"])); | ||
$this->assertEquals($response->getPong(), "PONG"); | ||
} | ||
|
||
public function testMetadata() | ||
{ | ||
$metadata = "123"; | ||
$response = $this->getMockGatewayClient()->Ping(new PingRequest(["ping" => "metadata"]), [ | ||
Options::Metadata => Metadata::create(["abc" => $metadata]), | ||
]); | ||
|
||
$this->assertEquals($response->getPong(), "PONG" . $metadata); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace Reatang\GrpcPHPAbstract\Tests\Features; | ||
|
||
use OpenTelemetry\API\Baggage\Baggage; | ||
use OpenTelemetry\API\Baggage\Propagation\BaggagePropagator; | ||
use OpenTelemetry\API\Trace\Propagation\TraceContextPropagator; | ||
use OpenTelemetry\Context\Propagation\MultiTextMapPropagator; | ||
use OpenTelemetry\SDK\Sdk; | ||
use OpenTelemetry\SDK\Trace\Sampler\AlwaysOnSampler; | ||
use OpenTelemetry\SDK\Trace\Sampler\ParentBased; | ||
use OpenTelemetry\SDK\Trace\SpanProcessor\NoopSpanProcessor; | ||
use OpenTelemetry\SDK\Trace\TracerProvider; | ||
use Reatang\GrpcPHPAbstract\Tests\Mock\PB\OTelRequest; | ||
use Reatang\GrpcPHPAbstract\Tests\TestCase; | ||
|
||
class OpenTelemetryGatewayTest extends TestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
// $processor = new SimpleSpanProcessor((new ConsoleSpanExporterFactory())->create()); | ||
$processor = new NoopSpanProcessor(); | ||
$tracerProvider = new TracerProvider( | ||
$processor, | ||
new ParentBased(new AlwaysOnSampler()), | ||
); | ||
|
||
Sdk::builder() | ||
->setTracerProvider($tracerProvider) | ||
->setPropagator(new MultiTextMapPropagator([ | ||
TraceContextPropagator::getInstance(), | ||
BaggagePropagator::getInstance(), | ||
])) | ||
->setAutoShutdown(true) | ||
->buildAndRegisterGlobal(); | ||
} | ||
|
||
public function testBase() | ||
{ | ||
$response = $this->getMockGatewayClient()->OTel(new OTelRequest()); | ||
|
||
$this->assertTrue(!empty($response->getTrace())); | ||
$this->assertNotEquals($response->getTrace(), '00000000000000000000000000000000'); | ||
} | ||
|
||
public function testBaggage() | ||
{ | ||
$baggageVar = "123"; | ||
$scope = Baggage::getCurrent()->toBuilder()->set("baggage1", $baggageVar)->build()->activate(); | ||
|
||
$response = $this->getMockGatewayClient()->OTel(new OTelRequest()); | ||
|
||
$scope->detach(); | ||
|
||
$this->assertTrue(!empty($response->getTrace())); | ||
$this->assertNotEquals($response->getTrace(), '00000000000000000000000000000000'); | ||
$this->assertEquals($baggageVar, $response->getBaggage()); | ||
} | ||
} |
Oops, something went wrong.