You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ch...@apache.org on 2019/04/05 06:34:02 UTC

[mesos] branch master updated (e6a3f0d -> 6e73de1)

This is an automated email from the ASF dual-hosted git repository.

chhsiao pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git.


    from e6a3f0d  Added a unit test for Mesos containerizer image force pulling.
     new 3da5496  Bundled CSI spec 1.1.0.
     new 6ef64a3  Added spec inclusion header and type helpers for CSI v1.
     new 2b1336d  Added the `mesos::csi::v1::Client` wrapper.
     new 6e73de1  Extended `CSIClientTest` to test the CSI v1 client wrapper.

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 3rdparty/CMakeLists.txt                            |  24 ++-
 3rdparty/Makefile.am                               |  19 +-
 3rdparty/cmake/Versions.cmake                      |   2 +
 3rdparty/csi-1.1.0.tar.gz                          | Bin 0 -> 173338 bytes
 3rdparty/versions.am                               |   1 +
 configure.ac                                       |   8 +-
 include/mesos/csi/{v0.hpp => v1.hpp}               |  24 +--
 src/CMakeLists.txt                                 |   3 +
 src/Makefile.am                                    |  29 ++-
 src/cmake/MesosProtobuf.cmake                      |   6 +
 src/csi/{v0.cpp => v1.cpp}                         |   6 +-
 src/csi/{v0_client.cpp => v1_client.cpp}           |  78 +++++++-
 src/csi/{v0_client.hpp => v1_client.hpp}           |  34 +++-
 src/tests/csi_client_tests.cpp                     |  31 +++
 src/tests/mock_csi_plugin.cpp                      | 208 ++++++++++++++++++---
 src/tests/mock_csi_plugin.hpp                      | 137 +++++++++++++-
 .../storage_local_resource_provider_tests.cpp      |   8 +-
 17 files changed, 539 insertions(+), 79 deletions(-)
 create mode 100644 3rdparty/csi-1.1.0.tar.gz
 copy include/mesos/csi/{v0.hpp => v1.hpp} (89%)
 copy src/csi/{v0.cpp => v1.cpp} (94%)
 copy src/csi/{v0_client.cpp => v1_client.cpp} (75%)
 copy src/csi/{v0_client.hpp => v1_client.hpp} (77%)


[mesos] 04/04: Extended `CSIClientTest` to test the CSI v1 client wrapper.

Posted by ch...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

chhsiao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 6e73de1d185cf6e9b14f268042e57e3bbaddd68d
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
AuthorDate: Sun Mar 31 17:17:15 2019 -0700

    Extended `CSIClientTest` to test the CSI v1 client wrapper.
    
    Review: https://reviews.apache.org/r/70363
---
 src/tests/csi_client_tests.cpp                     |  31 +++
 src/tests/mock_csi_plugin.cpp                      | 208 ++++++++++++++++++---
 src/tests/mock_csi_plugin.hpp                      | 137 +++++++++++++-
 .../storage_local_resource_provider_tests.cpp      |   8 +-
 4 files changed, 344 insertions(+), 40 deletions(-)

diff --git a/src/tests/csi_client_tests.cpp b/src/tests/csi_client_tests.cpp
index a2a181b..992341e 100644
--- a/src/tests/csi_client_tests.cpp
+++ b/src/tests/csi_client_tests.cpp
@@ -24,6 +24,7 @@
 #include <stout/tests/utils.hpp>
 
 #include "csi/v0_client.hpp"
+#include "csi/v1_client.hpp"
 
 #include "tests/mock_csi_plugin.hpp"
 
@@ -126,6 +127,36 @@ INSTANTIATE_TEST_CASE_P(
     RPCParam::Printer());
 
 
+INSTANTIATE_TEST_CASE_P(
+    V1,
+    CSIClientTest,
+    Values(
+        RPCParam::create(&csi::v1::Client::getPluginInfo),
+        RPCParam::create(&csi::v1::Client::getPluginCapabilities),
+        RPCParam::create(&csi::v1::Client::probe),
+        RPCParam::create(&csi::v1::Client::createVolume),
+        RPCParam::create(&csi::v1::Client::deleteVolume),
+        RPCParam::create(&csi::v1::Client::controllerPublishVolume),
+        RPCParam::create(&csi::v1::Client::controllerUnpublishVolume),
+        RPCParam::create(&csi::v1::Client::validateVolumeCapabilities),
+        RPCParam::create(&csi::v1::Client::listVolumes),
+        RPCParam::create(&csi::v1::Client::getCapacity),
+        RPCParam::create(&csi::v1::Client::controllerGetCapabilities),
+        RPCParam::create(&csi::v1::Client::createSnapshot),
+        RPCParam::create(&csi::v1::Client::deleteSnapshot),
+        RPCParam::create(&csi::v1::Client::listSnapshots),
+        RPCParam::create(&csi::v1::Client::controllerExpandVolume),
+        RPCParam::create(&csi::v1::Client::nodeStageVolume),
+        RPCParam::create(&csi::v1::Client::nodeUnstageVolume),
+        RPCParam::create(&csi::v1::Client::nodePublishVolume),
+        RPCParam::create(&csi::v1::Client::nodeUnpublishVolume),
+        RPCParam::create(&csi::v1::Client::nodeGetVolumeStats),
+        RPCParam::create(&csi::v1::Client::nodeExpandVolume),
+        RPCParam::create(&csi::v1::Client::nodeGetCapabilities),
+        RPCParam::create(&csi::v1::Client::nodeGetInfo)),
+    RPCParam::Printer());
+
+
 // This test verifies that the all methods of CSI clients work.
 TEST_P(CSIClientTest, Call)
 {
diff --git a/src/tests/mock_csi_plugin.cpp b/src/tests/mock_csi_plugin.cpp
index 1024570..cbcb59f 100644
--- a/src/tests/mock_csi_plugin.cpp
+++ b/src/tests/mock_csi_plugin.cpp
@@ -26,13 +26,10 @@ using grpc::ServerBuilder;
 using grpc::ServerContext;
 using grpc::Status;
 
-using mesos::csi::v0::Controller;
-using mesos::csi::v0::Identity;
-using mesos::csi::v0::Node;
-
 using process::grpc::client::Connection;
 
 using testing::_;
+using testing::A;
 using testing::Invoke;
 using testing::Return;
 
@@ -42,12 +39,13 @@ namespace tests {
 
 MockCSIPlugin::MockCSIPlugin()
 {
-  EXPECT_CALL(*this, GetPluginInfo(_, _, _))
+  EXPECT_CALL(*this, GetPluginInfo(_, _, A<csi::v0::GetPluginInfoResponse*>()))
     .WillRepeatedly(Return(Status::OK));
 
-  // Enable all plugin capabilities by default for testing with the test CSI
-  // plugin in forwarding mode.
-  EXPECT_CALL(*this, GetPluginCapabilities(_, _, _))
+  // Enable all plugin service capabilities by default for testing with the test
+  // CSI plugin in forwarding mode.
+  EXPECT_CALL(*this, GetPluginCapabilities(
+      _, _, A<csi::v0::GetPluginCapabilitiesResponse*>()))
     .WillRepeatedly(Invoke([](
         ServerContext* context,
         const csi::v0::GetPluginCapabilitiesRequest* request,
@@ -58,33 +56,37 @@ MockCSIPlugin::MockCSIPlugin()
       return Status::OK;
     }));
 
-  EXPECT_CALL(*this, Probe(_, _, _))
+  EXPECT_CALL(*this, Probe(_, _, A<csi::v0::ProbeResponse*>()))
     .WillRepeatedly(Return(Status::OK));
 
-  EXPECT_CALL(*this, CreateVolume(_, _, _))
+  EXPECT_CALL(*this, CreateVolume(_, _, A<csi::v0::CreateVolumeResponse*>()))
     .WillRepeatedly(Return(Status::OK));
 
-  EXPECT_CALL(*this, DeleteVolume(_, _, _))
+  EXPECT_CALL(*this, DeleteVolume(_, _, A<csi::v0::DeleteVolumeResponse*>()))
     .WillRepeatedly(Return(Status::OK));
 
-  EXPECT_CALL(*this, ControllerPublishVolume(_, _, _))
+  EXPECT_CALL(*this, ControllerPublishVolume(
+      _, _, A<csi::v0::ControllerPublishVolumeResponse*>()))
     .WillRepeatedly(Return(Status::OK));
 
-  EXPECT_CALL(*this, ControllerUnpublishVolume(_, _, _))
+  EXPECT_CALL(*this, ControllerUnpublishVolume(
+      _, _, A<csi::v0::ControllerUnpublishVolumeResponse*>()))
     .WillRepeatedly(Return(Status::OK));
 
-  EXPECT_CALL(*this, ValidateVolumeCapabilities(_, _, _))
+  EXPECT_CALL(*this, ValidateVolumeCapabilities(
+      _, _, A<csi::v0::ValidateVolumeCapabilitiesResponse*>()))
     .WillRepeatedly(Return(Status::OK));
 
-  EXPECT_CALL(*this, ListVolumes(_, _, _))
+  EXPECT_CALL(*this, ListVolumes(_, _, A<csi::v0::ListVolumesResponse*>()))
     .WillRepeatedly(Return(Status::OK));
 
-  EXPECT_CALL(*this, GetCapacity(_, _, _))
+  EXPECT_CALL(*this, GetCapacity(_, _, A<csi::v0::GetCapacityResponse*>()))
     .WillRepeatedly(Return(Status::OK));
 
-  // Enable all controller capabilities by default for testing with the test CSI
-  // plugin in forwarding mode.
-  EXPECT_CALL(*this, ControllerGetCapabilities(_, _, _))
+  // Enable all controller RPC capabilities by default for testing with the test
+  // CSI plugin in forwarding mode.
+  EXPECT_CALL(*this, ControllerGetCapabilities(
+      _, _, A<csi::v0::ControllerGetCapabilitiesResponse*>()))
     .WillRepeatedly(Invoke([](
         ServerContext* context,
         const csi::v0::ControllerGetCapabilitiesRequest* request,
@@ -94,31 +96,36 @@ MockCSIPlugin::MockCSIPlugin()
       response->add_capabilities()->mutable_rpc()->set_type(
           csi::v0::ControllerServiceCapability::RPC::PUBLISH_UNPUBLISH_VOLUME);
       response->add_capabilities()->mutable_rpc()->set_type(
-          csi::v0::ControllerServiceCapability::RPC::GET_CAPACITY);
-      response->add_capabilities()->mutable_rpc()->set_type(
           csi::v0::ControllerServiceCapability::RPC::LIST_VOLUMES);
+      response->add_capabilities()->mutable_rpc()->set_type(
+          csi::v0::ControllerServiceCapability::RPC::GET_CAPACITY);
 
       return Status::OK;
     }));
 
-  EXPECT_CALL(*this, NodeStageVolume(_, _, _))
+  EXPECT_CALL(*this, NodeStageVolume(
+      _, _, A<csi::v0::NodeStageVolumeResponse*>()))
     .WillRepeatedly(Return(Status::OK));
 
-  EXPECT_CALL(*this, NodeUnstageVolume(_, _, _))
+  EXPECT_CALL(*this, NodeUnstageVolume(
+      _, _, A<csi::v0::NodeUnstageVolumeResponse*>()))
     .WillRepeatedly(Return(Status::OK));
 
-  EXPECT_CALL(*this, NodePublishVolume(_, _, _))
+  EXPECT_CALL(*this, NodePublishVolume(
+      _, _, A<csi::v0::NodePublishVolumeResponse*>()))
     .WillRepeatedly(Return(Status::OK));
 
-  EXPECT_CALL(*this, NodeUnpublishVolume(_, _, _))
+  EXPECT_CALL(*this, NodeUnpublishVolume(
+      _, _, A<csi::v0::NodeUnpublishVolumeResponse*>()))
     .WillRepeatedly(Return(Status::OK));
 
-  EXPECT_CALL(*this, NodeGetId(_, _, _))
+  EXPECT_CALL(*this, NodeGetId(_, _, A<csi::v0::NodeGetIdResponse*>()))
     .WillRepeatedly(Return(Status::OK));
 
-  // Enable all node capabilities by default for testing with the test CSI
+  // Enable all node RPC capabilities by default for testing with the test CSI
   // plugin in forwarding mode.
-  EXPECT_CALL(*this, NodeGetCapabilities(_, _, _))
+  EXPECT_CALL(*this, NodeGetCapabilities(
+      _, _, A<csi::v0::NodeGetCapabilitiesResponse*>()))
     .WillRepeatedly(Invoke([](
         ServerContext* context,
         const csi::v0::NodeGetCapabilitiesRequest* request,
@@ -128,6 +135,142 @@ MockCSIPlugin::MockCSIPlugin()
 
       return Status::OK;
     }));
+
+  EXPECT_CALL(*this, GetPluginInfo(_, _, A<csi::v1::GetPluginInfoResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
+
+  // Enable all plugin service capabilities by default for testing with the test
+  // CSI plugin in forwarding mode.
+  EXPECT_CALL(*this, GetPluginCapabilities(
+      _, _, A<csi::v1::GetPluginCapabilitiesResponse*>()))
+    .WillRepeatedly(Invoke([](
+        ServerContext* context,
+        const csi::v1::GetPluginCapabilitiesRequest* request,
+        csi::v1::GetPluginCapabilitiesResponse* response) {
+      response->add_capabilities()->mutable_service()->set_type(
+          csi::v1::PluginCapability::Service::CONTROLLER_SERVICE);
+      response->add_capabilities()->mutable_service()->set_type(
+          csi::v1::PluginCapability::Service::VOLUME_ACCESSIBILITY_CONSTRAINTS);
+
+      return Status::OK;
+    }));
+
+  EXPECT_CALL(*this, Probe(_, _, A<csi::v1::ProbeResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
+
+  EXPECT_CALL(*this, CreateVolume(_, _, A<csi::v1::CreateVolumeResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
+
+  EXPECT_CALL(*this, DeleteVolume(_, _, A<csi::v1::DeleteVolumeResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
+
+  EXPECT_CALL(*this, ControllerPublishVolume(
+      _, _, A<csi::v1::ControllerPublishVolumeResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
+
+  EXPECT_CALL(*this, ControllerUnpublishVolume(
+      _, _, A<csi::v1::ControllerUnpublishVolumeResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
+
+  EXPECT_CALL(*this, ValidateVolumeCapabilities(
+      _, _, A<csi::v1::ValidateVolumeCapabilitiesResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
+
+  EXPECT_CALL(*this, ListVolumes(_, _, A<csi::v1::ListVolumesResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
+
+  EXPECT_CALL(*this, GetCapacity(_, _, A<csi::v1::GetCapacityResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
+
+  // Enable all controller RPC capabilities by default for testing with the test
+  // CSI plugin in forwarding mode.
+  EXPECT_CALL(*this, ControllerGetCapabilities(
+      _, _, A<csi::v1::ControllerGetCapabilitiesResponse*>()))
+    .WillRepeatedly(Invoke([](
+        ServerContext* context,
+        const csi::v1::ControllerGetCapabilitiesRequest* request,
+        csi::v1::ControllerGetCapabilitiesResponse* response) {
+      response->add_capabilities()->mutable_rpc()->set_type(
+          csi::v1::ControllerServiceCapability::RPC::CREATE_DELETE_VOLUME);
+      response->add_capabilities()->mutable_rpc()->set_type(
+          csi::v1::ControllerServiceCapability::RPC::PUBLISH_UNPUBLISH_VOLUME);
+      response->add_capabilities()->mutable_rpc()->set_type(
+          csi::v1::ControllerServiceCapability::RPC::LIST_VOLUMES);
+      response->add_capabilities()->mutable_rpc()->set_type(
+          csi::v1::ControllerServiceCapability::RPC::GET_CAPACITY);
+      response->add_capabilities()->mutable_rpc()->set_type(
+          csi::v1::ControllerServiceCapability::RPC::CREATE_DELETE_SNAPSHOT);
+      response->add_capabilities()->mutable_rpc()->set_type(
+          csi::v1::ControllerServiceCapability::RPC::LIST_SNAPSHOTS);
+      response->add_capabilities()->mutable_rpc()->set_type(
+          csi::v1::ControllerServiceCapability::RPC::CLONE_VOLUME);
+      response->add_capabilities()->mutable_rpc()->set_type(
+          csi::v1::ControllerServiceCapability::RPC::PUBLISH_READONLY);
+      response->add_capabilities()->mutable_rpc()->set_type(
+          csi::v1::ControllerServiceCapability::RPC::EXPAND_VOLUME);
+
+      return Status::OK;
+    }));
+
+  EXPECT_CALL(*this, CreateSnapshot(
+      _, _, A<csi::v1::CreateSnapshotResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
+
+  EXPECT_CALL(*this, DeleteSnapshot(
+      _, _, A<csi::v1::DeleteSnapshotResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
+
+  EXPECT_CALL(*this, ListSnapshots(_, _, A<csi::v1::ListSnapshotsResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
+
+  EXPECT_CALL(*this, ControllerExpandVolume(
+      _, _, A<csi::v1::ControllerExpandVolumeResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
+
+  EXPECT_CALL(*this, NodeStageVolume(
+      _, _, A<csi::v1::NodeStageVolumeResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
+
+  EXPECT_CALL(*this, NodeUnstageVolume(
+      _, _, A<csi::v1::NodeUnstageVolumeResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
+
+  EXPECT_CALL(*this, NodePublishVolume(
+      _, _, A<csi::v1::NodePublishVolumeResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
+
+  EXPECT_CALL(*this, NodeUnpublishVolume(
+      _, _, A<csi::v1::NodeUnpublishVolumeResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
+
+  EXPECT_CALL(*this, NodeGetVolumeStats(
+      _, _, A<csi::v1::NodeGetVolumeStatsResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
+
+  EXPECT_CALL(*this, NodeExpandVolume(
+      _, _, A<csi::v1::NodeExpandVolumeResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
+
+  // Enable all node RPC capabilities by default for testing with the test CSI
+  // plugin in forwarding mode.
+  EXPECT_CALL(*this, NodeGetCapabilities(
+      _, _, A<csi::v1::NodeGetCapabilitiesResponse*>()))
+    .WillRepeatedly(Invoke([](
+        ServerContext* context,
+        const csi::v1::NodeGetCapabilitiesRequest* request,
+        csi::v1::NodeGetCapabilitiesResponse* response) {
+      response->add_capabilities()->mutable_rpc()->set_type(
+          csi::v1::NodeServiceCapability::RPC::STAGE_UNSTAGE_VOLUME);
+      response->add_capabilities()->mutable_rpc()->set_type(
+          csi::v1::NodeServiceCapability::RPC::GET_VOLUME_STATS);
+      response->add_capabilities()->mutable_rpc()->set_type(
+          csi::v1::NodeServiceCapability::RPC::EXPAND_VOLUME);
+
+      return Status::OK;
+    }));
+
+  EXPECT_CALL(*this, NodeGetInfo(_, _, A<csi::v1::NodeGetInfoResponse*>()))
+    .WillRepeatedly(Return(Status::OK));
 }
 
 
@@ -139,9 +282,12 @@ Try<Connection> MockCSIPlugin::startup(const Option<string>& address)
     builder.AddListeningPort(address.get(), InsecureServerCredentials());
   }
 
-  builder.RegisterService(static_cast<Identity::Service*>(this));
-  builder.RegisterService(static_cast<Controller::Service*>(this));
-  builder.RegisterService(static_cast<Node::Service*>(this));
+  builder.RegisterService(static_cast<csi::v0::Identity::Service*>(this));
+  builder.RegisterService(static_cast<csi::v0::Controller::Service*>(this));
+  builder.RegisterService(static_cast<csi::v0::Node::Service*>(this));
+  builder.RegisterService(static_cast<csi::v1::Identity::Service*>(this));
+  builder.RegisterService(static_cast<csi::v1::Controller::Service*>(this));
+  builder.RegisterService(static_cast<csi::v1::Node::Service*>(this));
 
   server = builder.BuildAndStart();
   if (!server) {
diff --git a/src/tests/mock_csi_plugin.hpp b/src/tests/mock_csi_plugin.hpp
index 2e3cbfd..d7da1ed 100644
--- a/src/tests/mock_csi_plugin.hpp
+++ b/src/tests/mock_csi_plugin.hpp
@@ -14,8 +14,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#ifndef __TESTS_MOCKCSIPLUGIN_HPP__
-#define __TESTS_MOCKCSIPLUGIN_HPP__
+#ifndef __TESTS_MOCK_CSI_PLUGIN_HPP__
+#define __TESTS_MOCK_CSI_PLUGIN_HPP__
 
 #include <memory>
 #include <string>
@@ -25,6 +25,7 @@
 #include <grpcpp/grpcpp.h>
 
 #include <mesos/csi/v0.hpp>
+#include <mesos/csi/v1.hpp>
 
 #include <process/grpc.hpp>
 
@@ -38,13 +39,19 @@ namespace internal {
 namespace tests {
 
 // Definition of a mock CSI plugin to be used in tests with gmock.
-class MockCSIPlugin : public csi::v0::Identity::Service,
-                      public csi::v0::Controller::Service,
-                      public csi::v0::Node::Service
+class MockCSIPlugin
+  : public csi::v0::Identity::Service,
+    public csi::v0::Controller::Service,
+    public csi::v0::Node::Service,
+    public csi::v1::Identity::Service,
+    public csi::v1::Controller::Service,
+    public csi::v1::Node::Service
 {
 public:
   MockCSIPlugin();
 
+  // CSI v0 RPCs.
+
   MOCK_METHOD3(GetPluginInfo, grpc::Status(
       grpc::ServerContext*,
       const csi::v0::GetPluginInfoRequest*,
@@ -130,8 +137,126 @@ public:
       const csi::v0::NodeGetCapabilitiesRequest*,
       csi::v0::NodeGetCapabilitiesResponse*));
 
+  // CSI v1 RPCs.
+
+  MOCK_METHOD3(GetPluginInfo, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::GetPluginInfoRequest*,
+      csi::v1::GetPluginInfoResponse*));
+
+  MOCK_METHOD3(GetPluginCapabilities, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::GetPluginCapabilitiesRequest*,
+      csi::v1::GetPluginCapabilitiesResponse*));
+
+  MOCK_METHOD3(Probe, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::ProbeRequest*,
+      csi::v1::ProbeResponse*));
+
+  MOCK_METHOD3(CreateVolume, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::CreateVolumeRequest*,
+      csi::v1::CreateVolumeResponse*));
+
+  MOCK_METHOD3(DeleteVolume, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::DeleteVolumeRequest*,
+      csi::v1::DeleteVolumeResponse*));
+
+  MOCK_METHOD3(ControllerPublishVolume, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::ControllerPublishVolumeRequest*,
+      csi::v1::ControllerPublishVolumeResponse*));
+
+  MOCK_METHOD3(ControllerUnpublishVolume, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::ControllerUnpublishVolumeRequest*,
+      csi::v1::ControllerUnpublishVolumeResponse*));
+
+  MOCK_METHOD3(ValidateVolumeCapabilities, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::ValidateVolumeCapabilitiesRequest*,
+      csi::v1::ValidateVolumeCapabilitiesResponse*));
+
+  MOCK_METHOD3(ListVolumes, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::ListVolumesRequest*,
+      csi::v1::ListVolumesResponse*));
+
+  MOCK_METHOD3(GetCapacity, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::GetCapacityRequest*,
+      csi::v1::GetCapacityResponse*));
+
+  MOCK_METHOD3(ControllerGetCapabilities, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::ControllerGetCapabilitiesRequest*,
+      csi::v1::ControllerGetCapabilitiesResponse*));
+
+  MOCK_METHOD3(CreateSnapshot, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::CreateSnapshotRequest*,
+      csi::v1::CreateSnapshotResponse*));
+
+  MOCK_METHOD3(DeleteSnapshot, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::DeleteSnapshotRequest*,
+      csi::v1::DeleteSnapshotResponse*));
+
+  MOCK_METHOD3(ListSnapshots, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::ListSnapshotsRequest*,
+      csi::v1::ListSnapshotsResponse*));
+
+  MOCK_METHOD3(ControllerExpandVolume, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::ControllerExpandVolumeRequest*,
+      csi::v1::ControllerExpandVolumeResponse*));
+
+  MOCK_METHOD3(NodeStageVolume, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::NodeStageVolumeRequest*,
+      csi::v1::NodeStageVolumeResponse*));
+
+  MOCK_METHOD3(NodeUnstageVolume, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::NodeUnstageVolumeRequest*,
+      csi::v1::NodeUnstageVolumeResponse*));
+
+  MOCK_METHOD3(NodePublishVolume, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::NodePublishVolumeRequest*,
+      csi::v1::NodePublishVolumeResponse*));
+
+  MOCK_METHOD3(NodeUnpublishVolume, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::NodeUnpublishVolumeRequest*,
+      csi::v1::NodeUnpublishVolumeResponse*));
+
+  MOCK_METHOD3(NodeGetVolumeStats, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::NodeGetVolumeStatsRequest*,
+      csi::v1::NodeGetVolumeStatsResponse*));
+
+  MOCK_METHOD3(NodeExpandVolume, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::NodeExpandVolumeRequest*,
+      csi::v1::NodeExpandVolumeResponse*));
+
+  MOCK_METHOD3(NodeGetCapabilities, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::NodeGetCapabilitiesRequest*,
+      csi::v1::NodeGetCapabilitiesResponse*));
+
+  MOCK_METHOD3(NodeGetInfo, grpc::Status(
+      grpc::ServerContext*,
+      const csi::v1::NodeGetInfoRequest*,
+      csi::v1::NodeGetInfoResponse*));
+
   Try<process::grpc::client::Connection> startup(
       const Option<std::string>& address = None());
+
   Try<Nothing> shutdown();
 
 private:
@@ -142,4 +267,4 @@ private:
 } // namespace internal {
 } // namespace mesos {
 
-#endif // __TESTS_MOCKCSIPLUGIN_HPP__
+#endif // __TESTS_MOCK_CSI_PLUGIN_HPP__
diff --git a/src/tests/storage_local_resource_provider_tests.cpp b/src/tests/storage_local_resource_provider_tests.cpp
index da8db41..bd35150 100644
--- a/src/tests/storage_local_resource_provider_tests.cpp
+++ b/src/tests/storage_local_resource_provider_tests.cpp
@@ -87,6 +87,8 @@ using process::reap;
 
 using process::grpc::StatusError;
 
+using testing::_;
+using testing::A;
 using testing::AllOf;
 using testing::AtMost;
 using testing::Between;
@@ -4793,7 +4795,7 @@ TEST_F(StorageLocalResourceProviderTest, RetryRpcWithExponentialBackoff)
   MockCSIPlugin plugin;
   ASSERT_SOME(plugin.startup(mockCsiEndpoint));
 
-  EXPECT_CALL(plugin, GetCapacity(_, _, _))
+  EXPECT_CALL(plugin, GetCapacity(_, _, A<csi::v0::GetCapacityResponse*>()))
     .WillRepeatedly(Invoke([](
         grpc::ServerContext* context,
         const csi::v0::GetCapacityRequest* request,
@@ -4805,7 +4807,7 @@ TEST_F(StorageLocalResourceProviderTest, RetryRpcWithExponentialBackoff)
 
   Queue<csi::v0::CreateVolumeRequest> createVolumeRequests;
   Queue<Try<csi::v0::CreateVolumeResponse, StatusError>> createVolumeResults;
-  EXPECT_CALL(plugin, CreateVolume(_, _, _))
+  EXPECT_CALL(plugin, CreateVolume(_, _, A<csi::v0::CreateVolumeResponse*>()))
     .WillRepeatedly(Invoke([&](
         grpc::ServerContext* context,
         const csi::v0::CreateVolumeRequest* request,
@@ -4830,7 +4832,7 @@ TEST_F(StorageLocalResourceProviderTest, RetryRpcWithExponentialBackoff)
 
   Queue<csi::v0::DeleteVolumeRequest> deleteVolumeRequests;
   Queue<Try<csi::v0::DeleteVolumeResponse, StatusError>> deleteVolumeResults;
-  EXPECT_CALL(plugin, DeleteVolume(_, _, _))
+  EXPECT_CALL(plugin, DeleteVolume(_, _, A<csi::v0::DeleteVolumeResponse*>()))
     .WillRepeatedly(Invoke([&](
         grpc::ServerContext* context,
         const csi::v0::DeleteVolumeRequest* request,


[mesos] 02/04: Added spec inclusion header and type helpers for CSI v1.

Posted by ch...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

chhsiao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 6ef64a3a6ff34975d58abbb0b78e2b402d39873c
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
AuthorDate: Thu Mar 28 22:14:32 2019 -0700

    Added spec inclusion header and type helpers for CSI v1.
    
    Review: https://reviews.apache.org/r/70361
---
 include/mesos/csi/v1.hpp | 103 +++++++++++++++++++++++++++++++++++++++++++++++
 src/CMakeLists.txt       |   1 +
 src/Makefile.am          |   4 +-
 src/csi/v1.cpp           |  32 +++++++++++++++
 4 files changed, 139 insertions(+), 1 deletion(-)

diff --git a/include/mesos/csi/v1.hpp b/include/mesos/csi/v1.hpp
new file mode 100644
index 0000000..d4ebe42
--- /dev/null
+++ b/include/mesos/csi/v1.hpp
@@ -0,0 +1,103 @@
+// 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 __MESOS_CSI_V1_HPP__
+#define __MESOS_CSI_V1_HPP__
+
+#include <ostream>
+#include <type_traits>
+
+// ONLY USEFUL AFTER RUNNING PROTOC.
+#include <csi/v1/csi.pb.h>
+
+// ONLY USEFUL AFTER RUNNING PROTOC WITH GRPC CPP PLUGIN.
+#include <csi/v1/csi.grpc.pb.h>
+
+#include <google/protobuf/message.h>
+
+#include <google/protobuf/util/json_util.h>
+#include <google/protobuf/util/message_differencer.h>
+
+#include <stout/check.hpp>
+
+namespace mesos {
+namespace csi {
+namespace v1 {
+
+using namespace ::csi::v1;
+
+} // namespace v1 {
+} // namespace csi {
+} // namespace mesos {
+
+
+namespace csi {
+namespace v1 {
+
+// Default implementation for comparing protobuf messages in namespace
+// `csi::v1`. Note that any non-template overloading of the equality operator
+// would take precedence over this function template.
+template <
+    typename Message,
+    typename std::enable_if<std::is_convertible<
+        Message*, google::protobuf::Message*>::value, int>::type = 0>
+bool operator==(const Message& left, const Message& right)
+{
+  // NOTE: `MessageDifferencer::Equivalent` would ignore unknown fields and load
+  // default values for unset fields (which are indistinguishable in proto3).
+  return google::protobuf::util::MessageDifferencer::Equivalent(left, right);
+}
+
+
+template <
+    typename Message,
+    typename std::enable_if<std::is_convertible<
+        Message*, google::protobuf::Message*>::value, int>::type = 0>
+bool operator!=(const Message& left, const Message& right)
+{
+  return !(left == right);
+}
+
+
+std::ostream& operator<<(
+    std::ostream& stream,
+    const ControllerServiceCapability::RPC::Type& type);
+
+
+// Default implementation for output protobuf messages in namespace `csi::v1`.
+// Note that any non-template overloading of the output operator would take
+// precedence over this function template.
+template <
+    typename Message,
+    typename std::enable_if<std::is_convertible<
+        Message*, google::protobuf::Message*>::value, int>::type = 0>
+std::ostream& operator<<(std::ostream& stream, const Message& message)
+{
+  // NOTE: We use Google's JSON utility functions for proto3.
+  std::string output;
+  google::protobuf::util::Status status =
+    google::protobuf::util::MessageToJsonString(message, &output);
+
+  CHECK(status.ok())
+    << "Could not convert messages to string: " << status.error_message();
+
+  return stream << output;
+}
+
+} // namespace v1 {
+} // namespace csi {
+
+#endif // __MESOS_CSI_V1_HPP__
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5ffeccd..0512044 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -241,6 +241,7 @@ set(CSI_SRC
   csi/v0_client.cpp
   csi/v0_utils.cpp
   csi/v0_volume_manager.cpp
+  csi/v1.cpp
   csi/volume_manager.cpp)
 
 set(DOCKER_SRC
diff --git a/src/Makefile.am b/src/Makefile.am
index 6782e4b..2f25a84 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -710,7 +710,8 @@ csidir = $(pkgincludedir)/csi
 csi_HEADERS =								\
   $(top_srcdir)/include/mesos/csi/types.hpp				\
   $(top_srcdir)/include/mesos/csi/types.proto				\
-  $(top_srcdir)/include/mesos/csi/v0.hpp
+  $(top_srcdir)/include/mesos/csi/v0.hpp				\
+  $(top_srcdir)/include/mesos/csi/v1.hpp
 
 nodist_csi_HEADERS =							\
   ../include/mesos/csi/types.pb.h
@@ -1594,6 +1595,7 @@ libcsi_la_SOURCES =							\
   csi/v0_volume_manager.cpp						\
   csi/v0_volume_manager.hpp						\
   csi/v0_volume_manager_process.hpp					\
+  csi/v1.cpp								\
   csi/volume_manager.cpp						\
   csi/volume_manager.hpp
 
diff --git a/src/csi/v1.cpp b/src/csi/v1.cpp
new file mode 100644
index 0000000..a07d1fa
--- /dev/null
+++ b/src/csi/v1.cpp
@@ -0,0 +1,32 @@
+// 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 <mesos/csi/v1.hpp>
+
+using std::ostream;
+
+namespace csi {
+namespace v1 {
+
+ostream& operator<<(
+    ostream& stream,
+    const ControllerServiceCapability::RPC::Type& type)
+{
+  return stream << ControllerServiceCapability::RPC::Type_Name(type);
+}
+
+} // namespace v1 {
+} // namespace csi {


[mesos] 01/04: Bundled CSI spec 1.1.0.

Posted by ch...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

chhsiao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 3da54965d02a6bf0e4806bf2d4acebb3310d60f7
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
AuthorDate: Thu Mar 28 21:26:04 2019 -0700

    Bundled CSI spec 1.1.0.
    
    Since the CSI v1 spec proto file depends on certain proto files in the
    Protobuf library, we have to ensure the Protobuf library's include path
    is in the proto paths of the `protoc` command when compiling the CSI
    spec proto file. Specifically in Autotools, this path is passed through
    the `PROTOBUF_PROTOCFLAGS` variable when building with an unbundled
    protobuf library.
    
    Review: https://reviews.apache.org/r/70360
---
 3rdparty/CMakeLists.txt       |  24 ++++++++++++++++++++++--
 3rdparty/Makefile.am          |  19 ++++++++++++++++---
 3rdparty/cmake/Versions.cmake |   2 ++
 3rdparty/csi-1.1.0.tar.gz     | Bin 0 -> 173338 bytes
 3rdparty/versions.am          |   1 +
 configure.ac                  |   8 +++++++-
 src/CMakeLists.txt            |   1 +
 src/Makefile.am               |  23 ++++++++++++++++++++---
 src/cmake/MesosProtobuf.cmake |   6 ++++++
 9 files changed, 75 insertions(+), 9 deletions(-)

diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt
index 7f70407..53396fb 100644
--- a/3rdparty/CMakeLists.txt
+++ b/3rdparty/CMakeLists.txt
@@ -27,6 +27,7 @@ set(BOOST_URL           ${FETCH_URL}/boost-${BOOST_VERSION}.tar.gz)
 set(BZIP2_URL           ${FETCH_URL}/bzip2-${BZIP2_VERSION}.tar.gz)
 set(CONCURRENTQUEUE_URL ${FETCH_URL}/concurrentqueue-${CONCURRENTQUEUE_VERSION}.tar.gz)
 set(CSI_V0_URL          ${FETCH_URL}/csi-${CSI_V0_VERSION}.tar.gz)
+set(CSI_V1_URL          ${FETCH_URL}/csi-${CSI_V1_VERSION}.tar.gz)
 set(ELFIO_URL           ${FETCH_URL}/elfio-${ELFIO_VERSION}.tar.gz)
 set(GLOG_URL            ${FETCH_URL}/glog-${GLOG_VERSION}.tar.gz)
 set(GOOGLETEST_URL      ${FETCH_URL}/googletest-release-${GOOGLETEST_VERSION}.tar.gz)
@@ -299,12 +300,21 @@ add_library(csi_v0 INTERFACE)
 add_dependencies(csi_v0 ${CSI_V0_TARGET})
 target_include_directories(csi_v0 INTERFACE ${CSI_V0_ROOT})
 
-# NOTE: To support multiple CSI versions, we move the CSI proto file to a
-# version-qualified path so `protoc` can find it.
+EXTERNAL(csi_v1 ${CSI_V1_VERSION} ${CMAKE_CURRENT_BINARY_DIR})
+add_library(csi_v1 INTERFACE)
+add_dependencies(csi_v1 ${CSI_V1_TARGET})
+target_include_directories(csi_v1 INTERFACE ${CSI_V1_ROOT})
+
+# NOTE: To support multiple CSI versions, we move the CSI proto files to
+# version-qualified paths so `protoc` can find them.
 set(CSI_V0_CONFIG_CMD
   ${CMAKE_COMMAND} -E make_directory ${CSI_V0_ROOT}/csi/v0 &&
   ${CMAKE_COMMAND} -E rename ${CSI_V0_ROOT}/csi.proto ${CSI_V0_ROOT}/csi/v0/csi.proto)
 
+set(CSI_V1_CONFIG_CMD
+  ${CMAKE_COMMAND} -E make_directory ${CSI_V1_ROOT}/csi/v1 &&
+  ${CMAKE_COMMAND} -E rename ${CSI_V1_ROOT}/csi.proto ${CSI_V1_ROOT}/csi/v1/csi.proto)
+
 ExternalProject_Add(
   ${CSI_V0_TARGET}
   PREFIX            ${CSI_V0_CMAKE_ROOT}
@@ -315,6 +325,16 @@ ExternalProject_Add(
   URL               ${CSI_V0_URL}
   URL_HASH          ${CSI_V0_HASH})
 
+ExternalProject_Add(
+  ${CSI_V1_TARGET}
+  PREFIX            ${CSI_V1_CMAKE_ROOT}
+  BUILD_BYPRODUCTS  ${CSI_V1_ROOT}/csi/v1/csi.proto
+  CONFIGURE_COMMAND ${CSI_V1_CONFIG_CMD}
+  BUILD_COMMAND     ${CMAKE_NOOP}
+  INSTALL_COMMAND   ${CMAKE_NOOP}
+  URL               ${CSI_V1_URL}
+  URL_HASH          ${CSI_V1_HASH})
+
 
 # ELFIO: library for reading and generating ELF files.
 # http://elfio.sourceforge.net
diff --git a/3rdparty/Makefile.am b/3rdparty/Makefile.am
index adbbaf5..99815da 100644
--- a/3rdparty/Makefile.am
+++ b/3rdparty/Makefile.am
@@ -51,6 +51,7 @@ include versions.am
 BOOST = boost-$(BOOST_VERSION)
 CONCURRENTQUEUE = concurrentqueue-$(CONCURRENTQUEUE_VERSION)
 CSI_V0 = csi-$(CSI_V0_VERSION)
+CSI_V1 = csi-$(CSI_V1_VERSION)
 ELFIO = elfio-$(ELFIO_VERSION)
 GLOG = glog-$(GLOG_VERSION)
 GMOCK = $(GOOGLETEST)/googlemock
@@ -78,6 +79,7 @@ EXTRA_DIST =			\
   $(BOOST).tar.gz		\
   $(CONCURRENTQUEUE).tar.gz	\
   $(CSI_V0).tar.gz		\
+  $(CSI_V1).tar.gz		\
   $(ELFIO).tar.gz		\
   $(GLOG).tar.gz		\
   $(GOOGLETEST).tar.gz		\
@@ -140,6 +142,7 @@ CLEAN_EXTRACTED =		\
   $(BOOST)			\
   $(CONCURRENTQUEUE)		\
   $(CSI_V0)			\
+  $(CSI_V1)			\
   $(ELFIO)			\
   $(GLOG)			\
   $(GOOGLETEST)			\
@@ -175,7 +178,7 @@ CLEAN_EXTRACTED =		\
 #
 # NOTE: Since GNU make 3.81 does not support shortest-stem pattern matching, we
 # explicitly specify a static pattern rule here.
-CSI_STAMPS = $(CSI_V0)-stamp
+CSI_STAMPS = $(CSI_V0)-stamp $(CSI_V1)-stamp
 $(CSI_STAMPS): csi-%-stamp: csi-%.tar.gz
 	$(MKDIR_P) csi-$*
 	gzip -d -c $^ | (cd csi-$* && tar xf -)
@@ -540,20 +543,30 @@ $(GRPC)-build-stamp:
 	touch $@
 endif
 
-# NOTE: To support multiple CSI versions, we move the CSI proto file to a
-# version-qualified path so `protoc` can find it.
+# NOTE: To support multiple CSI versions, we move the CSI proto files to
+# version-qualified paths so `protoc` can find them.
 $(CSI_V0)-build-stamp: $(CSI_V0)-stamp
 	$(MKDIR_P) $(CSI_V0)/csi/v0
 	mv $(CSI_V0)/spec-$(CSI_V0_VERSION)/csi.proto $(CSI_V0)/csi/v0
 	touch $@
 
+$(CSI_V1)-build-stamp: $(CSI_V1)-stamp
+	$(MKDIR_P) $(CSI_V1)/csi/v1
+	mv $(CSI_V1)/spec-$(CSI_V1_VERSION)/csi.proto $(CSI_V1)/csi/v1
+	touch $@
+
 # Mesos depends on CSI. Install the CSI proto file into $PREFIX/include but
 # don't add it to the source tarball.
 csi_v0dir = $(includedir)/csi/v0
 nodist_csi_v0_HEADERS = $(CSI_V0)/csi/v0/csi.proto
 $(nodist_csi_v0_HEADERS): $(CSI_V0)-build-stamp
 
+csi_v1dir = $(includedir)/csi/v1
+nodist_csi_v1_HEADERS = $(CSI_V1)/csi/v1/csi.proto
+$(nodist_csi_v1_HEADERS): $(CSI_V1)-build-stamp
+
 ALL_LOCAL += $(CSI_V0)-build-stamp
+ALL_LOCAL += $(CSI_V1)-build-stamp
 
 # Convenience library for gmock/gtest.
 check_LTLIBRARIES = libgmock.la
diff --git a/3rdparty/cmake/Versions.cmake b/3rdparty/cmake/Versions.cmake
index a67cb16..b42d52c 100644
--- a/3rdparty/cmake/Versions.cmake
+++ b/3rdparty/cmake/Versions.cmake
@@ -4,6 +4,8 @@ set(CONCURRENTQUEUE_VERSION "7b69a8f")
 set(CONCURRENTQUEUE_HASH    "SHA256=B2741A1FB2172C2A829503A85D5EE7548BE7ED04236A3FD1EFD2B6088E065CB7")
 set(CSI_V0_VERSION          "0.2.0")
 set(CSI_V0_HASH             "SHA256=B013F844C1E309B03FE6BCE9F186FEFA8910FCFAE7F8E6F7E4ACBEC166692F92")
+set(CSI_V1_VERSION          "1.1.0")
+set(CSI_V1_HASH             "SHA256=DF6DF163A1DC1130144D95BEE7725C7FA59F1A8676EAC188B209FCC28DA8379F")
 set(CURL_VERSION            "7.61.0")
 set(CURL_HASH               "SHA256=64141F0DB4945268A21B490D58806B97C615D3D0C75BF8C335BBE0EFD13B45B5")
 set(ELFIO_VERSION           "3.2")
diff --git a/3rdparty/csi-1.1.0.tar.gz b/3rdparty/csi-1.1.0.tar.gz
new file mode 100644
index 0000000..2cacd32
Binary files /dev/null and b/3rdparty/csi-1.1.0.tar.gz differ
diff --git a/3rdparty/versions.am b/3rdparty/versions.am
index b16132c..54daf00 100644
--- a/3rdparty/versions.am
+++ b/3rdparty/versions.am
@@ -22,6 +22,7 @@
 BOOST_VERSION = 1.65.0
 CONCURRENTQUEUE_VERSION = 7b69a8f
 CSI_V0_VERSION = 0.2.0
+CSI_V1_VERSION = 1.1.0
 ELFIO_VERSION = 3.2
 GLOG_VERSION = 0.3.3
 GOOGLETEST_VERSION = 1.8.0
diff --git a/configure.ac b/configure.ac
index 5302e66..a367c28 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1805,6 +1805,12 @@ if test "x$without_bundled_protobuf" = "xyes" || \
                     [AC_MSG_ERROR([cannot find PROTOBUF_JAR=$PROTOBUF_JAR])])
     fi
 
+    AC_CHECK_FILE([$PROTOBUFPREFIX/include/google/protobuf/wrappers.proto],
+                  [],
+                  [AC_MSG_ERROR([cannot find protobuf proto files])])
+
+    PROTOBUF_PROTOCFLAGS="-I${PROTOBUFPREFIX}/include"
+
     AC_CHECK_TOOL([PROTOCOMPILER_TEST], [protoc], [], [$PROTOBUFPREFIX/bin])
 
     if test -z "`echo $PROTOCOMPILER_TEST`"; then
@@ -1816,7 +1822,6 @@ if test "x$without_bundled_protobuf" = "xyes" || \
     if test "x$enable_python" = "xyes"; then
       AC_PYTHON_MODULE([google.protobuf], [yes])
     fi
-
   else
     AC_MSG_ERROR([cannot find protobuf
 -------------------------------------------------------------------
@@ -1840,6 +1845,7 @@ AM_CONDITIONAL([WITH_BUNDLED_PROTOBUF],
 AC_SUBST([PROTOBUF_CPPFLAGS])
 AC_SUBST([PROTOBUF_JAR])
 AC_SUBST([PROTOBUF_LINKERFLAGS])
+AC_SUBST([PROTOBUF_PROTOCFLAGS])
 AC_SUBST([PROTOCOMPILER])
 
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index af3715a..5ffeccd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -27,6 +27,7 @@ set(JAVA_PROTOBUF_SRC "")
 # NOTE: The following `PROTOC_GENERATE` calls will list append to
 # `PUBLIC_PROTOBUF_SRC`. The GRPC option is a noop if gRPC is disabled.
 PROTOC_GENERATE(GRPC LIB csi_v0 TARGET csi/v0/csi)
+PROTOC_GENERATE(GRPC LIB csi_v1 TARGET csi/v1/csi)
 
 # NOTE: The following `PROTOC_GENERATE` calls will list append to
 # `PUBLIC_PROTOBUF_SRC`.
diff --git a/src/Makefile.am b/src/Makefile.am
index a800444..6782e4b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,6 +27,7 @@ include ../3rdparty/versions.am
 BOOST = 3rdparty/boost-$(BOOST_VERSION)
 CONCURRENTQUEUE = 3rdparty/concurrentqueue-$(CONCURRENTQUEUE_VERSION)
 CSI_V0 = 3rdparty/csi-$(CSI_V0_VERSION)
+CSI_V1 = 3rdparty/csi-$(CSI_V1_VERSION)
 ELFIO = 3rdparty/elfio-$(ELFIO_VERSION)
 GLOG = 3rdparty/glog-$(GLOG_VERSION)
 GMOCK = $(GOOGLETEST)/googlemock
@@ -139,6 +140,9 @@ MESOS_CPPFLAGS += -I../include
 # Protobuf headers that depend on mesos.pb.h need this.
 MESOS_CPPFLAGS += -I../include/mesos
 
+# Set up include paths for the protocol buffer compiler.
+PROTOCFLAGS = -I$(top_srcdir)/include -I$(srcdir) -I../$(CSI_V0) -I../$(CSI_V1)
+
 # Header only dependencies will be ignored for --disable-bundled.
 #
 # For non-convenience libraries we need to link them in to make the shared
@@ -247,10 +251,12 @@ if WITH_BUNDLED_PROTOBUF
 MESOS_CPPFLAGS += -I../$(PROTOBUF)/src
 LIB_PROTOBUF = ../$(PROTOBUF)/src/libprotobuf.la
 PROTOC = ../$(PROTOBUF)/src/protoc
+PROTOCFLAGS += -I../$(PROTOBUF)/src
 else
 LIB_PROTOBUF = -lprotobuf
 LDADD += -lprotobuf
 PROTOC = @PROTOCOMPILER@
+PROTOCFLAGS += @PROTOBUF_PROTOCFLAGS@
 endif
 
 if WITH_BUNDLED_RAPIDJSON
@@ -270,9 +276,6 @@ LIB_ZOOKEEPER = -lzookeeper_mt
 LDADD += -lzookeeper_mt
 endif
 
-# Set up include paths for the protocol buffer compiler.
-PROTOCFLAGS = -I$(top_srcdir)/include -I$(srcdir) -I../$(CSI_V0)
-
 # 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
@@ -422,6 +425,10 @@ CXX_CSI_PROTOS =							\
   ../include/csi/v0/csi.grpc.pb.h					\
   ../include/csi/v0/csi.pb.cc						\
   ../include/csi/v0/csi.pb.h						\
+  ../include/csi/v1/csi.grpc.pb.cc					\
+  ../include/csi/v1/csi.grpc.pb.h					\
+  ../include/csi/v1/csi.pb.cc						\
+  ../include/csi/v1/csi.pb.h						\
   ../include/mesos/csi/types.pb.cc					\
   ../include/mesos/csi/types.pb.h					\
   csi/state.pb.cc							\
@@ -497,6 +504,10 @@ CLEANFILES +=								\
 	$(PROTOC) $(PROTOCFLAGS) --cpp_out=../include --grpc_out=../include	\
 		--plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN) $^
 
+../include/%.grpc.pb.cc ../include/%.grpc.pb.h ../include/%.pb.cc ../include/%.pb.h: ../$(CSI_V1)/%.proto
+	$(PROTOC) $(PROTOCFLAGS) --cpp_out=../include --grpc_out=../include	\
+		--plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN) $^
+
 # Targets for generating Java protocol buffer code.
 java/generated/org/apache/mesos/executor/Protos.java: $(EXECUTOR_PROTO)
 	$(MKDIR_P) $(@D)
@@ -711,6 +722,12 @@ nodist_csi_v0_HEADERS =							\
   ../include/csi/v0/csi.grpc.pb.h					\
   ../include/csi/v0/csi.pb.h
 
+csi_v1dir = $(includedir)/csi/v1
+
+nodist_csi_v1_HEADERS =							\
+  ../include/csi/v1/csi.grpc.pb.h					\
+  ../include/csi/v1/csi.pb.h
+
 dockerdir = $(pkgincludedir)/docker
 
 docker_HEADERS =							\
diff --git a/src/cmake/MesosProtobuf.cmake b/src/cmake/MesosProtobuf.cmake
index 9f7d79a..7011270 100644
--- a/src/cmake/MesosProtobuf.cmake
+++ b/src/cmake/MesosProtobuf.cmake
@@ -101,9 +101,15 @@ function(PROTOC_GENERATE)
     set(JAVA_OUT ${MESOS_BIN_SRC_DIR}/java/generated)
   endif()
 
+  get_target_property(
+    PROTOBUF_INCLUDE_DIR
+    protobuf
+    INTERFACE_INCLUDE_DIRECTORIES)
+
   set(PROTOC_OPTIONS
     -I${MESOS_PUBLIC_INCLUDE_DIR}
     -I${MESOS_SRC_DIR}
+    -I${PROTOBUF_INCLUDE_DIR}
     --cpp_out=${CPP_OUT})
 
   foreach (LIB_PROTO_PATH IN LISTS LIB_PROTO_PATHS)


[mesos] 03/04: Added the `mesos::csi::v1::Client` wrapper.

Posted by ch...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

chhsiao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 2b1336d307380768176db072c1dcb70bcbb2f891
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
AuthorDate: Fri Mar 29 16:33:18 2019 -0700

    Added the `mesos::csi::v1::Client` wrapper.
    
    The differences between CSI v0 and v1 client wrappers are summarized as
    follows:
    
      * Added snapshot related functions: `createSnapshot`,
        `deleteSnapshot` and `listSnapshots`.
    
      * Added volume expansion related functions: `controllerExpandVolume`
        and `nodeExpandVolume`.
    
      * Added volume statistics related functions: `nodeGetVolumeStats`.
    
      * Replaced `nodeGetId` with `nodeGetInfo`.
    
    Review: https://reviews.apache.org/r/70362
---
 src/CMakeLists.txt    |   1 +
 src/Makefile.am       |   2 +
 src/csi/v1_client.cpp | 282 ++++++++++++++++++++++++++++++++++++++++++++++++++
 src/csi/v1_client.hpp | 119 +++++++++++++++++++++
 4 files changed, 404 insertions(+)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0512044..51c7a04 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -242,6 +242,7 @@ set(CSI_SRC
   csi/v0_utils.cpp
   csi/v0_volume_manager.cpp
   csi/v1.cpp
+  csi/v1_client.cpp
   csi/volume_manager.cpp)
 
 set(DOCKER_SRC
diff --git a/src/Makefile.am b/src/Makefile.am
index 2f25a84..9c0180f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1596,6 +1596,8 @@ libcsi_la_SOURCES =							\
   csi/v0_volume_manager.hpp						\
   csi/v0_volume_manager_process.hpp					\
   csi/v1.cpp								\
+  csi/v1_client.cpp							\
+  csi/v1_client.hpp							\
   csi/volume_manager.cpp						\
   csi/volume_manager.hpp
 
diff --git a/src/csi/v1_client.cpp b/src/csi/v1_client.cpp
new file mode 100644
index 0000000..a19eb55
--- /dev/null
+++ b/src/csi/v1_client.cpp
@@ -0,0 +1,282 @@
+// 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/v1_client.hpp"
+
+#include <utility>
+
+using process::Future;
+
+using process::grpc::client::CallOptions;
+
+namespace mesos {
+namespace csi {
+namespace v1 {
+
+Future<RPCResult<GetPluginInfoResponse>>
+Client::getPluginInfo(GetPluginInfoRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Identity, GetPluginInfo),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<GetPluginCapabilitiesResponse>>
+Client::getPluginCapabilities(GetPluginCapabilitiesRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Identity, GetPluginCapabilities),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<ProbeResponse>> Client::probe(ProbeRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Identity, Probe),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<CreateVolumeResponse>>
+Client::createVolume(CreateVolumeRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Controller, CreateVolume),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<DeleteVolumeResponse>>
+Client::deleteVolume(DeleteVolumeRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Controller, DeleteVolume),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<ControllerPublishVolumeResponse>>
+Client::controllerPublishVolume(ControllerPublishVolumeRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Controller, ControllerPublishVolume),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<ControllerUnpublishVolumeResponse>>
+Client::controllerUnpublishVolume(ControllerUnpublishVolumeRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Controller, ControllerUnpublishVolume),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<ValidateVolumeCapabilitiesResponse>>
+Client::validateVolumeCapabilities(ValidateVolumeCapabilitiesRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Controller, ValidateVolumeCapabilities),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<ListVolumesResponse>>
+Client::listVolumes(ListVolumesRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Controller, ListVolumes),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<GetCapacityResponse>>
+Client::getCapacity(GetCapacityRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Controller, GetCapacity),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<ControllerGetCapabilitiesResponse>>
+Client::controllerGetCapabilities(ControllerGetCapabilitiesRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Controller, ControllerGetCapabilities),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<CreateSnapshotResponse>>
+Client::createSnapshot(CreateSnapshotRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Controller, CreateSnapshot),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<DeleteSnapshotResponse>>
+Client::deleteSnapshot(DeleteSnapshotRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Controller, DeleteSnapshot),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<ListSnapshotsResponse>>
+Client::listSnapshots(ListSnapshotsRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Controller, ListSnapshots),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<ControllerExpandVolumeResponse>>
+Client::controllerExpandVolume(ControllerExpandVolumeRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Controller, ControllerExpandVolume),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<NodeStageVolumeResponse>>
+Client::nodeStageVolume(NodeStageVolumeRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Node, NodeStageVolume),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<NodeUnstageVolumeResponse>>
+Client::nodeUnstageVolume(NodeUnstageVolumeRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Node, NodeUnstageVolume),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<NodePublishVolumeResponse>>
+Client::nodePublishVolume(NodePublishVolumeRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Node, NodePublishVolume),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<NodeUnpublishVolumeResponse>>
+Client::nodeUnpublishVolume(NodeUnpublishVolumeRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Node, NodeUnpublishVolume),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<NodeGetVolumeStatsResponse>>
+Client::nodeGetVolumeStats(NodeGetVolumeStatsRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Node, NodeGetVolumeStats),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<NodeExpandVolumeResponse>>
+Client::nodeExpandVolume(NodeExpandVolumeRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Node, NodeExpandVolume),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<NodeGetCapabilitiesResponse>>
+Client::nodeGetCapabilities(NodeGetCapabilitiesRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Node, NodeGetCapabilities),
+      std::move(request),
+      CallOptions());
+}
+
+
+Future<RPCResult<NodeGetInfoResponse>>
+Client::nodeGetInfo(NodeGetInfoRequest request)
+{
+  return runtime.call(
+      connection,
+      GRPC_CLIENT_METHOD(Node, NodeGetInfo),
+      std::move(request),
+      CallOptions());
+}
+
+} // namespace v1 {
+} // namespace csi {
+} // namespace mesos {
diff --git a/src/csi/v1_client.hpp b/src/csi/v1_client.hpp
new file mode 100644
index 0000000..992276a
--- /dev/null
+++ b/src/csi/v1_client.hpp
@@ -0,0 +1,119 @@
+// 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_V1_CLIENT_HPP__
+#define __CSI_V1_CLIENT_HPP__
+
+#include <mesos/csi/v1.hpp>
+
+#include <process/future.hpp>
+#include <process/grpc.hpp>
+
+#include <stout/try.hpp>
+
+namespace mesos {
+namespace csi {
+namespace v1 {
+
+template <typename Response>
+using RPCResult = Try<Response, process::grpc::StatusError>;
+
+
+class Client
+{
+public:
+  Client(const process::grpc::client::Connection& _connection,
+         const process::grpc::client::Runtime& _runtime)
+    : connection(_connection), runtime(_runtime) {}
+
+  process::Future<RPCResult<GetPluginInfoResponse>>
+  getPluginInfo(GetPluginInfoRequest request);
+
+  process::Future<RPCResult<GetPluginCapabilitiesResponse>>
+  getPluginCapabilities(GetPluginCapabilitiesRequest request);
+
+  process::Future<RPCResult<ProbeResponse>> probe(ProbeRequest request);
+
+  process::Future<RPCResult<CreateVolumeResponse>>
+  createVolume(CreateVolumeRequest request);
+
+  process::Future<RPCResult<DeleteVolumeResponse>>
+  deleteVolume(DeleteVolumeRequest request);
+
+  process::Future<RPCResult<ControllerPublishVolumeResponse>>
+  controllerPublishVolume(ControllerPublishVolumeRequest request);
+
+  process::Future<RPCResult<ControllerUnpublishVolumeResponse>>
+  controllerUnpublishVolume(ControllerUnpublishVolumeRequest request);
+
+  process::Future<RPCResult<ValidateVolumeCapabilitiesResponse>>
+  validateVolumeCapabilities(ValidateVolumeCapabilitiesRequest request);
+
+  process::Future<RPCResult<ListVolumesResponse>>
+  listVolumes(ListVolumesRequest request);
+
+  process::Future<RPCResult<GetCapacityResponse>>
+  getCapacity(GetCapacityRequest request);
+
+  process::Future<RPCResult<ControllerGetCapabilitiesResponse>>
+  controllerGetCapabilities(ControllerGetCapabilitiesRequest request);
+
+  process::Future<RPCResult<CreateSnapshotResponse>>
+  createSnapshot(CreateSnapshotRequest request);
+
+  process::Future<RPCResult<DeleteSnapshotResponse>>
+  deleteSnapshot(DeleteSnapshotRequest request);
+
+  process::Future<RPCResult<ListSnapshotsResponse>>
+  listSnapshots(ListSnapshotsRequest request);
+
+  process::Future<RPCResult<ControllerExpandVolumeResponse>>
+  controllerExpandVolume(ControllerExpandVolumeRequest request);
+
+  process::Future<RPCResult<NodeStageVolumeResponse>>
+  nodeStageVolume(NodeStageVolumeRequest request);
+
+  process::Future<RPCResult<NodeUnstageVolumeResponse>>
+  nodeUnstageVolume(NodeUnstageVolumeRequest request);
+
+  process::Future<RPCResult<NodePublishVolumeResponse>>
+  nodePublishVolume(NodePublishVolumeRequest request);
+
+  process::Future<RPCResult<NodeUnpublishVolumeResponse>>
+  nodeUnpublishVolume(NodeUnpublishVolumeRequest request);
+
+  process::Future<RPCResult<NodeGetVolumeStatsResponse>>
+  nodeGetVolumeStats(NodeGetVolumeStatsRequest request);
+
+  process::Future<RPCResult<NodeExpandVolumeResponse>>
+  nodeExpandVolume(NodeExpandVolumeRequest request);
+
+  process::Future<RPCResult<NodeGetCapabilitiesResponse>>
+  nodeGetCapabilities(NodeGetCapabilitiesRequest request);
+
+  process::Future<RPCResult<NodeGetInfoResponse>>
+  nodeGetInfo(NodeGetInfoRequest request);
+
+private:
+  process::grpc::client::Connection connection;
+  process::grpc::client::Runtime runtime;
+};
+
+} // namespace v1 {
+} // namespace csi {
+} // namespace mesos {
+
+#endif // __CSI_V1_CLIENT_HPP__