Negative test: invalid user name. Copied from FileTest, so this normally would succeed, but here a bogus user name is specified. So we check for fetch failure. This won't work on Windows because file ownership and permissions support isn't implemented, see MESOS-3176.
| 382 | // This won't work on Windows because file ownership and permissions |
| 383 | // support isn't implemented, see MESOS-3176. |
| 384 | TEST_F_TEMP_DISABLED_ON_WINDOWS(FetcherTest, InvalidUser) |
| 385 | { |
| 386 | string fromDir = path::join(os::getcwd(), "from"); |
| 387 | ASSERT_SOME(os::mkdir(fromDir)); |
| 388 | string testFile = path::join(fromDir, "test"); |
| 389 | EXPECT_SOME(os::write(testFile, "data")); |
| 390 | |
| 391 | string localFile = path::join(os::getcwd(), "test"); |
| 392 | EXPECT_FALSE(os::exists(localFile)); |
| 393 | |
| 394 | slave::Flags flags = CreateSlaveFlags(); |
| 395 | |
| 396 | ContainerID containerId; |
| 397 | containerId.set_value(id::UUID::random().toString()); |
| 398 | |
| 399 | CommandInfo commandInfo; |
| 400 | commandInfo.set_user(id::UUID::random().toString()); |
| 401 | |
| 402 | CommandInfo::URI* uri = commandInfo.add_uris(); |
| 403 | uri->set_value(uri::from_path(testFile)); |
| 404 | |
| 405 | Fetcher fetcher(flags); |
| 406 | |
| 407 | Future<Nothing> fetch = fetcher.fetch( |
| 408 | containerId, commandInfo, os::getcwd(), None()); |
| 409 | AWAIT_FAILED(fetch); |
| 410 | |
| 411 | // See FetcherProcess::fetch(), the message must mention "chown" in |
| 412 | // this case. |
| 413 | EXPECT_TRUE(strings::contains(fetch.failure(), "chown")); |
| 414 | |
| 415 | EXPECT_FALSE(os::exists(localFile)); |
| 416 | |
| 417 | verifyMetrics(0, 1); |
| 418 | } |
| 419 | |
| 420 | |
| 421 | // Negative test: URI leading to non-existing file. Copied from FileTest, |
nothing calls this directly
no test coverage detected