Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B4DB8200B84 for ; Tue, 6 Sep 2016 04:56:41 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B3482160ACC; Tue, 6 Sep 2016 02:56:41 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 08648160ABC for ; Tue, 6 Sep 2016 04:56:40 +0200 (CEST) Received: (qmail 90454 invoked by uid 500); 6 Sep 2016 02:56:40 -0000 Mailing-List: contact commits-help@mesos.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mesos.apache.org Delivered-To: mailing list commits@mesos.apache.org Received: (qmail 90443 invoked by uid 99); 6 Sep 2016 02:56:40 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 Sep 2016 02:56:40 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 03AFCDFFB9; Tue, 6 Sep 2016 02:56:40 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jieyu@apache.org To: commits@mesos.apache.org Message-Id: <57af34372cc44a37a9065d404ef79d36@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: mesos git commit: Added tests to invoke the fetcher plugins by name. Date: Tue, 6 Sep 2016 02:56:40 +0000 (UTC) archived-at: Tue, 06 Sep 2016 02:56:41 -0000 Repository: mesos Updated Branches: refs/heads/master 9157c7029 -> b4441a4cb Added tests to invoke the fetcher plugins by name. Add a test case for each of the existing fetcher plugins to invoke them by name. Review: https://reviews.apache.org/r/50958/ Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b4441a4c Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b4441a4c Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b4441a4c Branch: refs/heads/master Commit: b4441a4cb29776171333b3fae0c97e5d895aba4e Parents: 9157c70 Author: Srinivas Brahmaroutu Authored: Mon Sep 5 19:40:59 2016 -0700 Committer: Jie Yu Committed: Mon Sep 5 19:56:32 2016 -0700 ---------------------------------------------------------------------- src/tests/uri_fetcher_tests.cpp | 96 ++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/b4441a4c/src/tests/uri_fetcher_tests.cpp ---------------------------------------------------------------------- diff --git a/src/tests/uri_fetcher_tests.cpp b/src/tests/uri_fetcher_tests.cpp index 072c09b..3c1bd33 100644 --- a/src/tests/uri_fetcher_tests.cpp +++ b/src/tests/uri_fetcher_tests.cpp @@ -129,6 +129,26 @@ TEST_F(CurlFetcherPluginTest, CURL_InvalidUri) } +// This test verifies invoking 'fetch' by plugin name. +TEST_F(CurlFetcherPluginTest, CURL_InvokeFetchByName) +{ + URI uri = uri::http( + stringify(server.self().address.ip), + "/TestHttpServer/test", + server.self().address.port); + + EXPECT_CALL(server, test(_)) + .WillOnce(Return(http::OK("test"))); + + Try> fetcher = uri::fetcher::create(); + ASSERT_SOME(fetcher); + + AWAIT_READY(fetcher.get()->fetch(uri, os::getcwd(), "curl")); + + EXPECT_TRUE(os::exists(path::join(os::getcwd(), "test"))); +} + + class HadoopFetcherPluginTest : public TemporaryDirectoryTest { public: @@ -207,6 +227,29 @@ TEST_F(HadoopFetcherPluginTest, FetchNonExistingFile) } +// This test verifies invoking 'fetch' by plugin name. +TEST_F(HadoopFetcherPluginTest, InvokeFetchByName) +{ + string file = path::join(os::getcwd(), "file"); + + ASSERT_SOME(os::write(file, "abc")); + + URI uri = uri::hdfs(file); + + uri::fetcher::Flags flags; + flags.hadoop_client = hadoop; + + Try> fetcher = uri::fetcher::create(flags); + ASSERT_SOME(fetcher); + + string dir = path::join(os::getcwd(), "dir"); + + AWAIT_READY(fetcher.get()->fetch(uri, dir, "hadoop")); + + EXPECT_SOME_EQ("abc", os::read(path::join(dir, "file"))); +} + + // TODO(jieyu): Expose this constant so that other docker related // tests can use this as well. static constexpr char DOCKER_REGISTRY_HOST[] = "registry-1.docker.io"; @@ -293,6 +336,37 @@ TEST_F(DockerFetcherPluginTest, INTERNET_CURL_FetchImage) } +// This test verifies invoking 'fetch' by plugin name. +TEST_F(DockerFetcherPluginTest, INTERNET_CURL_InvokeFetchByName) +{ + URI uri = uri::docker::image( + "library/busybox", + "latest", + DOCKER_REGISTRY_HOST); + + Try> fetcher = uri::fetcher::create(); + ASSERT_SOME(fetcher); + + string dir = path::join(os::getcwd(), "dir"); + + AWAIT_READY_FOR(fetcher.get()->fetch(uri, dir, "docker"), Seconds(60)); + + Try _manifest = os::read(path::join(dir, "manifest")); + ASSERT_SOME(_manifest); + + Try manifest = + docker::spec::v2::parse(_manifest.get()); + + ASSERT_SOME(manifest); + EXPECT_EQ("library/busybox", manifest->name()); + EXPECT_EQ("latest", manifest->tag()); + + for (int i = 0; i < manifest->fslayers_size(); i++) { + EXPECT_TRUE(os::exists(path::join(dir, manifest->fslayers(i).blobsum()))); + } +} + + class CopyFetcherPluginTest : public TemporaryDirectoryTest {}; @@ -335,6 +409,28 @@ TEST_F(CopyFetcherPluginTest, FetchNonExistingFile) } +// This test verifies invoking 'fetch' by plugin name. +TEST_F(CopyFetcherPluginTest, InvokeFetchByName) +{ + const string file = path::join(os::getcwd(), "file"); + + ASSERT_SOME(os::write(file, "abc")); + + // Create a URI for the test file. + const URI uri = uri::file(file); + + // Use the file fetcher to fetch the URI. + Try> fetcher = uri::fetcher::create(); + ASSERT_SOME(fetcher); + + const string dir = path::join(os::getcwd(), "dir"); + + AWAIT_READY(fetcher.get()->fetch(uri, dir, "copy")); + + // Validate the fetched file's content. + EXPECT_SOME_EQ("abc", os::read(path::join(dir, "file"))); +} + // TODO(jieyu): Add Docker fetcher plugin tests to test with a local // registry server (w/ or w/o authentication).