Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add functional tests #5

Merged
merged 1 commit into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,45 @@ jobs:
env: SYMFONY_VERSION="5.0.*"
- php: '7.4'
env: SYMFONY_VERSION="5.0.*"
- stage: test-functional
php: '7.4'
env:
- SYMFONY_VERSION="3.4.*"
- BRANCH=${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}
services: docker
before_script:
- wget https://get.symfony.com/cli/installer -O - | bash
- sudo mv /home/travis/.symfony/bin/symfony /usr/local/bin/symfony
script:
- composer run-script phpunit-functional
after_success:
- docker ps
- stage: test-functional
php: '7.4'
env:
- SYMFONY_VERSION="4.4.*"
- BRANCH=${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}
services: docker
before_script:
- wget https://get.symfony.com/cli/installer -O - | bash
- sudo mv /home/travis/.symfony/bin/symfony /usr/local/bin/symfony
script:
- composer run-script phpunit-functional
after_success:
- docker ps
- stage: test-functional
php: '7.4'
env:
- SYMFONY_VERSION="5.0.*"
- BRANCH=${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}
services: docker
before_script:
- wget https://get.symfony.com/cli/installer -O - | bash
- sudo mv /home/travis/.symfony/bin/symfony /usr/local/bin/symfony
script:
- composer run-script phpunit-functional
after_success:
- docker ps

before_install:
- composer global require hirak/prestissimo
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# auxmoney OpentracingBundle - Jaeger

![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/auxmoney/OpentracingBundle-Jaeger)
![Travis (.org)](https://img.shields.io/travis/auxmoney/OpentracingBundle-Jaeger)
![Coveralls github](https://img.shields.io/coveralls/github/auxmoney/OpentracingBundle-Jaeger)
![Codacy Badge](https://api.codacy.com/project/badge/Grade/dd11fb9bdbe54affb1946a03af5f432a)
![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/auxmoney/OpentracingBundle-Jaeger)
![Scrutinizer code quality (GitHub/Bitbucket)](https://img.shields.io/scrutinizer/quality/g/auxmoney/OpentracingBundle-Jaeger)
![GitHub](https://img.shields.io/github/license/auxmoney/OpentracingBundle-Jaeger)

This symfony bundle provides a tracer implementation for [Jaeger](https://www.jaegertracing.io/) for the [auxmoney OpentracingBundle](https://github.com/auxmoney/OpentracingBundle-core).

Please have a look at [the central documentation](https://github.com/auxmoney/OpentracingBundle-core) for installation and usage instructions.
25 changes: 25 additions & 0 deletions Tests/Functional/FunctionalTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

namespace Auxmoney\OpentracingBundle\Tests\Functional;

use Symfony\Component\Process\Process;

class FunctionalTest extends JaegerFunctionalTest
{
public function testSuccessfulTracing(): void
{
$this->setUpTestProject('default');

$p = new Process(['symfony', 'console', 'test:jaeger'], 'build/testproject');
$p->mustRun();
$output = $p->getOutput();
$traceId = substr($output, 0, strpos($output, ':'));
self::assertNotEmpty($traceId);

$spans = $this->getSpansFromTrace($this->getTraceFromJaegerAPI($traceId));
self::assertCount(1, $spans);
self::assertSame('test:jaeger', $spans[0]['operationName']);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace App\Command;

use Auxmoney\OpentracingBundle\Internal\Opentracing;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use const OpenTracing\Formats\TEXT_MAP;

class TestCommand extends Command
{
private $opentracing;

public function __construct(Opentracing $opentracing)
{
parent::__construct('test:jaeger');
$this->setDescription('some fancy command description');
$this->opentracing = $opentracing;
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$carrier = [];
$this->opentracing->getTracerInstance()->inject($this->opentracing->getTracerInstance()->getActiveSpan()->getContext(), TEXT_MAP, $carrier);
$output->writeln(current($carrier));
return 0;
}
}
15 changes: 13 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
"phpstan/phpstan": "^0.12",
"squizlabs/php_codesniffer": "^3.5",
"phpmd/phpmd": "^2.7",
"php-coveralls/php-coveralls": "^2.2"
"php-coveralls/php-coveralls": "^2.2",
"symfony/filesystem": "*",
"symfony/process": "*",
"symfony/yaml": "*",
"mtdowling/jmespath.php": "^2.5"
},
"autoload": {
"psr-4": {
Expand All @@ -49,7 +53,14 @@
],
"phpmd": "vendor/bin/phpmd . text cleancode,codesize,controversial,design,naming,unusedcode --exclude vendor,Tests",
"phpcs": "vendor/bin/phpcs",
"phpunit": "phpdbg -qrr vendor/bin/phpunit --colors=never",
"phpunit": "phpdbg -qrr vendor/bin/phpunit --colors=never --testsuite=unit",
"phpunit-functional": [
"vendor/auxmoney/opentracing-bundle-core/Tests/Functional/Scripts/checkEnvironment.sh",
"vendor/auxmoney/opentracing-bundle-core/Tests/Functional/Scripts/setup.sh",
"vendor/auxmoney/opentracing-bundle-core/Tests/Functional/Scripts/createResetPoint.sh",
"vendor/bin/phpunit --colors=never --testsuite=functional --no-coverage",
"vendor/auxmoney/opentracing-bundle-core/Tests/Functional/Scripts/teardown.sh"
],
"phpstan": "vendor/bin/phpstan analyse --no-progress"
}
}
6 changes: 6 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
<testsuites>
<testsuite name="unit">
<directory>./Tests/</directory>
<exclude>./Tests/Functional</exclude>
</testsuite>
<testsuite name="functional">
<directory>./Tests/Functional/</directory>
<exclude>./Tests/Functional/Scripts</exclude>
<exclude>./Tests/Functional/TestProjectFiles</exclude>
</testsuite>
</testsuites>

Expand Down