Example #1
0
 public function run()
 {
     // Test management operations
     r\dbCreate('tableTest')->run($this->conn);
     $this->checkQueryResult(r\db('tableTest')->tableCreate('t1', array('hard_durability' => false, 'cache_size' => 8, 'primary_key' => 'p')), array('created' => 1.0));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->insert(array('p' => 'foo')), array('unchanged' => 0, 'skipped' => 0, 'replaced' => 0, 'inserted' => 1, 'errors' => 0, 'deleted' => 0));
     $this->checkQueryResult(r\db('tableTest')->tableList(), array('t1'));
     // TODO: These index tests are kind of duplicates of IndexTest...
     $this->checkQueryResult(r\db('tableTest')->table('t1')->indexCreate('akey'), array('created' => 1.0));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->indexCreate('bfun', r\row('p')), array('created' => 1.0));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->indexCreate('cfun', function ($r) {
         return r\expr(5);
     }), array('created' => 1.0));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->indexList(), array('akey', 'bfun', 'cfun'));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->indexDrop('akey'), array('dropped' => 1.0));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->indexDrop('bfun'), array('dropped' => 1.0));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->indexDrop('cfun'), array('dropped' => 1.0));
     $this->checkQueryResult(r\db('tableTest')->tableDrop('t1'), array('dropped' => 1.0));
     r\dbDrop('tableTest')->run($this->conn);
     // Test general whole-table queries
     $this->requireDataset('Heroes');
     $testResult = r\db('Heroes')->table('marvel')->orderBy('superhero')->run($this->conn)->toNative();
     $this->checkQueryResult(r\expr($testResult)->count(), 3.0);
     $this->datasets['Heroes']->reset();
 }
Example #2
0
 public function run()
 {
     // Test management operations
     r\dbCreate('tableTest')->run($this->conn);
     $this->checkQueryResult(r\db('tableTest')->tableCreate('t1', array('durability' => 'soft', 'primary_key' => 'p'))->pluck('tables_created'), array('tables_created' => 1.0));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->insert(array('p' => 'foo')), array('unchanged' => 0, 'skipped' => 0, 'replaced' => 0, 'inserted' => 1, 'errors' => 0, 'deleted' => 0));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->rebalance()->pluck('rebalanced'), array('rebalanced' => 1.0));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->reconfigure(array('shards' => 1, 'replicas' => 1))->pluck('reconfigured'), array('reconfigured' => 1.0));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->wait()->pluck('ready'), array('ready' => 1.0));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->wait(array('wait_for' => "all_replicas_ready"))->pluck('ready'), array('ready' => 1.0));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->config()->pluck('name'), array('name' => "t1"));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->status()->getField('status')->pluck('all_replicas_ready'), array('all_replicas_ready' => true));
     $this->checkQueryResult(r\db('tableTest')->tableList(), array('t1'));
     // TODO: These index tests are kind of duplicates of IndexTest...
     $this->checkQueryResult(r\db('tableTest')->table('t1')->indexCreate('akey'), array('created' => 1.0));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->indexCreate('bfun', r\row('p')), array('created' => 1.0));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->indexCreate('cfun', function ($r) {
         return r\expr(5);
     }), array('created' => 1.0));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->indexList(), array('akey', 'bfun', 'cfun'));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->indexDrop('akey'), array('dropped' => 1.0));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->indexDrop('bfun'), array('dropped' => 1.0));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->indexDrop('cfun'), array('dropped' => 1.0));
     $this->checkQueryResult(r\db('tableTest')->table('t1')->sync(), array('synced' => 1.0));
     $this->checkQueryResult(r\db('tableTest')->table('t1', false)->count(), 1.0);
     $this->checkQueryResult(r\db('tableTest')->table('t1', true)->count(), 1.0);
     $this->checkQueryResult(r\db('tableTest')->table('t1', array("use_outdated" => true))->count(), 1.0);
     $this->checkQueryResult(r\db('tableTest')->tableDrop('t1')->pluck('tables_dropped'), array('tables_dropped' => 1.0));
     r\dbDrop('tableTest')->run($this->conn);
     // Test general whole-table queries
     $this->requireDataset('Heroes');
     $testResult = r\db('Heroes')->table('marvel')->orderBy('superhero')->run($this->conn);
     $this->checkQueryResult(r\expr($testResult)->count(), 3.0);
     $this->datasets['Heroes']->reset();
 }
Example #3
0
 public function run()
 {
     $this->checkQueryResult(r\dbCreate('dbTest')->pluck('dbs_created'), array('dbs_created' => 1.0));
     $this->checkQueryResult(r\db('dbTest')->wait(), array('ready' => 0.0));
     $this->checkQueryResult(r\db('dbTest')->rebalance(), array());
     $this->checkQueryResult(r\db('dbTest')->reconfigure(array('shards' => 1, 'replicas' => 1)), array());
     $this->checkQueryResult(r\dbDrop('dbTest')->pluck('dbs_dropped'), array('dbs_dropped' => 1.0));
 }
Example #4
0
 protected function create()
 {
     // Prepare a table with 5000 rows
     r\dbCreate('Huge')->run($this->conn);
     r\db('Huge')->tableCreate('t5000', array('hard_durability' => false, 'cache_size' => 128))->run($this->conn);
     $doc = array('key' => 'val');
     $docs = array_fill(0, 5000, $doc);
     r\db('Huge')->table('t5000')->insert($docs)->run($this->conn);
 }
Example #5
0
 protected function create()
 {
     // Prepare a table with 5000 rows
     r\dbCreate('Huge')->run($this->conn);
     r\db('Huge')->tableCreate('t5000', array('durability' => 'soft'))->run($this->conn);
     $doc = array('key' => str_repeat("var", 1000));
     $docs = array_fill(0, 5000, $doc);
     r\db('Huge')->table('t5000')->insert($docs)->run($this->conn);
 }
Example #6
0
 protected function create()
 {
     r\dbCreate('Heroes')->run($this->conn);
     r\db('Heroes')->tableCreate('marvel', array('primary_key' => 'superhero'))->run($this->conn);
     r\db('Heroes')->tableCreate('dc_universe', array('primary_key' => 'name'))->run($this->conn);
     $marvelTable = r\db('Heroes')->table('marvel');
     $dcUniverseTable = r\db('Heroes')->table('dc_universe');
     $marvelTable->insert(array('superhero' => 'Iron Man', 'superpower' => 'Arc Reactor', 'combatPower' => 2.0, 'compassionPower' => 1.5))->run($this->conn);
     $marvelTable->insert(array(array('superhero' => 'Wolverine', 'superpower' => 'Adamantium', 'combatPower' => 5.0, 'compassionPower' => 2.0), array('superhero' => 'Spiderman', 'superpower' => 'spidy sense', 'combatPower' => 2.0, 'compassionPower' => 2.5)))->run($this->conn);
 }
Example #7
0
 public function run()
 {
     r\dbCreate('NoreplyTest')->run($this->conn);
     $this->conn->useDb('NoreplyTest');
     r\tableCreate('t')->run($this->conn);
     $result = r\table('t')->insert(array('id' => 1, 'key' => 'val'))->run($this->conn, array('noreply' => true));
     if (!is_null($result)) {
         echo "Noreply query returned a result\n";
     }
     $this->checkQueryResult(r\table('t')->get(1)->attr('key'), 'val');
     r\dbDrop('NoreplyTest')->run($this->conn);
 }
Example #8
0
 protected function create()
 {
     r\dbCreate('Geo')->run($this->conn);
     r\db('Geo')->tableCreate('geo')->run($this->conn);
     $geoTable = r\db('Geo')->table('geo');
     $geoTable->insert(array('geo' => r\point(1.0, 1.0)))->run($this->conn);
     $geoTable->insert(array('geo' => r\point(1.0, 0.0)))->run($this->conn);
     $geoTable->indexCreateGeo('geo')->run($this->conn);
     $geoTable->indexCreateMultiGeo('mgeo', function ($x) {
         return r\expr(array($x('geo')));
     })->run($this->conn);
     $geoTable->indexWait('geo')->run($this->conn);
     $geoTable->indexWait('mgeo')->run($this->conn);
 }
Example #9
0
 protected function create()
 {
     r\dbCreate('Joins')->run($this->conn);
     r\db('Joins')->tableCreate('t1')->run($this->conn);
     r\db('Joins')->tableCreate('t2')->run($this->conn);
     $t1 = r\db('Joins')->table('t1');
     $t2 = r\db('Joins')->table('t2');
     $t1->indexCreate('other')->run($this->conn);
     $t2->indexCreate('other')->run($this->conn);
     $t1->insert(array('id' => 1, 'other' => 'a'))->run($this->conn);
     $t1->insert(array('id' => 2, 'other' => 'a'))->run($this->conn);
     $t1->insert(array('id' => 3, 'other' => 'b'))->run($this->conn);
     $t2->insert(array('id' => 'a', 'other' => 1))->run($this->conn);
     $t2->insert(array('id' => 'b', 'other' => 1))->run($this->conn);
     $t2->insert(array('id' => 'c', 'other' => 5))->run($this->conn);
 }
Example #10
0
<?php

include __DIR__ . '../../../vendor/autoload.php';
$conn = r\connect(getenv('RDB_HOST'), getenv('RDB_PORT'));
$db = getenv('RDB_DB');
$res = r\dbCreate($db)->run($conn);
if ($res['dbs_created'] !== 1.0) {
    echo 'Error creating DB' . PHP_EOL;
    exit;
}
r\db($db)->tableCreate('marvel', array('primary_key' => 'superhero'))->run($conn);
r\db($db)->tableCreate('dc_universe', array('primary_key' => 'name'))->run($conn);
r\db($db)->tableCreate('t5000', array('durability' => 'soft'))->run($conn);
$tables = array('t1', 't2', 'geo');
foreach ($tables as $table) {
    r\db($db)->tableCreate($table)->run($conn);
}
r\db($db)->table('t1')->indexCreate('other')->run($conn);
r\db($db)->table('t2')->indexCreate('other')->run($conn);
$geoTable = r\db($db)->table('geo');
$geoTable->indexCreateGeo('geo')->run($conn);
$geoTable->indexCreateMultiGeo('mgeo', function ($x) {
    return r\expr(array($x('geo')));
})->run($conn);
$geoTable->indexWait('geo')->run($conn);
$geoTable->indexWait('mgeo')->run($conn);
Example #11
0
 public function testDrop()
 {
     \r\dbCreate($this->db)->run($this->conn);
     $res = \r\dbDrop($this->db)->pluck('dbs_dropped')->run($this->conn);
     $this->assertEquals(array('dbs_dropped' => 1.0), (array) $res);
 }
Example #12
0
 protected function create()
 {
     r\dbCreate('Control')->run($this->conn);
     r\db('Control')->tableCreate('t1')->run($this->conn);
 }
Example #13
0
 public function run()
 {
     $this->checkQueryResult(r\dbCreate('dbTest'), array('created' => 1.0));
     $this->checkQueryResult(r\dbDrop('dbTest'), array('dropped' => 1.0));
 }