You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2017/08/22 22:27:45 UTC
[1/6] mesos git commit: Rewrited rules for generating Protobuf and
gRPC code.
Repository: mesos
Updated Branches:
refs/heads/master 40906e31a -> 38a889cb2
Rewrited rules for generating Protobuf and gRPC code.
Made code generation for Proobuf and gRPC more generic and changed the
variable names in \`Makefile.am\` to follow the same style in Mesos.
Review: https://reviews.apache.org/r/61600/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/5abd9640
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/5abd9640
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/5abd9640
Branch: refs/heads/master
Commit: 5abd9640e1cddb7999a41b166ad7a2702e09db47
Parents: 40906e3
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Tue Aug 22 14:27:44 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Aug 22 15:20:29 2017 -0700
----------------------------------------------------------------------
3rdparty/libprocess/Makefile.am | 51 +++++++++++++++++-------------------
1 file changed, 24 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/5abd9640/3rdparty/libprocess/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/Makefile.am b/3rdparty/libprocess/Makefile.am
index c2fa3f9..6b2fdff 100644
--- a/3rdparty/libprocess/Makefile.am
+++ b/3rdparty/libprocess/Makefile.am
@@ -325,27 +325,15 @@ libprocess_tests_LDADD = \
libprocess.la
if ENABLE_GRPC
-libprocess_tests_SOURCES += \
- src/tests/grpc_tests.cpp \
+libprocess_tests_SOURCES += \
+ src/tests/grpc_tests.cpp \
src/tests/grpc_tests.proto
-GRPC_TESTS_GENERATED_SOURCES = \
- grpc_tests.pb.h \
- grpc_tests.pb.cc \
- grpc_tests.grpc.pb.h \
- grpc_tests.grpc.pb.cc
-
-# Use a pseudo-target here to avoid multiple protoc invocations.
-$(GRPC_TESTS_GENERATED_SOURCES): grpc_tests_proto
-
-grpc_tests_proto: src/tests/grpc_tests.proto \
- $(PROTOBUF)-build-stamp \
- $(GRPC)-build-stamp
- $(PROTOC) $< \
- -I$(srcdir)/src/tests \
- --cpp_out=$(builddir) \
- --grpc_out=$(builddir) \
- --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN)
+GRPC_TESTS_PROTOS = \
+ grpc_tests.grpc.pb.cc \
+ grpc_tests.grpc.pb.h \
+ grpc_tests.pb.cc \
+ grpc_tests.pb.h
endif
if ENABLE_SSL
@@ -396,15 +384,24 @@ libprocess_tests_LDADD += \
$(LIB_EV)
endif
-BUILT_SOURCES = \
- $(BUNDLED_DEPS) \
- $(GRPC_TESTS_GENERATED_SOURCES)
+BUILT_SOURCES = \
+ $(BUNDLED_DEPS)
+
+nodist_libprocess_tests_SOURCES = \
+ $(GRPC_TESTS_PROTOS)
+
+CLEANFILES = \
+ $(GRPC_TESTS_PROTOS)
+
+
+# Targets for generating C++ protocol buffer and gRPC code for tests.
+%.pb.cc %.pb.h: src/tests/%.proto
+ $(PROTOC) -I$(^D) --cpp_out=. $^
-nodist_libprocess_tests_SOURCES = \
- $(GRPC_TESTS_GENERATED_SOURCES)
+%.grpc.pb.cc %.grpc.pb.h: src/tests/%.proto
+ $(PROTOC) -I$(^D) --grpc_out=. $^ \
+ --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN)
-CLEANFILES = \
- $(GRPC_TESTS_GENERATED_SOURCES)
# We use a check-local target for now to avoid the parallel test
# runner that ships with newer versions of autotools.
@@ -413,7 +410,7 @@ CLEANFILES = \
check-local: tests
$(TEST_DRIVER) ./libprocess-tests
-tests: all $(BUNDLED_DEPS)
+tests: all $(BUNDLED_DEPS) $(GRPC_TESTS_PROTOS)
$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
# TODO(benh): Fix shared builds (tests need libglog, libev, etc).
[6/6] mesos git commit: Added Autotools rules to build the CSI client
module in Mesos.
Posted by ji...@apache.org.
Added Autotools rules to build the CSI client module in Mesos.
Review: https://reviews.apache.org/r/61706/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/38a889cb
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/38a889cb
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/38a889cb
Branch: refs/heads/master
Commit: 38a889cb28b52eff67e642ac346281a3f10195d2
Parents: 4073428
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Tue Aug 22 14:32:24 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Aug 22 15:20:47 2017 -0700
----------------------------------------------------------------------
3rdparty/Makefile.am | 7 ++++++
3rdparty/versions.am | 1 +
src/Makefile.am | 63 ++++++++++++++++++++++++++++++++++++++---------
3 files changed, 59 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/38a889cb/3rdparty/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/Makefile.am b/3rdparty/Makefile.am
index 2182837..687f52d 100644
--- a/3rdparty/Makefile.am
+++ b/3rdparty/Makefile.am
@@ -50,6 +50,7 @@ include versions.am
BOOST = boost-$(BOOST_VERSION)
CONCURRENTQUEUE = concurrentqueue-$(CONCURRENTQUEUE_VERSION)
+CSI = csi-$(CSI_VERSION)
ELFIO = elfio-$(ELFIO_VERSION)
GLOG = glog-$(GLOG_VERSION)
GOOGLETEST = googletest-release-$(GOOGLETEST_VERSION)
@@ -71,6 +72,7 @@ ZOOKEEPER = zookeeper-$(ZOOKEEPER_VERSION)
EXTRA_DIST = \
$(BOOST).tar.gz \
$(CONCURRENTQUEUE).tar.gz \
+ $(CSI).tar.gz \
$(ELFIO).tar.gz \
$(GLOG).tar.gz \
$(GOOGLETEST).tar.gz \
@@ -112,6 +114,7 @@ EXTRA_DIST += \
CLEAN_EXTRACTED = \
$(BOOST) \
$(CONCURRENTQUEUE) \
+ $(CSI) \
$(ELFIO) \
$(GLOG) \
$(GOOGLETEST) \
@@ -332,6 +335,10 @@ $(GRPC)-build-stamp:
endif
endif
+if ENABLE_GRPC
+ALL_LOCAL += $(CSI)-stamp
+endif
+
# Convenience library for gmock/gtest.
check_LTLIBRARIES = libgmock.la
nodist_libgmock_la_SOURCES = gmock_sources.cc
http://git-wip-us.apache.org/repos/asf/mesos/blob/38a889cb/3rdparty/versions.am
----------------------------------------------------------------------
diff --git a/3rdparty/versions.am b/3rdparty/versions.am
index 82d66be..cbab26d 100644
--- a/3rdparty/versions.am
+++ b/3rdparty/versions.am
@@ -21,6 +21,7 @@
BOOST_VERSION = 1.53.0
CONCURRENTQUEUE_VERSION = 1.0.0-beta
+CSI_VERSION = 0.1.0
ELFIO_VERSION = 3.2
GLOG_VERSION = 0.3.3
GOOGLETEST_VERSION = 1.8.0
http://git-wip-us.apache.org/repos/asf/mesos/blob/38a889cb/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 87cc395..dffa608 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,6 +24,7 @@ include ../3rdparty/versions.am
# TODO(charles): Move these into an included automakefile and have
# them include $(top_builddir) as appropriate.
+CSI = 3rdparty/csi-$(CSI_VERSION)
LEVELDB = 3rdparty/leveldb-$(LEVELDB_VERSION)
PIP = 3rdparty/pip-$(PIP_VERSION)
SETUPTOOLS = 3rdparty/setuptools-$(SETUPTOOLS_VERSION)
@@ -58,15 +59,6 @@ testlibexecdir = $(pkglibexecdir)/tests
pkgmoduledir = $(pkglibdir)/modules
relative_pkgmoduledir = $(PACKAGE)/modules
-if WITH_BUNDLED_PROTOBUF
-# Protocol buffer compiler.
-PROTOC = ../$(PROTOBUF)/src/protoc
-else
-PROTOC = @PROTOCOMPILER@
-endif
-
-PROTOCFLAGS = -I$(top_srcdir)/include -I$(srcdir)
-
# Initialize variables here so we can use += operator everywhere else.
lib_LTLIBRARIES =
pkgmodule_LTLIBRARIES =
@@ -176,6 +168,7 @@ endif
if ENABLE_GRPC
if WITH_BUNDLED_GRPC
+MESOS_CPPFLAGS += -I../$(GRPC)/include
LIB_GRPC = ../$(GRPC)/libs/opt/libgrpc++.a \
../$(GRPC)/libs/opt/libgrpc.a \
../$(GRPC)/libs/opt/libgpr.a \
@@ -218,9 +211,11 @@ endif
if WITH_BUNDLED_PROTOBUF
MESOS_CPPFLAGS += -I../$(PROTOBUF)/src
LIB_PROTOBUF = ../$(PROTOBUF)/src/libprotobuf.la
+PROTOC = ../$(PROTOBUF)/src/protoc
else
LIB_PROTOBUF = -lprotobuf
LDADD += -lprotobuf
+PROTOC = @PROTOCOMPILER@
endif
if WITH_BUNDLED_STOUT
@@ -238,6 +233,12 @@ endif
MESOS_CPPFLAGS += -DHAS_AUTHENTICATION=1
+# Set up include paths for the protocol buffer compiler.
+PROTOCFLAGS = -I$(top_srcdir)/include -I$(srcdir)
+if ENABLE_GRPC
+PROTOCFLAGS += -I../$(CSI)
+endif
+
# README: we build the Mesos library out of a collection of
# convenience libraries (that is, libraries that do not get installed
# but we can use as building blocks to vary compile flags as necessary
@@ -363,6 +364,14 @@ CXX_PROTOS += \
slave/containerizer/mesos/isolators/network/cni/spec.pb.cc \
slave/containerizer/mesos/isolators/network/cni/spec.pb.h
+if ENABLE_GRPC
+CXX_CSI_PROTOS = \
+ csi/csi.grpc.pb.cc \
+ csi/csi.grpc.pb.h \
+ csi/csi.pb.cc \
+ csi/csi.pb.h
+endif
+
CXX_LOG_PROTOS = \
messages/log.pb.cc \
messages/log.pb.h
@@ -402,6 +411,7 @@ V1_PYTHON_PROTOS = \
python/interface/src/mesos/v1/interface/scheduler_pb2.py
BUILT_SOURCES += \
+ $(CXX_CSI_PROTOS) \
$(CXX_LOG_PROTOS) \
$(CXX_PROTOS) \
$(CXX_STATE_PROTOS) \
@@ -411,6 +421,7 @@ BUILT_SOURCES += \
$(V1_PYTHON_PROTOS)
CLEANFILES += \
+ $(CXX_CSI_PROTOS) \
$(CXX_LOG_PROTOS) \
$(CXX_PROTOS) \
$(CXX_STATE_PROTOS) \
@@ -420,13 +431,19 @@ CLEANFILES += \
$(V1_PYTHON_PROTOS)
-# Targets for generating C++ protocol buffer code.
+# Targets for generating C++ protocol buffer and gRPC code.
../include/mesos/%.pb.cc ../include/mesos/%.pb.h: $(top_srcdir)/include/mesos/%.proto
$(PROTOC) $(PROTOCFLAGS) --cpp_out=../include $^
+csi/%.pb.cc csi/%.pb.h: ../$(CSI)/%.proto
+ $(PROTOC) $(PROTOCFLAGS) --cpp_out=csi $^
+
%.pb.cc %.pb.h: %.proto
$(PROTOC) $(PROTOCFLAGS) --cpp_out=. $^
+csi/%.grpc.pb.cc csi/%.grpc.pb.h: ../$(CSI)/%.proto
+ $(PROTOC) $(PROTOCFLAGS) --grpc_out=csi $^ \
+ --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN)
# Targets for generating Java protocol buffer code.
java/generated/org/apache/mesos/executor/Protos.java: $(EXECUTOR_PROTO)
@@ -1374,7 +1391,7 @@ endif
if ENABLE_SSL
libmesos_no_3rdparty_la_SOURCES += \
- authentication/executor/jwt_secret_generator.cpp \
+ authentication/executor/jwt_secret_generator.cpp \
authentication/executor/jwt_secret_generator.hpp
endif
@@ -1421,6 +1438,21 @@ libbuild_la_CPPFLAGS += -DBUILD_FLAGS="\"$$BUILD_FLAGS\""
libmesos_no_3rdparty_la_LIBADD += libbuild.la
+if ENABLE_GRPC
+# Convenience library for build the CSI client.
+noinst_LTLIBRARIES += libcsi.la
+libcsi_la_SOURCES = \
+ csi/client.cpp
+libcsi_la_SOURCES += \
+ csi/client.hpp \
+ csi/spec.hpp
+nodist_libcsi_la_SOURCES = $(CXX_CSI_PROTOS)
+libcsi_la_CPPFLAGS = $(MESOS_CPPFLAGS)
+
+libmesos_no_3rdparty_la_LIBADD += libcsi.la
+endif
+
+
# Convenience library for building the replicated log in order to
# include the leveldb headers.
noinst_LTLIBRARIES += liblog.la
@@ -2446,7 +2478,7 @@ mesos_tests_CPPFLAGS += -isystem ../$(GMOCK)/include
mesos_tests_CPPFLAGS += -DTESTLIBEXECDIR=\"$(testlibexecdir)\"
mesos_tests_CPPFLAGS += -DSBINDIR=\"$(sbindir)\"
-mesos_tests_LDADD = ../3rdparty/libgmock.la libmesos.la $(LDADD)
+mesos_tests_LDADD = ../3rdparty/libgmock.la libmesos.la $(LIB_GRPC) $(LDADD)
if !OS_FREEBSD
mesos_tests_LDADD += -ldl # FreeBSD includes dynamic lib utils in libc.
@@ -2489,6 +2521,13 @@ mesos_tests_SOURCES += \
tests/containerizer/routing_tests.cpp
endif
+if ENABLE_GRPC
+mesos_tests_SOURCES += \
+ tests/csi_client_tests.cpp \
+ tests/mock_csi_plugin.cpp \
+ tests/mock_csi_plugin.hpp
+endif
+
if ENABLE_SSL
mesos_tests_SOURCES += \
tests/secret_generator_tests.cpp
[4/6] mesos git commit: Style cleanup for grpc tests.
Posted by ji...@apache.org.
Style cleanup for grpc tests.
Review: https://reviews.apache.org/r/61748/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/71e1dce4
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/71e1dce4
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/71e1dce4
Branch: refs/heads/master
Commit: 71e1dce481ccdd5f0cfddc26e6ebfecb2285ef47
Parents: 5abd964
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Tue Aug 22 14:27:50 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Aug 22 15:20:34 2017 -0700
----------------------------------------------------------------------
3rdparty/libprocess/src/tests/grpc_tests.cpp | 35 +++++++++--------------
1 file changed, 13 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/71e1dce4/3rdparty/libprocess/src/tests/grpc_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/grpc_tests.cpp b/3rdparty/libprocess/src/tests/grpc_tests.cpp
index a11b6f0..7ac4ef6 100644
--- a/3rdparty/libprocess/src/tests/grpc_tests.cpp
+++ b/3rdparty/libprocess/src/tests/grpc_tests.cpp
@@ -27,8 +27,8 @@
#include <stout/tests/utils.hpp>
-#include "grpc_tests.pb.h"
#include "grpc_tests.grpc.pb.h"
+#include "grpc_tests.pb.h"
namespace client = process::grpc::client;
@@ -92,7 +92,8 @@ private:
};
-class GRPCClientTest : public TemporaryDirectoryTest {
+class GRPCClientTest : public TemporaryDirectoryTest
+{
protected:
string server_address() const
{
@@ -114,8 +115,7 @@ TEST_F(GRPCClientTest, Success)
client::Runtime runtime;
Channel channel(server_address());
- Future<Pong> pong = runtime.call(
- channel, GRPC_RPC(PingPong, Send), Ping());
+ Future<Pong> pong = runtime.call(channel, GRPC_RPC(PingPong, Send), Ping());
AWAIT_EXPECT_READY(pong);
@@ -160,12 +160,9 @@ TEST_F(GRPCClientTest, ConcurrentRPCs)
client::Runtime runtime;
Channel channel(server_address());
- Future<Pong> pong1 = runtime.call(
- channel, GRPC_RPC(PingPong, Send), Ping());
- Future<Pong> pong2 = runtime.call(
- channel, GRPC_RPC(PingPong, Send), Ping());
- Future<Pong> pong3 = runtime.call(
- channel, GRPC_RPC(PingPong, Send), Ping());
+ Future<Pong> pong1 = runtime.call(channel, GRPC_RPC(PingPong, Send), Ping());
+ Future<Pong> pong2 = runtime.call(channel, GRPC_RPC(PingPong, Send), Ping());
+ Future<Pong> pong3 = runtime.call(channel, GRPC_RPC(PingPong, Send), Ping());
AWAIT_READY(processed1->future());
AWAIT_READY(processed2->future());
@@ -198,8 +195,7 @@ TEST_F(GRPCClientTest, Failed)
client::Runtime runtime;
Channel channel(server_address());
- Future<Pong> pong = runtime.call(
- channel, GRPC_RPC(PingPong, Send), Ping());
+ Future<Pong> pong = runtime.call(channel, GRPC_RPC(PingPong, Send), Ping());
AWAIT_EXPECT_FAILED(pong);
@@ -222,8 +218,7 @@ TEST_F(GRPCClientTest, DiscardedBeforeServerStarted)
client::Runtime runtime;
Channel channel(server_address());
- Future<Pong> pong = runtime.call(
- channel, GRPC_RPC(PingPong, Send), Ping());
+ Future<Pong> pong = runtime.call(channel, GRPC_RPC(PingPong, Send), Ping());
pong.discard();
ASSERT_SOME(server.Startup(server_address()));
@@ -259,8 +254,7 @@ TEST_F(GRPCClientTest, DiscardedWhenServerProcessing)
ASSERT_SOME(server.Startup(server_address()));
- Future<Pong> pong = runtime.call(
- channel, GRPC_RPC(PingPong, Send), Ping());
+ Future<Pong> pong = runtime.call(channel, GRPC_RPC(PingPong, Send), Ping());
AWAIT_READY(processed->future());
pong.discard();
@@ -297,8 +291,7 @@ TEST_F(GRPCClientTest, ClientShutdown)
client::Runtime runtime;
Channel channel(server_address());
- Future<Pong> pong = runtime.call(
- channel, GRPC_RPC(PingPong, Send), Ping());
+ Future<Pong> pong = runtime.call(channel, GRPC_RPC(PingPong, Send), Ping());
AWAIT_READY(processed->future());
@@ -319,8 +312,7 @@ TEST_F(GRPCClientTest, ServerUnreachable)
client::Runtime runtime;
Channel channel("nosuchhost");
- Future<Pong> pong = runtime.call(
- channel, GRPC_RPC(PingPong, Send), Ping());
+ Future<Pong> pong = runtime.call(channel, GRPC_RPC(PingPong, Send), Ping());
runtime.terminate();
AWAIT_ASSERT_READY(runtime.wait());
@@ -349,8 +341,7 @@ TEST_F(GRPCClientTest, ServerTimeout)
client::Runtime runtime;
Channel channel(server_address());
- Future<Pong> pong = runtime.call(
- channel, GRPC_RPC(PingPong, Send), Ping());
+ Future<Pong> pong = runtime.call(channel, GRPC_RPC(PingPong, Send), Ping());
// TODO(chhsiao): The gRPC library returns a failure after the default
// timeout (5 seconds) is passed, no matter when the `CompletionQueue`
[3/6] mesos git commit: Bundled CSI v0.1.0 into 3rdparty libraries.
Posted by ji...@apache.org.
Bundled CSI v0.1.0 into 3rdparty libraries.
The bundled package is generated wih the following command:
git clone https://github.com/container-storage-interface/spec.git csi
cd csi && git archive --prefix=csi-0.1.0/ 6606242 |
gzip > csi-0.1.0.tar.gz
Review: https://reviews.apache.org/r/61703/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/07b76c07
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/07b76c07
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/07b76c07
Branch: refs/heads/master
Commit: 07b76c07b790bbfe42a1a54ebfb950ebf1a65599
Parents: 71e1dce
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Tue Aug 22 14:31:16 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Aug 22 15:20:34 2017 -0700
----------------------------------------------------------------------
3rdparty/csi-0.1.0.tar.gz | Bin 0 -> 80603 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/07b76c07/3rdparty/csi-0.1.0.tar.gz
----------------------------------------------------------------------
diff --git a/3rdparty/csi-0.1.0.tar.gz b/3rdparty/csi-0.1.0.tar.gz
new file mode 100644
index 0000000..1d09c70
Binary files /dev/null and b/3rdparty/csi-0.1.0.tar.gz differ
[5/6] mesos git commit: Added a mock CSI plugin and a unit test for
CSI client classes.
Posted by ji...@apache.org.
Added a mock CSI plugin and a unit test for CSI client classes.
The mock plugin simply starts the `Identity`, `Controller` and `Node`
CSI services and return a success with an empty response protocol buffer
for each RPC. The unit test verifies that each method in the `Client`
class makes the corresponding RPC call through the gRPC interface in
libprocess.
Review: https://reviews.apache.org/r/61705/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/40734286
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/40734286
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/40734286
Branch: refs/heads/master
Commit: 40734286ffeeaf68afd9f87c162a7a36701f5ab7
Parents: 9bf4e83
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Tue Aug 22 14:32:12 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Aug 22 15:20:40 2017 -0700
----------------------------------------------------------------------
src/tests/csi_client_tests.cpp | 148 ++++++++++++++++++++++++++++++++++++
src/tests/mock_csi_plugin.cpp | 76 ++++++++++++++++++
src/tests/mock_csi_plugin.hpp | 80 +++++++++++++++++++
3 files changed, 304 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/40734286/src/tests/csi_client_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/csi_client_tests.cpp b/src/tests/csi_client_tests.cpp
new file mode 100644
index 0000000..725466a
--- /dev/null
+++ b/src/tests/csi_client_tests.cpp
@@ -0,0 +1,148 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <process/gtest.hpp>
+
+#include <stout/lambda.hpp>
+#include <stout/path.hpp>
+#include <stout/strings.hpp>
+
+#include <stout/tests/utils.hpp>
+
+#include "csi/client.hpp"
+
+#include "tests/mock_csi_plugin.hpp"
+
+using std::string;
+
+using mesos::csi::Client;
+
+using process::Future;
+
+using process::grpc::client::Runtime;
+
+using testing::TestParamInfo;
+using testing::Values;
+using testing::WithParamInterface;
+
+namespace mesos {
+namespace internal {
+namespace tests {
+
+struct RPCParam
+{
+ struct Printer
+ {
+ const string& operator()(const TestParamInfo<RPCParam>& info) const
+ {
+ return info.param.name;
+ }
+ };
+
+ template <typename Request, typename Response>
+ RPCParam(const string& _name, Future<Response>(Client::*rpc)(const Request&))
+ : name(_name),
+ call([=](const string& address, const Runtime runtime) {
+ return (Client(address, runtime).*rpc)(Request())
+ .then([] { return Nothing(); });
+ }) {}
+
+ string name;
+ lambda::function<Future<Nothing>(const string&, const Runtime&)> call;
+};
+
+
+class CSIClientTest
+ : public TemporaryDirectoryTest,
+ public WithParamInterface<RPCParam>
+{
+protected:
+ virtual void SetUp() override
+ {
+ TemporaryDirectoryTest::SetUp();
+
+ ASSERT_SOME(plugin.Startup(GetPluginAddress()));
+ }
+
+ virtual void TearDown() override
+ {
+ runtime.terminate();
+ AWAIT_ASSERT_READY(runtime.wait());
+
+ ASSERT_SOME(plugin.Shutdown());
+ }
+
+ string GetPluginAddress()
+ {
+ // TODO(chhsiao): Use in-process tranport instead of a Unix domain
+ // socket once gRPC supports it for Windows support.
+ // https://github.com/grpc/grpc/pull/11145
+ return "unix://" + path::join(sandbox.get(), "socket");
+ }
+
+ MockCSIPlugin plugin;
+ process::grpc::client::Runtime runtime;
+};
+
+
+#define RPC_PARAM(method) \
+ RPCParam(strings::replace(#method, "::", "_"), &method)
+
+
+INSTANTIATE_TEST_CASE_P(
+ Identity,
+ CSIClientTest,
+ Values(
+ RPC_PARAM(Client::GetSupportedVersions),
+ RPC_PARAM(Client::GetPluginInfo)),
+ RPCParam::Printer());
+
+INSTANTIATE_TEST_CASE_P(
+ Controller,
+ CSIClientTest,
+ Values(
+ RPC_PARAM(Client::CreateVolume),
+ RPC_PARAM(Client::DeleteVolume),
+ RPC_PARAM(Client::ControllerPublishVolume),
+ RPC_PARAM(Client::ControllerUnpublishVolume),
+ RPC_PARAM(Client::ValidateVolumeCapabilities),
+ RPC_PARAM(Client::ListVolumes),
+ RPC_PARAM(Client::GetCapacity),
+ RPC_PARAM(Client::ControllerGetCapabilities)),
+ RPCParam::Printer());
+
+INSTANTIATE_TEST_CASE_P(
+ Node,
+ CSIClientTest,
+ Values(
+ RPC_PARAM(Client::NodePublishVolume),
+ RPC_PARAM(Client::NodeUnpublishVolume),
+ RPC_PARAM(Client::GetNodeID),
+ RPC_PARAM(Client::ProbeNode),
+ RPC_PARAM(Client::NodeGetCapabilities)),
+ RPCParam::Printer());
+
+
+// This test verifies that the all methods of CSI clients work.
+TEST_P(CSIClientTest, Call)
+{
+ Future<Nothing> call = GetParam().call(GetPluginAddress(), runtime);
+ AWAIT_EXPECT_READY(call);
+}
+
+} // namespace tests {
+} // namespace internal {
+} // namespace mesos {
http://git-wip-us.apache.org/repos/asf/mesos/blob/40734286/src/tests/mock_csi_plugin.cpp
----------------------------------------------------------------------
diff --git a/src/tests/mock_csi_plugin.cpp b/src/tests/mock_csi_plugin.cpp
new file mode 100644
index 0000000..46ca398
--- /dev/null
+++ b/src/tests/mock_csi_plugin.cpp
@@ -0,0 +1,76 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "tests/mock_csi_plugin.hpp"
+
+using std::string;
+using std::unique_ptr;
+
+using csi::Controller;
+using csi::Identity;
+using csi::Node;
+
+using grpc::InsecureServerCredentials;
+using grpc::Server;
+using grpc::ServerBuilder;
+using grpc::ServerContext;
+using grpc::Status;
+
+using testing::_;
+using testing::Return;
+
+namespace mesos {
+namespace internal {
+namespace tests {
+
+#define DECLARE_MOCK_CSI_METHOD_IMPL(name) \
+ EXPECT_CALL(*this, name(_, _, _)) \
+ .WillRepeatedly(Return(Status::OK));
+
+MockCSIPlugin::MockCSIPlugin()
+{
+ CSI_METHOD_FOREACH(DECLARE_MOCK_CSI_METHOD_IMPL)
+}
+
+
+Try<Nothing> MockCSIPlugin::Startup(const string& address)
+{
+ ServerBuilder builder;
+ builder.AddListeningPort(address, InsecureServerCredentials());
+ builder.RegisterService(static_cast<Identity::Service*>(this));
+ builder.RegisterService(static_cast<Controller::Service*>(this));
+ builder.RegisterService(static_cast<Node::Service*>(this));
+
+ server = builder.BuildAndStart();
+ if (!server) {
+ return Error("Unable to start a mock CSI plugin.");
+ }
+
+ return Nothing();
+}
+
+
+Try<Nothing> MockCSIPlugin::Shutdown()
+{
+ server->Shutdown();
+ server->Wait();
+
+ return Nothing();
+}
+
+} // namespace tests {
+} // namespace internal {
+} // namespace mesos {
http://git-wip-us.apache.org/repos/asf/mesos/blob/40734286/src/tests/mock_csi_plugin.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mock_csi_plugin.hpp b/src/tests/mock_csi_plugin.hpp
new file mode 100644
index 0000000..b7926c4
--- /dev/null
+++ b/src/tests/mock_csi_plugin.hpp
@@ -0,0 +1,80 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __TESTS_MOCKCSIPLUGIN_HPP__
+#define __TESTS_MOCKCSIPLUGIN_HPP__
+
+#include <memory>
+#include <string>
+
+#include <gmock/gmock.h>
+
+#include <grpc++/grpc++.h>
+
+#include <stout/nothing.hpp>
+#include <stout/try.hpp>
+
+#include "csi/spec.hpp"
+
+namespace mesos {
+namespace internal {
+namespace tests {
+
+#define CSI_METHOD_FOREACH(macro) \
+ macro(GetSupportedVersions) \
+ macro(GetPluginInfo) \
+ macro(CreateVolume) \
+ macro(DeleteVolume) \
+ macro(ControllerPublishVolume) \
+ macro(ControllerUnpublishVolume) \
+ macro(ValidateVolumeCapabilities) \
+ macro(ListVolumes) \
+ macro(GetCapacity) \
+ macro(ControllerGetCapabilities) \
+ macro(NodePublishVolume) \
+ macro(NodeUnpublishVolume) \
+ macro(GetNodeID) \
+ macro(ProbeNode) \
+ macro(NodeGetCapabilities)
+
+#define DECLARE_MOCK_CSI_METHOD(name) \
+ MOCK_METHOD3(name, grpc::Status( \
+ grpc::ServerContext* context, \
+ const csi::name##Request* request, \
+ csi::name##Response* response));
+
+// Definition of a mock CSI plugin to be used in tests with gmock.
+class MockCSIPlugin : public csi::Identity::Service,
+ public csi::Controller::Service,
+ public csi::Node::Service
+{
+public:
+ MockCSIPlugin();
+
+ CSI_METHOD_FOREACH(DECLARE_MOCK_CSI_METHOD)
+
+ Try<Nothing> Startup(const std::string& address);
+ Try<Nothing> Shutdown();
+
+private:
+ std::unique_ptr<grpc::Server> server;
+};
+
+} // namespace tests {
+} // namespace internal {
+} // namespace mesos {
+
+#endif // __TESTS_MOCKCSIPLUGIN_HPP__
[2/6] mesos git commit: Added CSI client classes to talk to CSI
plugins.
Posted by ji...@apache.org.
Added CSI client classes to talk to CSI plugins.
Review: https://reviews.apache.org/r/61704/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/9bf4e838
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/9bf4e838
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/9bf4e838
Branch: refs/heads/master
Commit: 9bf4e8383d3f19a9cfe5cffec9fdee87cff254a7
Parents: 07b76c0
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Tue Aug 22 14:32:02 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Aug 22 15:20:34 2017 -0700
----------------------------------------------------------------------
src/csi/client.cpp | 174 ++++++++++++++++++++++++++++++++++++++++++++++++
src/csi/client.hpp | 96 ++++++++++++++++++++++++++
src/csi/spec.hpp | 23 +++++++
3 files changed, 293 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/9bf4e838/src/csi/client.cpp
----------------------------------------------------------------------
diff --git a/src/csi/client.cpp b/src/csi/client.cpp
new file mode 100644
index 0000000..e171f03
--- /dev/null
+++ b/src/csi/client.cpp
@@ -0,0 +1,174 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "csi/client.hpp"
+
+using process::Future;
+
+namespace mesos {
+namespace csi {
+
+Future<GetSupportedVersionsResponse> Client::GetSupportedVersions(
+ const GetSupportedVersionsRequest& request)
+{
+ return runtime.call(
+ channel,
+ GRPC_RPC(Identity, GetSupportedVersions),
+ request);
+}
+
+
+Future<GetPluginInfoResponse> Client::GetPluginInfo(
+ const GetPluginInfoRequest& request)
+{
+ return runtime.call(
+ channel,
+ GRPC_RPC(Identity, GetPluginInfo),
+ request);
+}
+
+
+Future<CreateVolumeResponse> Client::CreateVolume(
+ const CreateVolumeRequest& request)
+{
+ return runtime.call(
+ channel,
+ GRPC_RPC(Controller, CreateVolume),
+ request);
+}
+
+
+Future<DeleteVolumeResponse> Client::DeleteVolume(
+ const DeleteVolumeRequest& request)
+{
+ return runtime.call(
+ channel,
+ GRPC_RPC(Controller, DeleteVolume),
+ request);
+}
+
+
+Future<ControllerPublishVolumeResponse> Client::ControllerPublishVolume(
+ const ControllerPublishVolumeRequest& request)
+{
+ return runtime.call(
+ channel,
+ GRPC_RPC(Controller, ControllerPublishVolume),
+ request);
+}
+
+
+Future<ControllerUnpublishVolumeResponse> Client::ControllerUnpublishVolume(
+ const ControllerUnpublishVolumeRequest& request)
+{
+ return runtime.call(
+ channel,
+ GRPC_RPC(Controller, ControllerUnpublishVolume),
+ request);
+}
+
+
+Future<ValidateVolumeCapabilitiesResponse> Client::ValidateVolumeCapabilities(
+ const ValidateVolumeCapabilitiesRequest& request)
+{
+ return runtime.call(
+ channel,
+ GRPC_RPC(Controller, ValidateVolumeCapabilities),
+ request);
+}
+
+
+Future<ListVolumesResponse> Client::ListVolumes(
+ const ListVolumesRequest& request)
+{
+ return runtime.call(
+ channel,
+ GRPC_RPC(Controller, ListVolumes),
+ request);
+}
+
+
+Future<GetCapacityResponse> Client::GetCapacity(
+ const GetCapacityRequest& request)
+{
+ return runtime.call(
+ channel,
+ GRPC_RPC(Controller, GetCapacity),
+ request);
+}
+
+
+Future<ControllerGetCapabilitiesResponse> Client::ControllerGetCapabilities(
+ const ControllerGetCapabilitiesRequest& request)
+{
+ return runtime.call(
+ channel,
+ GRPC_RPC(Controller, ControllerGetCapabilities),
+ request);
+}
+
+
+Future<NodePublishVolumeResponse> Client::NodePublishVolume(
+ const NodePublishVolumeRequest& request)
+{
+ return runtime.call(
+ channel,
+ GRPC_RPC(Node, NodePublishVolume),
+ request);
+}
+
+
+Future<NodeUnpublishVolumeResponse> Client::NodeUnpublishVolume(
+ const NodeUnpublishVolumeRequest& request)
+{
+ return runtime.call(
+ channel,
+ GRPC_RPC(Node, NodeUnpublishVolume),
+ request);
+}
+
+
+Future<GetNodeIDResponse> Client::GetNodeID(
+ const GetNodeIDRequest& request)
+{
+ return runtime.call(
+ channel,
+ GRPC_RPC(Node, GetNodeID),
+ request);
+}
+
+
+Future<ProbeNodeResponse> Client::ProbeNode(
+ const ProbeNodeRequest& request)
+{
+ return runtime.call(
+ channel,
+ GRPC_RPC(Node, ProbeNode),
+ request);
+}
+
+
+Future<NodeGetCapabilitiesResponse> Client::NodeGetCapabilities(
+ const NodeGetCapabilitiesRequest& request)
+{
+ return runtime.call(
+ channel,
+ GRPC_RPC(Node, NodeGetCapabilities),
+ request);
+}
+
+} // namespace csi {
+} // namespace mesos {
http://git-wip-us.apache.org/repos/asf/mesos/blob/9bf4e838/src/csi/client.hpp
----------------------------------------------------------------------
diff --git a/src/csi/client.hpp b/src/csi/client.hpp
new file mode 100644
index 0000000..df674e1
--- /dev/null
+++ b/src/csi/client.hpp
@@ -0,0 +1,96 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __CSI_CLIENT_HPP__
+#define __CSI_CLIENT_HPP__
+
+#include <string>
+
+#include <process/grpc.hpp>
+
+#include "csi/spec.hpp"
+
+namespace mesos {
+namespace csi {
+
+using namespace ::csi;
+
+class Client
+{
+public:
+ Client(const std::string& uri,
+ const process::grpc::client::Runtime& _runtime)
+ : channel(uri),
+ runtime(_runtime) {}
+
+ // RPCs for the Identity service.
+ process::Future<GetSupportedVersionsResponse>
+ GetSupportedVersions(const GetSupportedVersionsRequest& request);
+
+ process::Future<GetPluginInfoResponse>
+ GetPluginInfo(const GetPluginInfoRequest& request);
+
+ // RPCs for the Controller service.
+ process::Future<CreateVolumeResponse>
+ CreateVolume(const CreateVolumeRequest& request);
+
+ process::Future<DeleteVolumeResponse>
+ DeleteVolume(const DeleteVolumeRequest& request);
+
+ process::Future<ControllerPublishVolumeResponse>
+ ControllerPublishVolume(const ControllerPublishVolumeRequest& request);
+
+ process::Future<ControllerUnpublishVolumeResponse>
+ ControllerUnpublishVolume(const ControllerUnpublishVolumeRequest& request);
+
+ process::Future<ValidateVolumeCapabilitiesResponse>
+ ValidateVolumeCapabilities(
+ const ValidateVolumeCapabilitiesRequest& request);
+
+ process::Future<ListVolumesResponse>
+ ListVolumes(const ListVolumesRequest& request);
+
+ process::Future<GetCapacityResponse>
+ GetCapacity(const GetCapacityRequest& request);
+
+ process::Future<ControllerGetCapabilitiesResponse>
+ ControllerGetCapabilities(const ControllerGetCapabilitiesRequest& request);
+
+ // RPCs for the Node service.
+ process::Future<NodePublishVolumeResponse>
+ NodePublishVolume(const NodePublishVolumeRequest& request);
+
+ process::Future<NodeUnpublishVolumeResponse>
+ NodeUnpublishVolume(const NodeUnpublishVolumeRequest& request);
+
+ process::Future<GetNodeIDResponse>
+ GetNodeID(const GetNodeIDRequest& request);
+
+ process::Future<ProbeNodeResponse>
+ ProbeNode(const ProbeNodeRequest& request);
+
+ process::Future<NodeGetCapabilitiesResponse>
+ NodeGetCapabilities(const NodeGetCapabilitiesRequest& request);
+
+private:
+ process::grpc::Channel channel;
+ process::grpc::client::Runtime runtime;
+};
+
+} // namespace csi {
+} // namespace mesos {
+
+#endif // __CSI_CLIENT_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/9bf4e838/src/csi/spec.hpp
----------------------------------------------------------------------
diff --git a/src/csi/spec.hpp b/src/csi/spec.hpp
new file mode 100644
index 0000000..60e40e0
--- /dev/null
+++ b/src/csi/spec.hpp
@@ -0,0 +1,23 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __CSI_SPEC_HPP__
+#define __CSI_SPEC_HPP__
+
+// ONLY USEFUL AFTER RUNNING PROTOC WITH GRPC CPP PLUGIN.
+#include "csi/csi.grpc.pb.h"
+
+#endif // __CSI_SPEC_HPP__