Ejemplo n.º 1
0
 public function test_should_import_mirror_to_ib_works_fine()
 {
     self::cleanTable('default', 'route_info');
     $route = \Myfox\App\Model\Router::set('mirror_v2', array());
     $route = reset($route);
     $route = reset($route);
     $task = new \Myfox\App\Task\Import(10, array('table' => 'mirror_v2', 'route' => '', 'file' => realpath(__DIR__ . '/resource/mirror_import_data_file.txt'), 'bucket' => $route['table'], 'hosts' => '4,5', 'engine' => 'BRIGHTHOUSE'), '999999,-98');
     $this->assertEquals(Task::WAIT, $task->execute());
     $this->assertEquals(Task::SUCC, $task->wait());
     $where = \Myfox\App\Model\Router::instance('mirror_v2')->where(null);
     $route = self::$mysql->getOne(self::$mysql->query(sprintf("SELECT hosts_list FROM %s WHERE table_name='mirror_v2' AND real_table='%s' AND route_flag = %d", $where['table'], $route['table'], \Myfox\App\Model\Router::FLAG_IMPORT_END)));
     $route = array_filter(explode(',', trim($route, '{}$')));
     sort($route);
     $this->assertEquals(array(4, 5), $route);
     $this->assertEquals(true, self::check_table_exists('ibtest_1', 'mirror_v2_0.t_1_0'));
     $this->assertEquals(true, self::check_table_exists('ibtest_1', 'mirror_v2_0.t_1_1'));
     $this->assertEquals(true, self::check_table_exists('ibtest_1', 'mirror_v2_0.t_1_2'));
     $this->assertEquals(true, self::check_table_exists('ibtest_2', 'mirror_v2_0.t_1_0'));
     $this->assertEquals(true, self::check_table_exists('ibtest_2', 'mirror_v2_0.t_1_1'));
     $this->assertEquals(true, self::check_table_exists('ibtest_2', 'mirror_v2_0.t_1_2'));
 }