You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by gr...@apache.org on 2020/09/03 20:59:34 UTC
[mesos] 02/03: Added a test helper for CSI volumes.
This is an automated email from the ASF dual-hosted git repository.
grag pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit f0ce0f1d8601228f16efbb98420693af42b19d43
Author: Greg Mann <gr...@mesosphere.io>
AuthorDate: Thu Sep 3 12:06:34 2020 -0700
Added a test helper for CSI volumes.
Review: https://reviews.apache.org/r/72805/
---
src/tests/mesos.hpp | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 76 insertions(+)
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index 8f89d7c..49abfc2 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -853,6 +853,66 @@ inline TVolume createVolumeFromDockerImage(
}
+template <typename TVolume>
+inline TVolume createVolumeCsi(
+ const std::string& pluginName,
+ const std::string volumeId,
+ const std::string& containerPath,
+ const typename TVolume::Source::CSIVolume::VolumeCapability
+ ::AccessMode::Mode mode,
+ bool readonly)
+{
+ TVolume volume;
+ volume.set_container_path(containerPath);
+
+ typename TVolume::Source* source = volume.mutable_source();
+ source->set_type(TVolume::Source::CSI_VOLUME);
+ source->mutable_csi_volume()->set_plugin_name(pluginName);
+
+ typename TVolume::Source::CSIVolume::StaticProvisioning* staticInfo =
+ source->mutable_csi_volume()->mutable_static_provisioning();
+
+ staticInfo->set_volume_id(volumeId);
+ staticInfo->set_readonly(readonly);
+ staticInfo->mutable_volume_capability()->mutable_mount();
+ staticInfo->mutable_volume_capability()
+ ->mutable_access_mode()->set_mode(mode);
+
+ typedef typename TVolume::Source::CSIVolume::VolumeCapability::AccessMode
+ CSIAccessMode;
+
+ // Set the top-level `mode` field of the volume based on the values of the
+ // CSI access mode and the `readonly` field.
+ typename TVolume::Mode mesosMode;
+
+ switch (mode) {
+ case CSIAccessMode::SINGLE_NODE_WRITER:
+ case CSIAccessMode::MULTI_NODE_SINGLE_WRITER:
+ case CSIAccessMode::MULTI_NODE_MULTI_WRITER: {
+ if (readonly) {
+ mesosMode = TVolume::RO;
+ } else {
+ mesosMode = TVolume::RW;
+ }
+
+ break;
+ }
+
+ case CSIAccessMode::SINGLE_NODE_READER_ONLY:
+ case CSIAccessMode::MULTI_NODE_READER_ONLY:
+ default: {
+ mesosMode = TVolume::RO;
+
+ break;
+ }
+ }
+
+ volume.set_mode(mesosMode);
+
+ return volume;
+}
+
+
template <typename TNetworkInfo>
inline TNetworkInfo createNetworkInfo(
const std::string& networkName)
@@ -1745,6 +1805,14 @@ inline Volume createVolumeFromDockerImage(Args&&... args)
template <typename... Args>
+inline Volume createVolumeCsi(Args&&... args)
+{
+ return common::createVolumeCsi<Volume>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
inline NetworkInfo createNetworkInfo(Args&&... args)
{
return common::createNetworkInfo<NetworkInfo>(std::forward<Args>(args)...);
@@ -2035,6 +2103,14 @@ inline mesos::v1::Volume createVolumeFromDockerImage(Args&&... args)
template <typename... Args>
+inline mesos::v1::Volume createVolumeCsi(Args&&... args)
+{
+ return common::createVolumeCsi<mesos::v1::Volume>(
+ std::forward<Args>(args)...);
+}
+
+
+template <typename... Args>
inline mesos::v1::NetworkInfo createNetworkInfo(Args&&... args)
{
return common::createNetworkInfo<mesos::v1::NetworkInfo>(