Пример #1
0
 def exists(self):
     """
     Tests whether a file exists.
     :rtype : bool
     :return: True if the file exists else False
     """
     return fs.is_file_exists(self.path)
Пример #2
0
 def exists(self):
     """
     Tests whether a file exists.
     :rtype : bool
     :return: True if the file exists else False
     """
     return fs.is_file_exists(self.path)
Пример #3
0
 def test_is_file_not_exists_command(self):
     # shell_client.EXECUTOR = self._executor_to_fail
     self.assertFalse(
         hdfs_client.is_file_exists(
             "/tmp/data.txt",
             executor=lambda cmd, *args: self._assert_command_generation(
                 "hadoop fs -test -e /tmp/data.txt", status=-1)
             (cmd, *args)))
Пример #4
0
 def test_is_file_not_exists_command(self):
     # shell_client.EXECUTOR = self._executor_to_fail
     self.assertFalse(
         hdfs_client.is_file_exists(
             "/tmp/data.txt",
             executor=lambda cmd, *args: self._assert_command_generation(
                 "hadoop fs -test -e /tmp/data.txt", status=-1
             )(cmd, *args),
         )
     )
Пример #5
0
 def test_create_table(self):
     files = self.temp_file(msg="hello,world")
     try:
         msg = "create database if not EXISTS testdb;"
         self.assertTrue(Hive.load_queries_from_string(msg).run().is_ok())
         msg = "create table some_table(strings STRING)" \
               "ROW FORMAT DELIMITED " \
               "FIELDS TERMINATED BY ','" \
               "STORED AS TEXTFILE " \
               "Location '/tmp/hive_table';"
         hive = Hive.load_queries_from_string(msg).use_database("testdb")
         self.assertTrue(hive.use_database("testdb").run().is_ok(), " create table")
         msg = "LOAD DATA LOCAL INPATH '{0}' OVERWRITE INTO TABLE some_table;".format(files)
         hive = Hive.load_queries_from_string(msg).use_database("testdb")
         self.assertTrue(hive.run().is_ok(), "load data in table")
         self.assertTrue(hdfs.is_file_exists("/tmp/hive_table"), "check tables")
     finally:
         Hive.load_queries_from_string("drop table some_table;").use_database("testdb").run()
         Hive.load_queries_from_string("drop database testdb;").use_database("testdb").run()
         self.delete_local(files)
         self.delete_file_in_hdfs()
Пример #6
0
 def test_is_file_exists_command_generator(self):
     hdfs_client.is_file_exists(
         "/tmp/data.txt",
         executor=lambda cmd, *args: self._assert_command_generation("hadoop fs -test -e /tmp/data.txt")(cmd, *args),
     )
Пример #7
0
 def test_is_file_exists_command_generator(self):
     hdfs_client.is_file_exists(
         "/tmp/data.txt",
         executor=lambda cmd, *args: self._assert_command_generation(
             "hadoop fs -test -e /tmp/data.txt")(cmd, *args))