def test_drop(self):
     tempobj.register_temp_table(self.odps, 'non_exist_table')
     tempobj.register_temp_model(self.odps, 'non_exist_model')
     tempobj.register_temp_function(self.odps, 'non_exist_function')
     tempobj.register_temp_resource(self.odps, 'non_exist_resource')
     tempobj.register_temp_volume_partition(self.odps, ('non_exist_vol', 'non_exist_vol_part'))
     tempobj.clean_stored_objects(self.odps)
 def test_cleanup(self):
     self.odps.execute_sql('drop table if exists {0}'.format(TEMP_TABLE_NAME))
     self.odps.execute_sql('create table {0} (col1 string) lifecycle 1'.format(TEMP_TABLE_NAME))
     tempobj.register_temp_table(self.odps, TEMP_TABLE_NAME)
     tempobj.clean_objects(self.odps)
     sleep(10)
     assert not self.odps.exist_table(TEMP_TABLE_NAME)
    def test_multi_process(self):
        self.odps.execute_sql(
            'drop table if exists {0}'.format(TEMP_TABLE_NAME))

        self.odps.execute_sql(
            'create table {0} (col1 string) lifecycle 1'.format(
                TEMP_TABLE_NAME))
        tempobj.register_temp_table(self.odps, TEMP_TABLE_NAME)

        script = SECONDARY_PROCESS_CODE.format(odps_info=self._get_odps_json(),
                                               import_paths=json.dumps(
                                                   sys.path))

        script_name = tempfile.gettempdir() + os.sep + 'tmp_' + str(
            os.getpid()) + '_secondary_script.py'
        with open(script_name, 'w') as script_file:
            script_file.write(script)
            script_file.close()
        env = copy.deepcopy(os.environ)
        env.update({'WAIT_CLEANUP': '1'})
        subprocess.call([sys.executable, script_name], close_fds=True, env=env)

        sleep(10)

        assert self.odps.exist_table(TEMP_TABLE_NAME)
        self.odps.run_sql('drop table {0}'.format(TEMP_TABLE_NAME))
 def test_cleanup(self):
     self.odps.execute_sql('drop table if exists {0}'.format(TEMP_TABLE_NAME))
     self.odps.execute_sql('create table {0} (col1 string) lifecycle 1'.format(TEMP_TABLE_NAME))
     tempobj.register_temp_table(self.odps, TEMP_TABLE_NAME)
     tempobj._obj_repos._exec_cleanup_script()
     sleep(5)
     assert not self.odps.exist_table(TEMP_TABLE_NAME)
Esempio n. 5
0
    def testCleanupScript(self):
        self.odps.execute_sql('drop table if exists {0}'.format(TEMP_TABLE_NAME))
        self.odps.execute_sql('create table {0} (col1 string) lifecycle 1'.format(TEMP_TABLE_NAME))
        tempobj.register_temp_table(self.odps, TEMP_TABLE_NAME)
        tempobj._obj_repos._exec_cleanup_script()

        sleep(10)
        assert not self.odps.exist_table(TEMP_TABLE_NAME)
    def test_multi_process(self):
        sleep(5)

        self.odps.execute_sql('drop table if exists {0}'.format(TEMP_TABLE_NAME))

        self.odps.execute_sql('create table {0} (col1 string) lifecycle 1'.format(TEMP_TABLE_NAME))
        tempobj.register_temp_table(self.odps, TEMP_TABLE_NAME)

        script = SECONDARY_PROCESS_CODE.format(odps_info=self._get_odps_json())

        script_name = tempfile.gettempdir() + os.sep + 'tmp_' + str(os.getpid()) + '_secondary_script.py'
        with open(script_name, 'w') as script_file:
            script_file.write(script)
            script_file.close()
        subprocess.call([sys.executable, script_name], close_fds=True)

        assert self.odps.exist_table(TEMP_TABLE_NAME)
    def test_multi_process(self):
        self.odps.execute_sql('drop table if exists {0}'.format(TEMP_TABLE_NAME))

        self.odps.execute_sql('create table {0} (col1 string) lifecycle 1'.format(TEMP_TABLE_NAME))
        tempobj.register_temp_table(self.odps, TEMP_TABLE_NAME)

        script = SECONDARY_PROCESS_CODE.format(odps_info=self._get_odps_json(), import_paths=json.dumps(sys.path))

        script_name = tempfile.gettempdir() + os.sep + 'tmp_' + str(os.getpid()) + '_secondary_script.py'
        with open(script_name, 'w') as script_file:
            script_file.write(script)
            script_file.close()
        env = copy.deepcopy(os.environ)
        env.update({'WAIT_CLEANUP': '1'})
        subprocess.call([sys.executable, script_name], close_fds=True, env=env)

        sleep(10)

        assert self.odps.exist_table(TEMP_TABLE_NAME)
        self.odps.run_sql('drop table {0}'.format(TEMP_TABLE_NAME))
Esempio n. 8
0
    def test_multi_process(self):
        sleep(5)

        self.odps.execute_sql(
            'drop table if exists {0}'.format(TEMP_TABLE_NAME))

        self.odps.execute_sql(
            'create table {0} (col1 string) lifecycle 1'.format(
                TEMP_TABLE_NAME))
        tempobj.register_temp_table(self.odps, TEMP_TABLE_NAME)

        script = SECONDARY_PROCESS_CODE.format(odps_info=self._get_odps_json())

        script_name = tempfile.gettempdir() + os.sep + 'tmp_' + str(
            os.getpid()) + '_secondary_script.py'
        with open(script_name, 'w') as script_file:
            script_file.write(script)
            script_file.close()
        subprocess.call([sys.executable, script_name], close_fds=True)

        assert self.odps.exist_table(TEMP_TABLE_NAME)
 def test_drop(self):
     tempobj.register_temp_table(self.odps, 'non_exist_table')
     tempobj.register_temp_model(self.odps, 'non_exist_model')
     tempobj.register_temp_volume_partition(self.odps, ('non_exist_vol', 'non_exist_vol_part'))
     tempobj.clean_objects(self.odps)