From 817d5f83d7884274d9264da7f73906145adc0c1e Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Mon, 22 Jan 2018 14:59:37 -0800 Subject: [PATCH] adds system tests for GAPIC clients --- .../Bigtable/BigtableInstanceAdminTest.php | 84 ++++++++++++++++++ .../Container/ClusterManagerClientTest.php | 85 ++++++++++++++++++ .../Dataproc/ClusterControllerClientTest.php | 87 +++++++++++++++++++ .../OsLogin/OsLoginServiceClientTest.php | 84 ++++++++++++++++++ tests/system/Spanner/SpannerTestCase.php | 2 + 5 files changed, 342 insertions(+) create mode 100644 tests/system/Bigtable/BigtableInstanceAdminTest.php create mode 100644 tests/system/Container/ClusterManagerClientTest.php create mode 100644 tests/system/Dataproc/ClusterControllerClientTest.php create mode 100644 tests/system/OsLogin/OsLoginServiceClientTest.php diff --git a/tests/system/Bigtable/BigtableInstanceAdminTest.php b/tests/system/Bigtable/BigtableInstanceAdminTest.php new file mode 100644 index 000000000000..ef7448d3cf97 --- /dev/null +++ b/tests/system/Bigtable/BigtableInstanceAdminTest.php @@ -0,0 +1,84 @@ + $credentialsLoader, + 'transport' => 'rest' + ]); + + self::$grpcClient = new BigtableInstanceAdminClient([ + 'credentialsLoader' => $credentialsLoader, + 'transport' => 'grpc' + ]); + + self::$projectId = $keyFileData['project_id']; + + self::$hasSetUp = true; + } + + /** + * @dataProvider clientProvider + */ + public function testListInstances(BigtableInstanceAdminClient $client) + { + $response = $client->listInstances( + $client->projectName(self::$projectId) + ); + + $this->assertInstanceOf(ListInstancesResponse::class, $response); + } +} + + diff --git a/tests/system/Container/ClusterManagerClientTest.php b/tests/system/Container/ClusterManagerClientTest.php new file mode 100644 index 000000000000..3e441b50b8e4 --- /dev/null +++ b/tests/system/Container/ClusterManagerClientTest.php @@ -0,0 +1,85 @@ + $credentialsLoader, + 'transport' => 'rest' + ]); + + self::$grpcClient = new ClusterManagerClient([ + 'credentialsLoader' => $credentialsLoader, + 'transport' => 'grpc' + ]); + + + self::$projectId = $keyFileData['project_id']; + + self::$hasSetUp = true; + } + + /** + * @dataProvider clientProvider + */ + public function testListOperations(ClusterManagerClient $client) + { + $response = $client->listOperations(self::$projectId, self::ZONE); + + $this->assertInstanceOf(ListOperationsResponse::class, $response); + } +} + + diff --git a/tests/system/Dataproc/ClusterControllerClientTest.php b/tests/system/Dataproc/ClusterControllerClientTest.php new file mode 100644 index 000000000000..70b497bf3888 --- /dev/null +++ b/tests/system/Dataproc/ClusterControllerClientTest.php @@ -0,0 +1,87 @@ + $credentialsLoader, + 'transport' => 'rest' + ]); + + self::$grpcClient = new ClusterControllerClient([ + 'credentialsLoader' => $credentialsLoader, + 'transport' => 'grpc' + ]); + + self::$projectId = $keyFileData['project_id']; + + self::$hasSetUp = true; + } + + /** + * @dataProvider clientProvider + */ + public function testListOperations(ClusterControllerClient $client) + { + $pagedResponse = $client->listClusters(self::$projectId, self::REGION); + $this->assertInstanceOf(PagedListResponse::class, $pagedResponse); + + $response = $pagedResponse->getPage()->getResponseObject(); + $this->assertInstanceOf(ListClustersResponse::class, $response); + } +} + + diff --git a/tests/system/OsLogin/OsLoginServiceClientTest.php b/tests/system/OsLogin/OsLoginServiceClientTest.php new file mode 100644 index 000000000000..0bb25d44cff8 --- /dev/null +++ b/tests/system/OsLogin/OsLoginServiceClientTest.php @@ -0,0 +1,84 @@ + $credentialsLoader, + 'transport' => 'rest' + ]); + + self::$grpcClient = new OsLoginServiceClient([ + 'credentialsLoader' => $credentialsLoader, + 'transport' => 'grpc' + ]); + + self::$clientEmail = $keyFileData['client_email']; + + self::$hasSetUp = true; + } + + /** + * @dataProvider clientProvider + */ + public function testListOperations(OsLoginServiceClient $client) + { + $response = $client->getLoginProfile( + $client->userName(self::$clientEmail) + ); + + $this->assertInstanceOf(LoginProfile::class, $response); + } +} + + diff --git a/tests/system/Spanner/SpannerTestCase.php b/tests/system/Spanner/SpannerTestCase.php index 1d1b9f92aba5..23338fba8036 100644 --- a/tests/system/Spanner/SpannerTestCase.php +++ b/tests/system/Spanner/SpannerTestCase.php @@ -75,6 +75,8 @@ public static function setUpBeforeClass() self::$database = $db; self::$database2 = self::getDatabaseInstance(self::$dbName); + + self::$hasSetUp = true; } private static function getClient()