This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 82
Add Integration tests #181
Merged
chingor13
merged 10 commits into
census-instrumentation:master
from
chingor13:integration-tests
May 8, 2018
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f42f05a
Add Curl integration test
chingor13 04e9f9f
Fix copyright headers for laravel test files
chingor13 2cade61
Fix a few test names
chingor13 266165f
separate bootstrap file unnecessary if only autoloading
chingor13 bdefb23
Add symfony/doctrine integration test
chingor13 d4b1cce
Run symfony test
chingor13 dbe7cd1
Configure database for symfony tests
chingor13 930e795
Skip creating database - already created
chingor13 598a548
Run doctrine migrations without interaction
chingor13 f139537
curl and memcached do not need a bootstrap test file
chingor13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -153,6 +153,81 @@ jobs: | |
RUN_EXTENSION_TESTS: 1 | ||
SUDO_CMD: "" | ||
|
||
integration: | ||
docker: | ||
- image: circleci/php:7.2-node | ||
- image: memcached | ||
- image: mysql:5.7 | ||
environment: | ||
MYSQL_USER: mysql | ||
MYSQL_PASSWORD: mysql | ||
MYSQL_DATABASE: mysqldb | ||
MYSQL_RANDOM_ROOT_PASSWORD: yes | ||
steps: | ||
- checkout | ||
- run: | ||
name: Install build tools | ||
command: | | ||
sudo apt-get update -y | ||
sudo apt-get install -y -q --no-install-recommends \ | ||
build-essential \ | ||
g++ \ | ||
gcc \ | ||
libc-dev \ | ||
make \ | ||
autoconf \ | ||
git \ | ||
unzip | ||
- run: | ||
name: Install opencensus extension | ||
command: | | ||
cd ext | ||
phpize | ||
./configure --enable-opencensus | ||
sudo make install | ||
sudo docker-php-ext-enable opencensus | ||
- run: | ||
name: Install memcached extension | ||
command: | | ||
sudo apt-get install -y -q --no-install-recommends \ | ||
libmemcached11 libmemcached-dev zlib1g-dev zlib1g | ||
sudo pecl install memcached <<<'' | ||
sudo docker-php-ext-enable memcached | ||
- run: | ||
name: Install pdo_mysql extension | ||
command: sudo docker-php-ext-install pdo_mysql | ||
- run: | ||
name: Install mysqli extension | ||
command: sudo docker-php-ext-install mysqli | ||
- run: | ||
name: Curl test | ||
command: tests/integration/curl/test.sh | ||
- run: | ||
name: Guzzle 5 test | ||
command: tests/integration/guzzle5/test.sh | ||
- run: | ||
name: Guzzle 6 test | ||
command: tests/integration/guzzle6/test.sh | ||
- run: | ||
name: Laravel test | ||
command: tests/integration/laravel/test.sh | ||
- run: | ||
name: Memcached test | ||
command: tests/integration/memcached/test.sh | ||
- run: | ||
name: Symfony 4 test | ||
command: tests/integration/symfony4/test.sh | ||
environment: | ||
DATABASE_URL: mysql://mysql:[email protected]:3306/mysqldb | ||
- run: | ||
name: Wordpress test | ||
command: tests/integration/wordpress/test.sh | ||
environment: | ||
DB_HOST: 127.0.0.1 | ||
DB_USERNAME: mysql | ||
DB_PASSWORD: mysql | ||
DB_DATABASE: mysqldb | ||
|
||
workflows: | ||
version: 2 | ||
units: | ||
|
@@ -168,3 +243,4 @@ workflows: | |
- php70-32bit | ||
- php71-32bit | ||
- php71-debug | ||
- integration |
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,16 @@ | ||
{ | ||
"require": { | ||
"php": "^7.2", | ||
"opencensus/opencensus": "dev-master", | ||
"ext-opencensus": "*" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^7.0" | ||
}, | ||
"repositories": [ | ||
{ | ||
"type": "git", | ||
"url": "https://github.com/census-instrumentation/opencensus-php" | ||
} | ||
] | ||
} |
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,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="./vendor/autoload.php" colors="true"> | ||
<testsuites> | ||
<testsuite> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">src</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
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,22 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if [ -z "${CIRCLE_PR_NUMBER}" ]; then | ||
BRANCH="master" | ||
REPO="https://github.com/census-instrumentation/opencensus-php" | ||
else | ||
PR_INFO=$(curl "https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/pulls/${CIRCLE_PR_NUMBER}") | ||
BRANCH=$(echo $PR_INFO | jq -r .head.ref) | ||
REPO=$(echo $PR_INFO | jq -r .head.repo.html_url) | ||
fi | ||
|
||
pushd $(dirname ${BASH_SOURCE[0]}) | ||
|
||
sed -i "s|dev-master|dev-${BRANCH}|" composer.json | ||
sed -i "s|https://github.com/census-instrumentation/opencensus-php|${REPO}|" composer.json | ||
composer install -n --prefer-dist | ||
|
||
vendor/bin/phpunit | ||
|
||
popd |
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,65 @@ | ||
<?php | ||
/** | ||
* Copyright 2018 OpenCensus Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace OpenCensus\Tests\Integration\Trace; | ||
|
||
use OpenCensus\Trace\Tracer; | ||
use OpenCensus\Trace\Exporter\ExporterInterface; | ||
use OpenCensus\Trace\Integrations\Curl; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @group trace | ||
*/ | ||
class CurlTest extends TestCase | ||
{ | ||
public static function setUpBeforeClass() | ||
{ | ||
Curl::load(); | ||
} | ||
|
||
public function setUp() | ||
{ | ||
if (!extension_loaded('opencensus')) { | ||
$this->markTestSkipped('Please enable the opencensus extension.'); | ||
} | ||
opencensus_trace_clear(); | ||
} | ||
|
||
public function testCurlExec() | ||
{ | ||
$url = 'https://www.google.com/'; | ||
|
||
$exporter = $this->prophesize(ExporterInterface::class); | ||
$tracer = Tracer::start($exporter->reveal(), [ | ||
'skipReporting' => true | ||
]); | ||
$ch = curl_init($url); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
$output = curl_exec($ch); | ||
curl_close($ch); | ||
$this->assertNotEmpty($output); | ||
$tracer->onExit(); | ||
|
||
$spans = $tracer->tracer()->spans(); | ||
$this->assertCount(2, $spans); | ||
|
||
$curlSpan = $spans[1]; | ||
$this->assertEquals('curl_exec', $curlSpan->name()); | ||
$this->assertEquals($url, $curlSpan->attributes()['uri']); | ||
} | ||
} |
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,17 @@ | ||
{ | ||
"require": { | ||
"php": "^7.2", | ||
"opencensus/opencensus": "dev-master", | ||
"guzzlehttp/guzzle": "^5.0", | ||
"ext-opencensus": "*" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^7.0" | ||
}, | ||
"repositories": [ | ||
{ | ||
"type": "git", | ||
"url": "https://github.com/census-instrumentation/opencensus-php" | ||
} | ||
] | ||
} |
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,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="./vendor/autoload.php" colors="true"> | ||
<testsuites> | ||
<testsuite> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">src</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
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,22 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if [ -z "${CIRCLE_PR_NUMBER}" ]; then | ||
BRANCH="master" | ||
REPO="https://github.com/census-instrumentation/opencensus-php" | ||
else | ||
PR_INFO=$(curl "https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/pulls/${CIRCLE_PR_NUMBER}") | ||
BRANCH=$(echo $PR_INFO | jq -r .head.ref) | ||
REPO=$(echo $PR_INFO | jq -r .head.repo.html_url) | ||
fi | ||
|
||
pushd $(dirname ${BASH_SOURCE[0]}) | ||
|
||
sed -i "s|dev-master|dev-${BRANCH}|" composer.json | ||
sed -i "s|https://github.com/census-instrumentation/opencensus-php|${REPO}|" composer.json | ||
composer install -n --prefer-dist | ||
|
||
vendor/bin/phpunit | ||
|
||
popd |
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,55 @@ | ||
<?php | ||
/** | ||
* Copyright 2018 OpenCensus Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace OpenCensus\Tests\Integration\Trace; | ||
|
||
use GuzzleHttp\Client; | ||
use OpenCensus\Trace\Tracer; | ||
use OpenCensus\Trace\Exporter\ExporterInterface; | ||
use OpenCensus\Trace\Integrations\Guzzle\EventSubscriber; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @group trace | ||
*/ | ||
class Guzzle5Test extends TestCase | ||
{ | ||
public function testGuzzleRequest() | ||
{ | ||
$client = new Client(); | ||
$subscriber = new EventSubscriber(); | ||
$client->getEmitter()->attach($subscriber); | ||
|
||
$url = 'http://www.google.com/'; | ||
$exporter = $this->prophesize(ExporterInterface::class); | ||
$tracer = Tracer::start($exporter->reveal(), [ | ||
'skipReporting' => true | ||
]); | ||
$response = $client->get($url); | ||
$this->assertEquals(200, $response->getStatusCode()); | ||
|
||
$tracer->onExit(); | ||
|
||
$spans = $tracer->tracer()->spans(); | ||
$this->assertCount(2, $spans); | ||
|
||
$curlSpan = $spans[1]; | ||
$this->assertEquals('GuzzleHttp::request', $curlSpan->name()); | ||
$this->assertEquals('GET', $curlSpan->attributes()['method']); | ||
$this->assertEquals($url, $curlSpan->attributes()['uri']); | ||
} | ||
} |
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,17 @@ | ||
{ | ||
"require": { | ||
"php": "^7.2", | ||
"opencensus/opencensus": "dev-master", | ||
"guzzlehttp/guzzle": "^6.0", | ||
"ext-opencensus": "*" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^7.0" | ||
}, | ||
"repositories": [ | ||
{ | ||
"type": "git", | ||
"url": "https://github.com/census-instrumentation/opencensus-php" | ||
} | ||
] | ||
} |
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,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="./vendor/autoload.php" colors="true"> | ||
<testsuites> | ||
<testsuite> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">src</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
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,22 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
if [ -z "${CIRCLE_PR_NUMBER}" ]; then | ||
BRANCH="master" | ||
REPO="https://github.com/census-instrumentation/opencensus-php" | ||
else | ||
PR_INFO=$(curl "https://api.github.com/repos/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/pulls/${CIRCLE_PR_NUMBER}") | ||
BRANCH=$(echo $PR_INFO | jq -r .head.ref) | ||
REPO=$(echo $PR_INFO | jq -r .head.repo.html_url) | ||
fi | ||
|
||
pushd $(dirname ${BASH_SOURCE[0]}) | ||
|
||
sed -i "s|dev-master|dev-${BRANCH}|" composer.json | ||
sed -i "s|https://github.com/census-instrumentation/opencensus-php|${REPO}|" composer.json | ||
composer install -n --prefer-dist | ||
|
||
vendor/bin/phpunit | ||
|
||
popd |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was broken and caught by integration tests - there is no parameter for query.