| 44 | namespace fs { |
| 45 | |
| 46 | TEST(TestHdfsOptions, FromUri) { |
| 47 | HdfsOptions options; |
| 48 | Uri uri; |
| 49 | |
| 50 | ASSERT_OK(uri.Parse("hdfs://localhost")); |
| 51 | ASSERT_OK_AND_ASSIGN(options, HdfsOptions::FromUri(uri)); |
| 52 | ASSERT_EQ(options.replication, 3); |
| 53 | ASSERT_EQ(options.host(), "hdfs://localhost"); |
| 54 | ASSERT_EQ(options.port(), 0); |
| 55 | ASSERT_EQ(options.user(), ""); |
| 56 | |
| 57 | ASSERT_OK(uri.Parse("hdfs://otherhost:9999/?replication=2&kerb_ticket=kerb.ticket")); |
| 58 | ASSERT_OK_AND_ASSIGN(options, HdfsOptions::FromUri(uri)); |
| 59 | ASSERT_EQ(options.replication, 2); |
| 60 | ASSERT_EQ(options.kerb_ticket(), "kerb.ticket"); |
| 61 | ASSERT_EQ(options.host(), "hdfs://otherhost"); |
| 62 | ASSERT_EQ(options.port(), 9999); |
| 63 | ASSERT_EQ(options.user(), ""); |
| 64 | |
| 65 | ASSERT_OK(uri.Parse("hdfs://otherhost:9999/?hdfs_token=hdfs_token_ticket")); |
| 66 | ASSERT_OK_AND_ASSIGN(options, HdfsOptions::FromUri(uri)); |
| 67 | ASSERT_EQ(options.host(), "hdfs://otherhost"); |
| 68 | ASSERT_EQ(options.port(), 9999); |
| 69 | ASSERT_EQ(options.extra_conf().at("hdfs_token"), "hdfs_token_ticket"); |
| 70 | |
| 71 | ASSERT_OK(uri.Parse("viewfs://other-nn/mypath/myfile")); |
| 72 | ASSERT_OK_AND_ASSIGN(options, HdfsOptions::FromUri(uri)); |
| 73 | ASSERT_EQ(options.host(), "viewfs://other-nn"); |
| 74 | ASSERT_EQ(options.port(), 0); |
| 75 | ASSERT_EQ(options.user(), ""); |
| 76 | } |
| 77 | |
| 78 | class HadoopFileSystemTestMixin { |
| 79 | public: |
nothing calls this directly
no test coverage detected