Skip to content

Commit

Permalink
feat(tests): get system tests passing again
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer committed Sep 24, 2024
1 parent b27aca5 commit 186fd65
Show file tree
Hide file tree
Showing 83 changed files with 515 additions and 431 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name:
name: Backward Compatibility
on:
pull_request:
types: [opened, synchronize, reopened, edited]
branches: ['main']
jobs:
# More info at https://github.com/Roave/BackwardCompatibilityCheck.
backwards-compatibility-check:
name: Backwards Compatibility Check
name: Breaking Change Detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -47,10 +47,12 @@ jobs:
--from=${{ steps.latest-release.outputs.release }} \
--to=origin/main --format=github-actions
# Ensure that PRs labeled "feat" actually contain a new feature
# Ensure that PRs labeled "feat" actually contain a new feature, PRs labeled
# "bug" or "chore" do not.
conventional-commit-check:
name: Conventional Commit Check
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'gcf-owl-bot[bot]'
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -63,19 +65,60 @@ jobs:
run: composer global require "roave/backward-compatibility-check:^8.2"
- name: "Check for an incorrect feat label in the PR"
id: compatibility-checker
if: ${{ github.event.pull_request.user.login == 'gcf-owl-bot[bot]' }}
continue-on-error: true
# OwlBot PRs which are not labelled feat should not add new files or methods
run: |
~/.composer/vendor/bin/roave-backward-compatibility-check --to=origin/main --format=github-actions
- name: "Print the action item"
run: |
if [[ "${{ steps.compatibility-checker.outcome }}" == 'failure' ]]; then
if [[ "${{ !startsWith(github.event.pull_request.title, 'feat') }}" ]]; then
if [[ "${{ startsWith(github.event.pull_request.title, 'feat') }}" == "true" ]]; then
echo "Action item: Change the conventional commit to use 'feat'"
exit 1
fi
elif [[ "${{ !startsWith(github.event.pull_request.title, 'feat') }}" ]]; then
elif [[ "${{ startsWith(github.event.pull_request.title, 'feat') }}" == "false" ]]; then
echo "Action item: No features found, do not use 'feat' for the conventional commit"
exit 1
fi
# Ensure the release PR does not contain an unexpected (e.g. 2.0.0) major version release
# Add "MAJOR_VERSION_ALLOWED=component1,component2" to the PR description to allow major version
# releases for those components
unexpected-major-version-check:
name: Unexpected Major Version Check
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'release-please[bot]'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Parse allowed major versions
uses: actions-ecosystem/action-regex-match@v2
id: allowed-major-versions
with:
text: ${{ github.event.pull_request.body }}
regex: '^MAJOR_VERSION_ALLOWED=(.*)$'
flags: gm
- name: "Check for unexpected major version"
run: |
# parse allowed major versions into an array
IFS=', ' read -r -a ALLOWED_MAJOR_VERSIONS <<< "${{ steps.allowed-major-versions.outputs.group1 }}"
# get all changed components
COMPONENTS=$(git diff origin/main --name-only | grep VERSION | xargs dirname)
FAIL=""
for COMPONENT in ${COMPONENTS}; do {
if [[ "$(cat $COMPONENT/VERSION)" == [123456789].0.0 ]]; then
# A new version is being released - make sure it's allowed
if [[ ${ALLOWED_MAJOR_VERSIONS[@]} =~ $COMPONENT ]]; then
echo "Major version release allowed: $COMPONENT"
else
echo "Unexpected major version release found: $COMPONENT"
FAIL="true"
fi
fi
}; done
if [[ "$FAIL" == "true" ]]; then
echo "Add \"MAJOR_VERSION_ALLOWED=component1,component2\" to the PR description to allow "
echo "major version releases for those components"
exit 1
fi
80 changes: 0 additions & 80 deletions .github/workflows/release-checks.yaml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/system-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: System Tests
on:
pull_request:
workflow_dispatch:
jobs:
# Run system tests on the release PR
system-tests:
name: Run System Test Suite
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'release-please[bot]' || github.event_name == 'workflow_dispatch'
env:
ASSET_TEST_BUCKET: cloud-php-testdata
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@verbose
with:
php-version: "8.1"
extensions: grpc
ini-values: grpc.grpc_verbosity=error
- name: Save secrets to file
run: |
echo "${{ secrets.GOOGLE_CLOUD_PHP_TESTS_KEY }}" | base64 -d > ${{ runner.temp }}/service-account.json
echo "${{ secrets.GOOGLE_CLOUD_PHP_WHITELIST_TESTS_KEY }}" | base64 -d > ${{ runner.temp }}/service-account.whitelist.json
echo "${{ secrets.GOOGLE_CLOUD_PHP_FIRESTORE_TESTS_KEY }}" | base64 -d > ${{ runner.temp }}/service-account.firestore.json
- name: Install dependencies
run: composer --no-interaction --no-ansi --no-progress update
- name: Run System Tests
run: vendor/bin/phpunit -c phpunit-system.xml.dist --testdox --colors=always
env:
GOOGLE_CLOUD_PHP_TESTS_KEY_PATH: ${{ runner.temp }}/service-account.json
# GOOGLE_CLOUD_PHP_WHITELIST_TESTS_KEY_PATH: ${{ runner.temp }}/service-account.whitelist.json
# GOOGLE_CLOUD_PHP_FIRESTORE_TESTS_KEY_PATH: ${{ runner.temp }}/service-account.firestore.json
9 changes: 7 additions & 2 deletions Asset/tests/System/V1/AssetServiceSmokeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
*/
namespace Google\Cloud\Asset\Tests\System\V1;

use Google\Cloud\Asset\V1\AssetServiceClient;
use Google\Cloud\Asset\V1\Client\AssetServiceClient;
use Google\Cloud\Asset\V1\ExportAssetsRequest;
use Google\Cloud\Asset\V1\GcsDestination;
use Google\Cloud\Asset\V1\OutputConfig;
use Google\Cloud\Core\Testing\System\SystemTestCase;
Expand Down Expand Up @@ -46,8 +47,12 @@ public function smokeTest()
$outputConfig = new OutputConfig([
'gcs_destination' => $gcsDestination
]);
$request = new ExportAssetsRequest([
'parent' => "projects/$projectId",
'output_config' => $outputConfig
]);

$resp = $client->exportAssets("projects/$projectId", $outputConfig);
$resp = $client->exportAssets($request);
$resp->pollUntilComplete();

$this->assertTrue($resp->operationSucceeded());
Expand Down
7 changes: 5 additions & 2 deletions BigQuery/tests/System/BigQueryTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use Google\Cloud\Storage\StorageClient;
use Google\Cloud\Core\Testing\System\SystemTestCase;

class BigQueryTestCase extends SystemTestCase
abstract class BigQueryTestCase extends SystemTestCase
{
const TESTING_PREFIX = 'gcloud_testing_';
const ENCRYPTION_SERVICE_ACCOUNT_EMAIL_TEMPLATE = 'bq-%[email protected]';
Expand All @@ -35,7 +35,10 @@ class BigQueryTestCase extends SystemTestCase
protected static $table;
private static $hasSetUp = false;

public static function setUpBeforeClass(): void
/**
* @beforeClass
*/
public static function setUpTestFixtures(): void
{
if (self::$hasSetUp) {
return;
Expand Down
7 changes: 5 additions & 2 deletions BigQuery/tests/System/ManageModelsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ class ManageModelsTest extends BigQueryTestCase
private static $keyName1;
private static $keyName2;

public static function setUpBeforeClass(): void
/**
* @beforeClass
*/
public static function setUpTestFixtures(): void
{
parent::setUpBeforeClass();
parent::setUpTestFixtures();

self::$modelId = uniqid(self::TESTING_PREFIX);

Expand Down
7 changes: 5 additions & 2 deletions BigQuery/tests/System/ManageRoutinesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ class ManageRoutinesTest extends BigQueryTestCase
{
private static $routines = [];

public static function setUpBeforeClass(): void
/**
* @beforeClass
*/
public static function setUpTestFixtures(): void
{
parent::setUpBeforeClass();
parent::setUpTestFixtures();

for ($i = 0; $i < 2; $i++) {
$routineId = uniqid(self::TESTING_PREFIX);
Expand Down
3 changes: 3 additions & 0 deletions BigQuery/tests/System/ManageTablesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ public function testReloadsTable()
public function testCreatesExternalTable()
{
$externalKeyFilePath = getenv('GOOGLE_CLOUD_PHP_FIRESTORE_TESTS_KEY_PATH');
if (!$externalKeyFilePath) {
$this->markTestSkipped('GOOGLE_CLOUD_PHP_FIRESTORE_TESTS_KEY_PATH must be set to run this test.');
}
$authenticatedKeyFilePath = getenv('GOOGLE_CLOUD_PHP_TESTS_KEY_PATH');
$externalKey = json_decode(file_get_contents($externalKeyFilePath), true);
$authenticatedKey = json_decode(file_get_contents($authenticatedKeyFilePath), true);
Expand Down
7 changes: 5 additions & 2 deletions BigQuery/tests/System/RegionalizationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ class RegionalizationTest extends BigQueryTestCase
private static $tableAsia;
private static $bucketAsia;

public static function setUpBeforeClass(): void
/**
* @beforeClass
*/
public static function setUpTestFixtures(): void
{
parent::setUpBeforeClass();
parent::setUpTestFixtures();
self::$datasetAsia = self::createDataset(
self::$client,
uniqid(self::TESTING_PREFIX),
Expand Down
13 changes: 9 additions & 4 deletions Bigtable/tests/System/BackupTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ class BackupTests extends BigtableTestCase
*/
private static $copyBackupClusterId;

public static function setUpBeforeClass(): void
/**
* @beforeClass
*/
public static function setUpTestFixtures(): void
{
parent::setUpBeforeClass();
parent::setUpTestFixtures();

self::$backupId = uniqid('backup');
self::$copyBackupId = 'copy' . self::$backupId;
Expand All @@ -78,8 +81,10 @@ public static function setUpBeforeClass(): void
);
self::$copyBackupClusterId = uniqid(self::CLUSTER_ID_PREFIX);
}

public static function tearDownAfterClass(): void
/**
* @afterClass
*/
public static function tearDownTestFixtures(): void
{
// Delete the base backup
self::deleteBackupIfExists(self::$tableAdminClient, self::$backupName);
Expand Down
7 changes: 5 additions & 2 deletions Bigtable/tests/System/BigtableInstanceAdminClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@ class BigtableInstanceAdminClientTest extends TestCase

public function clientProvider()
{
self::setUpBeforeClass();
self::setUpTestFixtures();

return [
[self::$restClient],
[self::$grpcClient]
];
}

public static function setUpBeforeClass(): void
/**
* @beforeClass
*/
public static function setUpTestFixtures(): void
{
if (self::$hasSetUp) {
return;
Expand Down
11 changes: 8 additions & 3 deletions Bigtable/tests/System/BigtableTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ class BigtableTestCase extends SystemTestCase
protected static $instanceId;
protected static $clusterId;

public static function setUpBeforeClass(): void
/**
* @beforeClass
*/
public static function setUpTestFixtures(): void
{
self::setUsingEmulator(getenv('BIGTABLE_EMULATOR_HOST'));
$keyFilePath = getenv('GOOGLE_CLOUD_PHP_TESTS_KEY_PATH');
Expand All @@ -73,8 +76,10 @@ public static function setUpBeforeClass(): void
}
self::createTable();
}

public static function tearDownAfterClass(): void
/**
* @afterClass
*/
public static function tearDownTestFixtures(): void
{
self::deleteTable();
if (!self::isEmulatorUsed()) {
Expand Down
7 changes: 5 additions & 2 deletions Bigtable/tests/System/CheckAndMutateRowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@
*/
class CheckAndMutateRowTest extends BigtableTestCase
{
public static function setUpBeforeClass(): void
/**
* @beforeClass
*/
public static function setUpTestFixtures(): void
{
parent::setUpBeforeClass();
parent::setUpTestFixtures();
$insertRows = [
'rk1' => [
'cf1' => [
Expand Down
Loading

0 comments on commit 186fd65

Please sign in to comment.