1
1
2
+
2
3
namespace Google \Cloud \Samples \BigTable \Tests ;
3
4
5
+ use Google \Cloud \Bigtable \BigtableClient ;
4
6
use PHPUnit \Framework \TestCase ;
5
7
6
8
use Google \Cloud \Bigtable \Admin \V2 \BigtableInstanceAdminClient ;
12
14
13
15
final class BigTableTest extends TestCase
14
16
{
15
- use TestTrait,ExponentialBackoffTrait;
17
+ use TestTrait, ExponentialBackoffTrait;
16
18
17
19
const INSTANCE_ID_PREFIX = 'php-instance- ' ;
18
20
const CLUSTER_ID_PREFIX = 'php-cluster- ' ;
19
21
const TABLE_ID_PREFIX = 'php-table- ' ;
20
22
private static $ instanceAdminClient ;
21
23
private static $ tableAdminClient ;
24
+ private static $ bigtableClient ;
22
25
private static $ instanceId ;
23
26
private static $ clusterId ;
24
27
@@ -27,11 +30,14 @@ public static function setUpBeforeClass()
27
30
self ::checkProjectEnvVarBeforeClass ();
28
31
self ::$ instanceAdminClient = new BigtableInstanceAdminClient ();
29
32
self ::$ tableAdminClient = new BigtableTableAdminClient ();
33
+ self ::$ bigtableClient = new BigtableClient ([
34
+ 'projectId ' => self ::$ projectId ,
35
+ ]);
30
36
31
37
self ::$ instanceId = uniqid (self ::INSTANCE_ID_PREFIX );
32
38
self ::$ clusterId = uniqid (self ::CLUSTER_ID_PREFIX );
33
39
34
- self ::create_production_instance (self ::$ projectId ,self ::$ instanceId ,self ::$ clusterId );
40
+ self ::create_production_instance (self ::$ projectId , self ::$ instanceId , self ::$ clusterId );
35
41
}
36
42
37
43
public function setUp ()
@@ -368,16 +374,18 @@ public function testWritingRows()
368
374
$ tableId = uniqid (self ::TABLE_ID_PREFIX );
369
375
$ tableName = self ::$ tableAdminClient ->tableName (self ::$ projectId , self ::$ instanceId , $ tableId );
370
376
371
- $ this ->createTable (self ::$ projectId , self ::$ instanceId , self ::$ clusterId , $ tableId );
377
+ $ this ->createHWTable (self ::$ projectId , self ::$ instanceId , self ::$ clusterId , $ tableId );
372
378
$ this ->checkTable ($ tableName );
373
379
374
- $ content = self ::runSnippet ('writing_rows ' , [
380
+ $ content = self ::runSnippet ('hw_write_rows ' , [
375
381
self ::$ projectId ,
376
382
self ::$ instanceId ,
377
383
$ tableId
378
384
]);
379
385
380
- $ table = self ::$ tableAdminClient ->table (self ::$ instanceId , self ::$ tableId );
386
+ $ table = self ::$ bigtableClient ->table (self ::$ instanceId , $ tableId );
387
+ $ columnFamilyId = 'cf1 ' ;
388
+ $ column = 'greeting ' ;
381
389
382
390
$ partial_rows = $ table ->readRows ([])->readAll ();
383
391
$ array = [];
@@ -395,16 +403,16 @@ public function testGettingARow()
395
403
$ tableId = uniqid (self ::TABLE_ID_PREFIX );
396
404
$ tableName = self ::$ tableAdminClient ->tableName (self ::$ projectId , self ::$ instanceId , $ tableId );
397
405
398
- $ this ->createTable (self ::$ projectId , self ::$ instanceId , self ::$ clusterId , $ tableId );
406
+ $ this ->createHWTable (self ::$ projectId , self ::$ instanceId , self ::$ clusterId , $ tableId );
399
407
$ this ->checkTable ($ tableName );
400
408
401
- self ::runSnippet ('writing_rows ' , [
409
+ self ::runSnippet ('hw_write_rows ' , [
402
410
self ::$ projectId ,
403
411
self ::$ instanceId ,
404
412
$ tableId
405
413
]);
406
414
407
- $ content = self ::runSnippet ('getting_a_row ' , [
415
+ $ content = self ::runSnippet ('hw_get_with_filter ' , [
408
416
self ::$ projectId ,
409
417
self ::$ instanceId ,
410
418
$ tableId
@@ -421,16 +429,16 @@ public function testScanningAllRows()
421
429
$ tableId = uniqid (self ::TABLE_ID_PREFIX );
422
430
$ tableName = self ::$ tableAdminClient ->tableName (self ::$ projectId , self ::$ instanceId , $ tableId );
423
431
424
- $ this ->createTable (self ::$ projectId , self ::$ instanceId , self ::$ clusterId , $ tableId );
432
+ $ this ->createHWTable (self ::$ projectId , self ::$ instanceId , self ::$ clusterId , $ tableId );
425
433
$ this ->checkTable ($ tableName );
426
434
427
- self ::runSnippet ('writing_rows ' , [
435
+ self ::runSnippet ('hw_write_rows ' , [
428
436
self ::$ projectId ,
429
437
self ::$ instanceId ,
430
438
$ tableId
431
439
]);
432
440
433
- $ content = self ::runSnippet ('scanning_all_rows ' , [
441
+ $ content = self ::runSnippet ('hw_scan_all ' , [
434
442
self ::$ projectId ,
435
443
self ::$ instanceId ,
436
444
$ tableId
@@ -548,6 +556,15 @@ private function createTable($projectId, $instanceId, $clusterId, $tableId)
548
556
]);
549
557
}
550
558
559
+ private function createHWTable ($ projectId , $ instanceId , $ clusterId , $ tableId )
560
+ {
561
+ self ::runSnippet ('hw_create_table ' , [
562
+ $ projectId ,
563
+ $ instanceId ,
564
+ $ tableId
565
+ ]);
566
+ }
567
+
551
568
private function cleanInstance ($ projectId , $ instanceId )
552
569
{
553
570
$ content = self ::runSnippet ('delete_instance ' , [
0 commit comments