コード例 #1
0
 def test_execute_VerticaManager_clone_schema_call(self):
     cv = self.config_value
     tf = make_tempfile()
     tempfile_write(tf, self.ptn_file_contents)
     rh = trh.RollbackHandler(datacfg_file="foo", envcfg_file="bar",
                              resources_file="baz.zip", partitions_file=tf.name)
     rh.execute()
     vmgr = self.mock_vtica.return_value
     vmgr.clone_schema.assert_called_with(cv, cv, cv, "%s__rollback__" % cv)
コード例 #2
0
 def test_execute_exception(self):
     tf = make_tempfile()
     tempfile_write(tf, self.ptn_file_contents)
     vmgr = self.mock_vtica.return_value
     vmgr.truncate.side_effect = Exception()
     rh = trh.RollbackHandler(datacfg_file="foo", envcfg_file="bar",
                              resources_file="baz.zip", partitions_file=tf.name)
     with self.assertRaises(Exception):
         rh.execute()
コード例 #3
0
 def test_execute_HdfsManager_path_exists_calls(self):
     cv = self.config_value
     tf = make_tempfile()
     tempfile_write(tf, self.ptn_file_contents)
     rh = trh.RollbackHandler(datacfg_file="foo", envcfg_file="bar",
                              resources_file="baz.zip", partitions_file=tf.name)
     rh.execute()
     hdfs_paths = ["%s/%s" % (cv, ptn) for ptn in self.ptns]
     path_exist_calls = [mock.call(s) for s in hdfs_paths]
     hdfs_mgr = self.mock_hdfs.return_value
     self.assertEqual(path_exist_calls, hdfs_mgr.path_exists.call_args_list)
コード例 #4
0
 def test_execute_MetadataManager_delete_partition_calls(self):
     cv = self.config_value
     tf = make_tempfile()
     tempfile_write(tf, self.ptn_file_contents)
     rh = trh.RollbackHandler(datacfg_file="foo", envcfg_file="bar",
                              resources_file="baz.zip", partitions_file=tf.name)
     rh.execute()
     md_delete_calls = [mock.call(cv, mdcolname="hive_last_partition", mdcolvalue=p)
                        for p in self.ptns]
     md_mgr = self.mock_mm.return_value
     md_mgr.delete.assert_has_calls(md_delete_calls)
コード例 #5
0
 def test_execute_HiveManager_drop_partition_calls(self):
     tf = make_tempfile()
     tempfile_write(tf, self.ptn_file_contents)
     rh = trh.RollbackHandler(datacfg_file="foo", envcfg_file="bar",
                              resources_file="baz.zip", partitions_file=tf.name)
     rh.execute()
     ptn_strs = ["year=%s, month=%s, day=%s, hour=%s, part=%s" \
                 % tuple(p.split("/")) for p in self.ptns]
     drop_ptn_calls = [mock.call(ps) for ps in ptn_strs]
     hive_mgr = self.mock_hive.return_value
     hive_mgr.drop_partition.assert_has_calls(drop_ptn_calls)
コード例 #6
0
 def test_execute_VerticaManager_truncate_calls(self):
     cv = self.config_value
     tf = make_tempfile()
     tempfile_write(tf, self.ptn_file_contents)
     src_schema, src_table, rb_schema, rb_table = cv, cv, cv, "%s__rollback__" % cv
     rh = trh.RollbackHandler(datacfg_file="foo", envcfg_file="bar",
                              resources_file="baz.zip", partitions_file=tf.name)
     rh.execute()
     truncate_calls = [mock.call(rb_schema, rb_table) for p in self.ptns]
     vmgr = self.mock_vtica.return_value
     vmgr.truncate.assert_has_calls(truncate_calls)
コード例 #7
0
 def test_execute_LoadHandler_vload_copy_direct_calls(self, mock_vcopy):
     cv = self.config_value
     tf = make_tempfile()
     tempfile_write(tf, self.ptn_file_contents)
     src_schema, src_table, rb_schema, rb_table = cv, cv, cv, "%s__rollback__" % cv
     rh = trh.RollbackHandler(datacfg_file="foo", envcfg_file="bar",
                              resources_file="baz.zip", partitions_file=tf.name)
     rh.execute()
     copy_calls = [mock.call(p, rb_schema, rb_table, mode="direct")
                   for p in self.ptns]
     mock_vcopy.assert_has_calls(copy_calls)