17 #ifndef __TESTS_MESOS_HPP__ 18 #define __TESTS_MESOS_HPP__ 25 #include <gmock/gmock.h> 79 #include "master/master.hpp" 95 #include "tests/utils.hpp" 99 #endif // MESOS_HAS_JAVA 103 using ::testing::DoDefault;
104 using ::testing::Invoke;
105 using ::testing::Return;
115 "72kUKUFtghAjNbIOvLzfF2RxNBfeM64Bri8g9WhpyaunwqRB/yozHAqSnyHbddAV" 116 "PcWRQlrJAt871oWgSH+n52vMZ3aVI+AFMzXSo8+sUfMk83IGp0WJefhzeQsjDlGH" 117 "GYQgCAuGim0BE2X5U+lEue8s697uQpAO8L/FFRuDH2s";
225 static void SetUpTestCase();
226 static void TearDownTestCase();
232 virtual master::Flags CreateMasterFlags();
255 const std::shared_ptr<MockRateLimiter>& slaveRemovalLimiter,
280 const std::string&
id,
288 const std::string&
id,
373 const std::string defaultAgentResourcesString{
375 "cpus:4;gpus:0;mem:2048;disk:1024;ports:[31000-32000]" 377 "cpus:2;gpus:0;mem:1024;disk:1024;ports:[31000-32000]" 378 #endif // __WINDOWS__ 381 const std::string defaultTaskResourcesString{
383 "cpus:1;mem:512;disk:32" 385 "cpus:0.1;mem:32;disk:32" 386 #endif // __WINDOWS__ 391 template <
typename T>
396 const static std::string TEST_CGROUPS_HIERARCHY =
"/tmp/mesos_test_cgroup";
399 const static std::string TEST_CGROUPS_ROOT =
"mesos_test";
406 static void SetUpTestCase();
407 static void TearDownTestCase();
411 void SetUp()
override;
412 void TearDown()
override;
418 std::string baseHierarchy;
433 #ifdef MESOS_HAS_JAVA 435 class MesosZooKeeperTest :
public MesosTest 438 static void SetUpTestCase()
445 server->startNetwork();
448 "zk://" + server->connectString() +
"/znode");
454 static void TearDownTestCase()
460 void SetUp()
override 463 server->startNetwork();
466 void TearDown()
override 468 server->shutdownNetwork();
475 master::Flags CreateMasterFlags()
override 490 #endif // MESOS_HAS_JAVA 500 namespace maintenance = mesos::v1::maintenance;
502 namespace quota = mesos::v1::quota;
504 using mesos::v1::OPERATION_PENDING;
505 using mesos::v1::OPERATION_FINISHED;
506 using mesos::v1::OPERATION_FAILED;
507 using mesos::v1::OPERATION_ERROR;
508 using mesos::v1::OPERATION_DROPPED;
509 using mesos::v1::OPERATION_UNREACHABLE;
510 using mesos::v1::OPERATION_GONE_BY_OPERATOR;
511 using mesos::v1::OPERATION_RECOVERING;
512 using mesos::v1::OPERATION_UNKNOWN;
514 using mesos::v1::TASK_STAGING;
515 using mesos::v1::TASK_STARTING;
516 using mesos::v1::TASK_RUNNING;
517 using mesos::v1::TASK_KILLING;
518 using mesos::v1::TASK_FINISHED;
519 using mesos::v1::TASK_FAILED;
520 using mesos::v1::TASK_KILLED;
521 using mesos::v1::TASK_ERROR;
522 using mesos::v1::TASK_LOST;
523 using mesos::v1::TASK_DROPPED;
524 using mesos::v1::TASK_UNREACHABLE;
525 using mesos::v1::TASK_GONE;
526 using mesos::v1::TASK_GONE_BY_OPERATOR;
527 using mesos::v1::TASK_UNKNOWN;
529 using mesos::v1::AgentID;
530 using mesos::v1::CheckInfo;
531 using mesos::v1::CommandInfo;
532 using mesos::v1::ContainerID;
533 using mesos::v1::ContainerStatus;
534 using mesos::v1::Environment;
535 using mesos::v1::ExecutorID;
536 using mesos::v1::ExecutorInfo;
537 using mesos::v1::Filters;
538 using mesos::v1::FrameworkID;
539 using mesos::v1::FrameworkInfo;
540 using mesos::v1::HealthCheck;
541 using mesos::v1::InverseOffer;
542 using mesos::v1::MachineID;
543 using mesos::v1::Metric;
544 using mesos::v1::Offer;
545 using mesos::v1::OperationID;
546 using mesos::v1::OperationState;
547 using mesos::v1::OperationStatus;
548 using mesos::v1::Resource;
549 using mesos::v1::ResourceProviderID;
550 using mesos::v1::ResourceProviderInfo;
552 using mesos::v1::TaskID;
553 using mesos::v1::TaskInfo;
554 using mesos::v1::TaskGroupInfo;
555 using mesos::v1::TaskState;
556 using mesos::v1::TaskStatus;
557 using mesos::v1::UUID;
558 using mesos::v1::WeightInfo;
564 template <
typename TCredential>
569 TCredential credential;
570 credential.set_principal(
"test-principal");
571 credential.set_secret(
"test-secret");
578 template <
typename TCredential>
583 TCredential credential;
584 credential.set_principal(
"test-principal-2");
585 credential.set_secret(
"test-secret-2");
591 template <
typename TFrameworkInfo,
typename TCredential>
596 TFrameworkInfo framework;
597 framework.set_name(
"default");
598 framework.set_user(
os::user().
get());
599 framework.set_principal(
601 framework.add_roles(
"*");
602 framework.add_capabilities()->set_type(
603 TFrameworkInfo::Capability::MULTI_ROLE);
604 framework.add_capabilities()->set_type(
605 TFrameworkInfo::Capability::RESERVATION_REFINEMENT);
635 template <
typename TCommandInfo>
638 const std::vector<std::string>& arguments = {})
640 TCommandInfo commandInfo;
641 if (value.isSome()) {
642 commandInfo.set_value(value.get());
644 if (!arguments.empty()) {
645 commandInfo.set_shell(
false);
646 foreach (
const std::string& arg, arguments) {
647 commandInfo.add_arguments(arg);
654 template <
typename TExecutorInfo,
655 typename TExecutorID,
657 typename TCommandInfo,
658 typename TFrameworkID>
660 const TExecutorID& executorId,
666 TExecutorInfo executor;
667 executor.mutable_executor_id()->CopyFrom(executorId);
669 executor.mutable_command()->CopyFrom(command.
get());
672 executor.mutable_resources()->CopyFrom(resources.
get());
675 executor.set_type(type.
get());
677 if (frameworkId.
isSome()) {
678 executor.mutable_framework_id()->CopyFrom(frameworkId.
get());
684 template <
typename TExecutorInfo,
685 typename TExecutorID,
687 typename TCommandInfo,
688 typename TFrameworkID>
690 const std::string& _executorId,
696 TExecutorID executorId;
697 executorId.set_value(_executorId);
703 executorId, command, resources,
type, frameworkId);
707 template <
typename TExecutorInfo,
708 typename TExecutorID,
710 typename TCommandInfo,
711 typename TFrameworkID>
713 const std::string& executorId,
719 if (resources.isSome()) {
741 template <
typename TExecutorInfo,
742 typename TExecutorID,
744 typename TCommandInfo,
745 typename TFrameworkID>
747 const TExecutorID& executorId,
749 const std::string& resources,
766 template <
typename TExecutorInfo,
767 typename TExecutorID,
769 typename TCommandInfo,
770 typename TFrameworkID>
772 const std::string& executorId,
773 const std::string& command,
778 TCommandInfo commandInfo = createCommandInfo<TCommandInfo>(command);
784 executorId, commandInfo, resources,
type, frameworkId);
788 template <
typename TImage>
792 image.set_type(TImage::DOCKER);
793 image.mutable_docker()->set_name(imageName);
798 template <
typename TVolume>
800 const std::string& containerPath,
801 const std::string& sandboxPath,
805 volume.set_container_path(containerPath);
806 volume.set_mode(mode);
809 volume.set_host_path(sandboxPath);
815 template <
typename TVolume,
typename TMountPropagation>
817 const std::string& containerPath,
818 const std::string& hostPath,
824 volume.set_container_path(containerPath);
825 volume.set_mode(mode);
827 typename TVolume::Source* source = volume.mutable_source();
828 source->set_type(TVolume::Source::HOST_PATH);
829 source->mutable_host_path()->set_path(hostPath);
831 if (mountPropagationMode.isSome()) {
833 ->mutable_host_path()
834 ->mutable_mount_propagation()
835 ->set_mode(mountPropagationMode.get());
842 template <
typename TVolume,
typename TImage>
844 const std::string& containerPath,
845 const std::string& imageName,
849 volume.set_container_path(containerPath);
850 volume.set_mode(mode);
851 volume.mutable_image()->CopyFrom(createDockerImage<TImage>(imageName));
856 template <
typename TVolume>
858 const std::string& pluginName,
859 const std::string& volumeId,
860 const std::string& containerPath,
862 const typename TVolume::Source::CSIVolume::VolumeCapability
866 volume.set_container_path(containerPath);
867 volume.set_mode(mode);
869 typename TVolume::Source* source = volume.mutable_source();
870 source->set_type(TVolume::Source::CSI_VOLUME);
871 source->mutable_csi_volume()->set_plugin_name(pluginName);
873 typename TVolume::Source::CSIVolume::StaticProvisioning* staticInfo =
874 source->mutable_csi_volume()->mutable_static_provisioning();
876 staticInfo->set_volume_id(volumeId);
877 staticInfo->mutable_volume_capability()->mutable_mount();
878 staticInfo->mutable_volume_capability()
879 ->mutable_access_mode()->set_mode(accessMode);
885 template <
typename TNetworkInfo>
887 const std::string& networkName)
890 info.set_name(networkName);
895 template <
typename TContainerInfo,
typename TVolume,
typename TImage>
898 const std::vector<TVolume>& volumes = {})
901 info.set_type(TContainerInfo::MESOS);
903 if (imageName.isSome()) {
904 TImage*
image = info.mutable_mesos()->mutable_image();
905 image->CopyFrom(createDockerImage<TImage>(imageName.get()));
908 foreach (
const TVolume& volume, volumes) {
909 info.add_volumes()->CopyFrom(volume);
918 return offer.slave_id();
922 inline mesos::v1::AgentID
getAgentID(
const mesos::v1::Offer& offer)
924 return offer.agent_id();
928 inline void setAgentID(TaskInfo* task,
const SlaveID& slaveId)
930 task->mutable_slave_id()->CopyFrom(slaveId);
935 mesos::v1::TaskInfo* task,
936 const mesos::v1::AgentID& agentId)
938 task->mutable_agent_id()->CopyFrom(agentId);
946 typename TExecutorID,
949 typename TExecutorInfo,
950 typename TCommandInfo,
954 const TSlaveID& slaveId,
955 const TResources& resourceRequests,
956 const TCommandInfo& command,
958 const std::string&
name =
"test-task",
960 const google::protobuf::Map<std::string, TScalar>& resourceLimits = {})
964 task.mutable_task_id()->set_value(
id);
966 task.mutable_resources()->CopyFrom(resourceRequests);
967 if (!resourceLimits.empty()) {
968 *task.mutable_limits() = resourceLimits;
970 if (executorId.isSome()) {
971 TExecutorInfo executor;
972 executor.mutable_executor_id()->CopyFrom(executorId.get());
973 executor.mutable_command()->CopyFrom(command);
974 task.mutable_executor()->CopyFrom(executor);
976 task.mutable_command()->CopyFrom(command);
985 typename TExecutorID,
988 typename TExecutorInfo,
989 typename TCommandInfo,
993 const TSlaveID& slaveId,
994 const TResources& resourceRequests,
995 const std::string& command,
997 const std::string&
name =
"test-task",
999 const google::protobuf::Map<std::string, TScalar>& resourceLimits = {})
1012 createCommandInfo<TCommandInfo>(command),
1022 typename TExecutorID,
1024 typename TResources,
1025 typename TExecutorInfo,
1026 typename TCommandInfo,
1030 const TOffer& offer,
1031 const std::string& command,
1033 const std::string&
name =
"test-task",
1035 const google::protobuf::Map<std::string, TScalar>& resourceLimits = {})
1056 template <
typename TTaskGroupInfo,
typename TTaskInfo>
1059 TTaskGroupInfo taskGroup;
1060 foreach (
const TTaskInfo& task, tasks) {
1061 taskGroup.add_tasks()->CopyFrom(task);
1067 template <
typename TResource>
1069 const std::string& role)
1071 typename TResource::ReservationInfo info;
1072 info.set_type(TResource::ReservationInfo::STATIC);
1073 info.set_role(role);
1078 template <
typename TResource,
typename TLabels>
1080 const std::string& role,
1084 typename TResource::ReservationInfo info;
1086 info.set_type(TResource::ReservationInfo::DYNAMIC);
1087 info.set_role(role);
1089 if (principal.isSome()) {
1090 info.set_principal(principal.get());
1093 if (labels.isSome()) {
1094 info.mutable_labels()->CopyFrom(labels.get());
1103 typename TResources,
1104 typename... TReservationInfos>
1106 const std::string&
name,
1107 const std::string& value,
1108 const TReservationInfos&... reservations)
1110 std::initializer_list<typename TResource::ReservationInfo> reservations_ = {
1115 resource.mutable_reservations()->CopyFrom(
1116 google::protobuf::RepeatedPtrField<typename TResource::ReservationInfo>{
1117 reservations_.begin(), reservations_.end()});
1126 template <
typename TResource,
typename TVolume>
1135 typename TResource::DiskInfo info;
1137 if (persistenceId.
isSome()) {
1138 info.mutable_persistence()->set_id(persistenceId.
get());
1141 if (principal.isSome()) {
1142 info.mutable_persistence()->set_principal(principal.get());
1145 if (containerPath.
isSome()) {
1147 volume.set_container_path(containerPath.
get());
1148 volume.set_mode(mode.isSome() ? mode.get() : TVolume::RW);
1150 if (hostPath.isSome()) {
1151 volume.set_host_path(hostPath.get());
1154 info.mutable_volume()->CopyFrom(volume);
1157 if (source.isSome()) {
1158 info.mutable_source()->CopyFrom(source.get());
1166 template <
typename TResource>
1172 typename TResource::DiskInfo::Source source;
1174 source.set_type(TResource::DiskInfo::Source::PATH);
1176 if (root.isSome()) {
1177 source.mutable_path()->set_root(root.get());
1181 source.set_id(
id.
get());
1184 if (profile.isSome()) {
1185 source.set_profile(profile.get());
1193 template <
typename TResource>
1199 typename TResource::DiskInfo::Source source;
1201 source.set_type(TResource::DiskInfo::Source::MOUNT);
1203 if (root.isSome()) {
1204 source.mutable_mount()->set_root(root.get());
1208 source.set_id(
id.
get());
1211 if (profile.isSome()) {
1212 source.set_profile(profile.get());
1220 template <
typename TResource>
1225 typename TResource::DiskInfo::Source source;
1227 source.set_type(TResource::DiskInfo::Source::BLOCK);
1230 source.set_id(
id.
get());
1233 if (profile.isSome()) {
1234 source.set_profile(profile.get());
1242 template <
typename TResource>
1247 typename TResource::DiskInfo::Source source;
1249 source.set_type(TResource::DiskInfo::Source::RAW);
1252 source.set_id(
id.
get());
1255 if (profile.isSome()) {
1256 source.set_profile(profile.get());
1264 template <
typename TResource,
typename TResources,
typename TVolume>
1266 const std::string& value,
1267 const std::string& role,
1271 bool isShared =
false)
1275 if (persistenceID.
isSome() || containerPath.
isSome() || source.isSome()) {
1276 resource.mutable_disk()->CopyFrom(
1277 createDiskInfo<TResource, TVolume>(
1285 resource.mutable_shared();
1295 template <
typename TResource,
typename TResources,
typename TVolume>
1298 const std::string& role,
1299 const std::string& persistenceId,
1300 const std::string& containerPath,
1304 bool isShared =
false)
1311 volume.mutable_disk()->CopyFrom(
1312 createDiskInfo<TResource, TVolume>(
1320 if (reservationPrincipal.isSome()) {
1321 typename TResource::ReservationInfo& reservation =
1322 *volume.mutable_reservations()->rbegin();
1324 reservation.set_type(TResource::ReservationInfo::DYNAMIC);
1325 reservation.set_principal(reservationPrincipal.get());
1329 volume.mutable_shared();
1338 template <
typename TResource,
typename TResources,
typename TVolume>
1341 const std::string& persistenceId,
1342 const std::string& containerPath,
1345 bool isShared =
false)
1348 if (volume.has_disk() && volume.disk().has_source()) {
1349 source = volume.disk().source();
1352 volume.mutable_disk()->CopyFrom(
1353 createDiskInfo<TResource, TVolume>(
1361 if (reservationPrincipal.isSome()) {
1362 typename TResource::ReservationInfo& reservation =
1363 *volume.mutable_reservations()->rbegin();
1365 reservation.set_type(TResource::ReservationInfo::DYNAMIC);
1366 reservation.set_principal(reservationPrincipal.get());
1370 volume.mutable_shared();
1377 template <
typename TCredential>
1379 const TCredential& credential)
1384 base64::encode(credential.principal() +
":" + credential.secret())
1390 template <
typename TWeightInfo>
1392 const std::string& weightsFlag)
1394 google::protobuf::RepeatedPtrField<TWeightInfo>
infos;
1396 foreach (
const std::string& token, tokens) {
1398 EXPECT_EQ(2u, pair.size());
1399 double weight = atof(pair[1].c_str());
1400 TWeightInfo weightInfo;
1401 weightInfo.set_role(pair[0]);
1402 weightInfo.set_weight(weight);
1403 infos.Add()->CopyFrom(weightInfo);
1411 template <
typename TWeightInfo>
1413 const google::protobuf::RepeatedPtrField<TWeightInfo> weightInfos)
1417 foreach (
const TWeightInfo& weightInfo, weightInfos) {
1418 weights[weightInfo.role()] = weightInfo.weight();
1426 template <
typename TDomainInfo>
1428 const std::string& regionName,
1429 const std::string& zoneName)
1433 domain.mutable_fault_domain()->mutable_region()->set_name(regionName);
1434 domain.mutable_fault_domain()->mutable_zone()->set_name(zoneName);
1441 template <
typename TResources,
typename TOperationID,
typename TOffer>
1443 const TResources& resources,
1448 operation.mutable_reserve()->mutable_resources()->CopyFrom(resources);
1450 if (operationId.isSome()) {
1451 *operation.mutable_id() = operationId.get();
1458 template <
typename TResources,
typename TOperationID,
typename TOffer>
1460 const TResources& resources,
1465 operation.mutable_unreserve()->mutable_resources()->CopyFrom(resources);
1467 if (operationId.isSome()) {
1468 *operation.mutable_id() = operationId.get();
1475 template <
typename TResources,
typename TOperationID,
typename TOffer>
1477 const TResources& volumes,
1482 operation.mutable_create()->mutable_volumes()->CopyFrom(volumes);
1484 if (operationId.isSome()) {
1485 *operation.mutable_id() = operationId.get();
1492 template <
typename TResources,
typename TOperationID,
typename TOffer>
1494 const TResources& volumes,
1499 operation.mutable_destroy()->mutable_volumes()->CopyFrom(volumes);
1501 if (operationId.isSome()) {
1502 *operation.mutable_id() = operationId.get();
1509 template <
typename TResource,
typename TOperationID,
typename TOffer>
1511 const TResource& volume,
1512 const TResource& addition,
1517 operation.mutable_grow_volume()->mutable_volume()->CopyFrom(volume);
1518 operation.mutable_grow_volume()->mutable_addition()->CopyFrom(addition);
1520 if (operationId.isSome()) {
1521 *operation.mutable_id() = operationId.get();
1530 typename TValueScalar,
1531 typename TOperationID,
1534 const TResource& volume,
1535 const TValueScalar& subtract,
1540 operation.mutable_shrink_volume()->mutable_volume()->CopyFrom(volume);
1541 operation.mutable_shrink_volume()->mutable_subtract()->CopyFrom(subtract);
1543 if (operationId.isSome()) {
1544 *operation.mutable_id() = operationId.get();
1551 template <
typename TOffer,
typename TTaskInfo>
1557 foreach (
const TTaskInfo& task, tasks) {
1558 operation.mutable_launch()->add_task_infos()->CopyFrom(task);
1565 template <
typename TExecutorInfo,
typename TTaskGroupInfo,
typename TOffer>
1567 const TExecutorInfo& executorInfo,
1568 const TTaskGroupInfo& taskGroup)
1572 operation.mutable_launch_group()->mutable_executor()->CopyFrom(executorInfo);
1573 operation.mutable_launch_group()->mutable_task_group()->CopyFrom(taskGroup);
1580 typename TTargetType,
1581 typename TOperationID,
1584 const TResource& source,
1585 const TTargetType& targetType,
1591 operation.mutable_create_disk()->mutable_source()->CopyFrom(source);
1592 operation.mutable_create_disk()->set_target_type(targetType);
1594 if (targetProfile.isSome()) {
1595 operation.mutable_create_disk()->set_target_profile(targetProfile.get());
1598 if (operationId.isSome()) {
1599 operation.mutable_id()->CopyFrom(operationId.get());
1606 template <
typename TResource,
typename TOperationID,
typename TOffer>
1612 operation.mutable_destroy_disk()->mutable_source()->CopyFrom(source);
1614 if (operationId.isSome()) {
1615 operation.mutable_id()->CopyFrom(operationId.get());
1622 template <
typename TParameters,
typename TParameter>
1625 TParameters parameters;
1626 TParameter* parameter = parameters.add_parameter();
1627 parameter->set_key(
"acls");
1638 template <
typename... Args>
1646 FrameworkID>(std::forward<Args>(args)...);
1653 const std::vector<std::string>& arguments = {})
1655 return common::createCommandInfo<CommandInfo>(value, arguments);
1662 const ExecutorInfo& executorInfo,
1663 const std::string& sandboxDirectory,
1666 mesos::slave::ContainerConfig containerConfig;
1667 containerConfig.mutable_executor_info()->CopyFrom(executorInfo);
1668 containerConfig.mutable_command_info()->CopyFrom(executorInfo.command());
1669 containerConfig.mutable_resources()->CopyFrom(executorInfo.resources());
1670 containerConfig.set_directory(sandboxDirectory);
1672 if (
user.isSome()) {
1673 containerConfig.set_user(
user.get());
1677 containerConfig.mutable_task_info()->CopyFrom(taskInfo.
get());
1679 if (taskInfo->has_container()) {
1680 containerConfig.mutable_container_info()->CopyFrom(taskInfo->container());
1683 if (executorInfo.has_container()) {
1684 containerConfig.mutable_container_info()
1685 ->CopyFrom(executorInfo.container());
1689 return containerConfig;
1695 const CommandInfo& commandInfo,
1700 mesos::slave::ContainerConfig containerConfig;
1701 containerConfig.mutable_command_info()->CopyFrom(commandInfo);
1703 if (
user.isSome()) {
1704 containerConfig.set_user(
user.get());
1707 if (containerInfo.isSome()) {
1708 containerConfig.mutable_container_info()->CopyFrom(containerInfo.get());
1711 if (containerClass.isSome()) {
1712 containerConfig.set_container_class(containerClass.get());
1715 return containerConfig;
1721 const CommandInfo& commandInfo,
1722 const std::string& resources,
1723 const std::string& sandboxDirectory,
1727 mesos::slave::ContainerConfig containerConfig;
1728 containerConfig.mutable_command_info()->CopyFrom(commandInfo);
1729 containerConfig.mutable_resources()->CopyFrom(
1732 containerConfig.set_directory(sandboxDirectory);
1734 if (
user.isSome()) {
1735 containerConfig.set_user(
user.get());
1738 if (containerInfo.isSome()) {
1739 containerConfig.mutable_container_info()->CopyFrom(containerInfo.get());
1742 return containerConfig;
1746 template <
typename... Args>
1749 return common::createDockerImage<Image>(std::forward<Args>(args)...);
1753 template <
typename... Args>
1756 return common::createVolumeSandboxPath<Volume>(std::forward<Args>(args)...);
1760 template <
typename... Args>
1763 return common::createVolumeHostPath<Volume, MountPropagation>(
1764 std::forward<Args>(args)...);
1768 template <
typename... Args>
1771 return common::createVolumeFromDockerImage<Volume, Image>(
1772 std::forward<Args>(args)...);
1776 template <
typename... Args>
1779 return common::createVolumeCsi<Volume>(
1780 std::forward<Args>(args)...);
1784 template <
typename... Args>
1787 return common::createNetworkInfo<NetworkInfo>(std::forward<Args>(args)...);
1794 const std::vector<Volume>& volumes = {})
1796 return common::createContainerInfo<ContainerInfo, Volume, Image>(
1802 template <
typename... Args>
1813 Value::Scalar>(std::forward<Args>(args)...);
1820 return common::createTaskGroupInfo<TaskGroupInfo, TaskInfo>(tasks);
1825 const std::string& role)
1827 return common::createStaticReservationInfo<Resource>(role);
1832 const std::string& role,
1836 return common::createDynamicReservationInfo<Resource, Labels>(
1837 role, principal, labels);
1841 template <
typename... Args>
1844 return common::createReservedResource<Resource, Resources>(
1845 std::forward<Args>(args)...);
1849 template <
typename... Args>
1852 return common::createDiskInfo<Resource, Volume>(std::forward<Args>(args)...);
1856 template <
typename... Args>
1859 return common::createDiskSourcePath<Resource>(std::forward<Args>(args)...);
1863 template <
typename... Args>
1866 return common::createDiskSourceMount<Resource>(std::forward<Args>(args)...);
1870 template <
typename... Args>
1873 return common::createDiskSourceBlock<Resource>(std::forward<Args>(args)...);
1877 template <
typename... Args>
1880 return common::createDiskSourceRaw<Resource>(std::forward<Args>(args)...);
1884 template <
typename... Args>
1887 return common::createDiskResource<Resource, Resources, Volume>(
1888 std::forward<Args>(args)...);
1892 template <
typename... Args>
1895 return common::createPersistentVolume<Resource, Resources, Volume>(
1896 std::forward<Args>(args)...);
1900 template <
typename... Args>
1903 return common::createBasicAuthHeaders<Credential>(
1904 std::forward<Args>(args)...);
1908 template <
typename... Args>
1912 return common::createWeightInfos<WeightInfo>(std::forward<Args>(args)...);
1916 template <
typename... Args>
1919 return common::convertToHashmap<WeightInfo>(std::forward<Args>(args)...);
1923 template <
typename... Args>
1926 return common::createDomainInfo<DomainInfo>(std::forward<Args>(args)...);
1930 template <
typename... Args>
1933 return common::RESERVE<Resources, OperationID, Offer>(
1934 std::forward<Args>(args)...);
1938 template <
typename... Args>
1941 return common::UNRESERVE<Resources, OperationID, Offer>(
1942 std::forward<Args>(args)...);
1946 template <
typename... Args>
1949 return common::CREATE<Resources, OperationID, Offer>(
1950 std::forward<Args>(args)...);
1954 template <
typename... Args>
1957 return common::DESTROY<Resources, OperationID, Offer>(
1958 std::forward<Args>(args)...);
1962 template <
typename... Args>
1965 return common::GROW_VOLUME<Resource, OperationID, Offer>(
1966 std::forward<Args>(args)...);
1970 template <
typename... Args>
1973 return common::SHRINK_VOLUME<Resource, Value::Scalar, OperationID, Offer>(
1974 std::forward<Args>(args)...);
1981 return common::LAUNCH<Offer, TaskInfo>(tasks);
1985 template <
typename... Args>
1988 return common::LAUNCH_GROUP<ExecutorInfo, TaskGroupInfo, Offer>(
1989 std::forward<Args>(args)...);
1993 template <
typename... Args>
1997 CREATE_DISK<Resource, Resource::DiskInfo::Source::Type, OperationID, Offer>(
1998 std::forward<Args>(args)...);
2002 template <
typename... Args>
2005 return common::DESTROY_DISK<Resource, OperationID, Offer>(
2006 std::forward<Args>(args)...);
2010 template <
typename... Args>
2013 return common::parameterize<Parameters, Parameter>(
2014 std::forward<Args>(args)...);
2020 template <
typename... Args>
2024 mesos::v1::ExecutorInfo,
2025 mesos::v1::ExecutorID,
2027 mesos::v1::CommandInfo,
2028 mesos::v1::FrameworkID>(std::forward<Args>(args)...);
2035 const std::vector<std::string>& arguments = {})
2037 return common::createCommandInfo<mesos::v1::CommandInfo>(value, arguments);
2041 template <
typename... Args>
2044 return common::createDockerImage<mesos::v1::Image>(
2045 std::forward<Args>(args)...);
2049 template <
typename... Args>
2052 return common::createVolumeSandboxPath<mesos::v1::Volume>(
2053 std::forward<Args>(args)...);
2057 template <
typename... Args>
2062 mesos::v1::MountPropagation>(std::forward<Args>(args)...);
2066 template <
typename... Args>
2070 mesos::v1::Volume, mesos::v1::Image>(std::forward<Args>(args)...);
2074 template <
typename... Args>
2077 return common::createVolumeCsi<mesos::v1::Volume>(
2078 std::forward<Args>(args)...);
2082 template <
typename... Args>
2085 return common::createNetworkInfo<mesos::v1::NetworkInfo>(
2086 std::forward<Args>(args)...);
2093 const std::vector<mesos::v1::Volume>& volumes = {})
2096 mesos::v1::ContainerInfo, mesos::v1::Volume, mesos::v1::Image>(
2097 imageName, volumes);
2101 template <
typename... Args>
2105 mesos::v1::TaskInfo,
2106 mesos::v1::ExecutorID,
2109 mesos::v1::ExecutorInfo,
2110 mesos::v1::CommandInfo,
2112 mesos::v1::Value::Scalar>(std::forward<Args>(args)...);
2118 const std::vector<mesos::v1::TaskInfo>& tasks)
2121 mesos::v1::TaskGroupInfo,
2122 mesos::v1::TaskInfo>(tasks);
2127 const std::string& role)
2129 return common::createStaticReservationInfo<mesos::v1::Resource>(role);
2134 const std::string& role,
2139 mesos::v1::Resource, mesos::v1::Labels>(role, principal, labels);
2143 template <
typename... Args>
2151 template <
typename... Args>
2154 return common::createDiskInfo<mesos::v1::Resource, mesos::v1::Volume>(
2155 std::forward<Args>(args)...);
2159 template <
typename... Args>
2163 return common::createDiskSourcePath<mesos::v1::Resource>(
2164 std::forward<Args>(args)...);
2168 template <
typename... Args>
2172 return common::createDiskSourceMount<mesos::v1::Resource>(
2173 std::forward<Args>(args)...);
2177 template <
typename... Args>
2181 return common::createDiskSourceBlock<mesos::v1::Resource>(
2182 std::forward<Args>(args)...);
2186 template <
typename... Args>
2190 return common::createDiskSourceRaw<mesos::v1::Resource>(
2191 std::forward<Args>(args)...);
2195 template <
typename... Args>
2199 mesos::v1::Resource,
2201 mesos::v1::Volume>(std::forward<Args>(args)...);
2205 template <
typename... Args>
2209 mesos::v1::Resource,
2211 mesos::v1::Volume>(std::forward<Args>(args)...);
2215 template <
typename... Args>
2218 return common::createBasicAuthHeaders<mesos::v1::Credential>(
2219 std::forward<Args>(args)...);
2223 template <
typename... Args>
2224 inline google::protobuf::RepeatedPtrField<
2227 return common::createWeightInfos<mesos::v1::WeightInfo>(
2228 std::forward<Args>(args)...);
2232 template <
typename... Args>
2235 return common::convertToHashmap<mesos::v1::WeightInfo>(
2236 std::forward<Args>(args)...);
2240 template <
typename... Args>
2245 mesos::v1::OperationID,
2246 mesos::v1::Offer>(std::forward<Args>(args)...);
2250 template <
typename... Args>
2255 mesos::v1::OperationID,
2256 mesos::v1::Offer>(std::forward<Args>(args)...);
2260 template <
typename... Args>
2265 mesos::v1::OperationID,
2266 mesos::v1::Offer>(std::forward<Args>(args)...);
2270 template <
typename... Args>
2275 mesos::v1::OperationID,
2276 mesos::v1::Offer>(std::forward<Args>(args)...);
2280 template <
typename... Args>
2284 mesos::v1::Resource,
2285 mesos::v1::OperationID,
2286 mesos::v1::Offer>(std::forward<Args>(args)...);
2290 template <
typename... Args>
2294 mesos::v1::Resource,
2295 mesos::v1::Value::Scalar,
2296 mesos::v1::OperationID,
2297 mesos::v1::Offer>(std::forward<Args>(args)...);
2303 const std::vector<mesos::v1::TaskInfo>& tasks)
2305 return common::LAUNCH<mesos::v1::Offer, mesos::v1::TaskInfo>(tasks);
2309 template <
typename... Args>
2313 mesos::v1::ExecutorInfo,
2314 mesos::v1::TaskGroupInfo,
2315 mesos::v1::Offer>(std::forward<Args>(args)...);
2319 template <
typename... Args>
2323 mesos::v1::Resource,
2325 mesos::v1::OperationID,
2326 mesos::v1::Offer>(std::forward<Args>(args)...);
2330 template <
typename... Args>
2334 mesos::v1::Resource,
2335 mesos::v1::OperationID,
2336 mesos::v1::Offer>(std::forward<Args>(args)...);
2340 template <
typename... Args>
2343 return common::parameterize<mesos::v1::Parameters, mesos::v1::Parameter>(
2344 std::forward<Args>(args)...);
2349 const mesos::v1::FrameworkID& frameworkId,
2350 const mesos::v1::Offer& offer,
2351 const std::vector<mesos::v1::Offer::Operation>& operations,
2355 call.set_type(mesos::v1::scheduler::Call::ACCEPT);
2356 call.mutable_framework_id()->CopyFrom(frameworkId);
2358 mesos::v1::scheduler::Call::Accept*
accept = call.mutable_accept();
2359 accept->add_offer_ids()->CopyFrom(offer.id());
2362 accept->add_operations()->CopyFrom(operation);
2366 accept->mutable_filters()->CopyFrom(
filters.get());
2374 const mesos::v1::FrameworkID& frameworkId,
2375 const mesos::v1::AgentID& agentId,
2376 const mesos::v1::scheduler::Event::Update&
update)
2379 call.set_type(mesos::v1::scheduler::Call::ACKNOWLEDGE);
2380 call.mutable_framework_id()->CopyFrom(frameworkId);
2382 mesos::v1::scheduler::Call::Acknowledge* acknowledge =
2383 call.mutable_acknowledge();
2385 acknowledge->mutable_task_id()->CopyFrom(
2386 update.status().task_id());
2388 acknowledge->mutable_agent_id()->CopyFrom(agentId);
2389 acknowledge->set_uuid(update.status().uuid());
2396 const mesos::v1::FrameworkID& frameworkId,
2397 const mesos::v1::AgentID& agentId,
2399 const mesos::v1::scheduler::Event::UpdateOperationStatus&
update)
2402 call.set_type(mesos::v1::scheduler::Call::ACKNOWLEDGE_OPERATION_STATUS);
2403 call.mutable_framework_id()->CopyFrom(frameworkId);
2405 mesos::v1::scheduler::Call::AcknowledgeOperationStatus* acknowledge =
2406 call.mutable_acknowledge_operation_status();
2408 acknowledge->mutable_agent_id()->CopyFrom(agentId);
2409 if (resourceProviderId.
isSome()) {
2410 acknowledge->mutable_resource_provider_id()->CopyFrom(
2411 resourceProviderId.
get());
2413 acknowledge->set_uuid(update.status().uuid().value());
2414 acknowledge->mutable_operation_id()->CopyFrom(update.status().operation_id());
2421 const mesos::v1::FrameworkID& frameworkId,
2422 const mesos::v1::TaskID& taskId,
2428 call.mutable_framework_id()->CopyFrom(frameworkId);
2430 mesos::v1::scheduler::Call::Kill*
kill = call.mutable_kill();
2431 kill->mutable_task_id()->CopyFrom(taskId);
2433 if (agentId.isSome()) {
2434 kill->mutable_agent_id()->CopyFrom(agentId.get());
2437 if (killPolicy.isSome()) {
2438 kill->mutable_kill_policy()->CopyFrom(killPolicy.get());
2446 const mesos::v1::FrameworkID& frameworkId,
2452 call.set_type(mesos::v1::scheduler::Call::RECONCILE_OPERATIONS);
2453 call.mutable_framework_id()->CopyFrom(frameworkId);
2455 mesos::v1::scheduler::Call::ReconcileOperations* reconcile =
2456 call.mutable_reconcile_operations();
2462 reconcile->add_operations()->CopyFrom(operation);
2470 const mesos::v1::FrameworkInfo& frameworkInfo,
2474 call.set_type(mesos::v1::scheduler::Call::SUBSCRIBE);
2476 call.mutable_subscribe()->mutable_framework_info()->CopyFrom(frameworkInfo);
2478 if (frameworkId.isSome()) {
2479 call.mutable_framework_id()->CopyFrom(frameworkId.get());
2492 foreachpair (
const std::string& key,
const std::string& value, map) {
2493 mesos::Environment::Variable* variable = environment.add_variables();
2494 variable->set_name(key);
2495 variable->set_value(value);
2502 #define DEFAULT_EXECUTOR_INFO createExecutorInfo("default", "exit 1") 2505 #define DEFAULT_CREDENTIAL DefaultCredential::create() 2506 #define DEFAULT_CREDENTIAL_2 DefaultCredential2::create() 2509 #define DEFAULT_FRAMEWORK_INFO DefaultFrameworkInfo::create() 2512 #define DEFAULT_EXECUTOR_ID DEFAULT_EXECUTOR_INFO.executor_id() 2524 const MasterInfo&));
2525 MOCK_METHOD2(reregistered,
void(
SchedulerDriver*,
const MasterInfo&));
2528 const std::vector<Offer>&));
2530 MOCK_METHOD2(statusUpdate,
void(
SchedulerDriver*,
const TaskStatus&));
2534 const std::string&));
2551 std::vector<Offer> offers =
arg1;
2552 int numTasks = tasks;
2555 for (
size_t i = 0; i < offers.size(); i++) {
2556 const Offer& offer = offers[i];
2561 if (offer.resources_size() > 0 &&
2562 offer.resources(0).has_allocation_info()) {
2566 std::vector<TaskInfo> tasks;
2567 Resources remaining = offer.resources();
2570 launched < numTasks) {
2572 task.set_name(
"TestTask");
2574 task.mutable_slave_id()->MergeFrom(offer.slave_id());
2575 task.mutable_executor()->MergeFrom(executor);
2578 role == std::string(
"*")
2584 task.mutable_resources()->MergeFrom(resources.
get());
2585 remaining -= resources.
get();
2587 tasks.push_back(task);
2601 std::vector<Offer> offers =
arg1;
2603 for (
size_t i = 0; i < offers.size(); i++) {
2613 std::vector<Offer> offers =
arg1;
2615 for (
size_t i = 0; i < offers.size(); i++) {
2628 std::vector<Offer> offers =
arg1;
2629 foreach (
const Offer& offer, offers) {
2643 const ExecutorInfo&,
2644 const FrameworkInfo&,
2646 MOCK_METHOD2(reregistered,
void(
ExecutorDriver*,
const SlaveInfo&));
2648 MOCK_METHOD2(launchTask,
void(
ExecutorDriver*,
const TaskInfo&));
2650 MOCK_METHOD2(frameworkMessage,
void(
ExecutorDriver*,
const std::string&));
2673 std::shared_ptr<mesos::master::detector::MasterDetector>(
2680 const FrameworkInfo& framework,
2681 bool implicitAcknowledgements =
true)
2686 implicitAcknowledgements,
2691 std::shared_ptr<mesos::master::detector::MasterDetector>(
2698 const FrameworkInfo& framework,
2699 bool implicitAcknowledgements,
2700 const Credential& credential)
2705 implicitAcknowledgements,
2710 std::shared_ptr<mesos::master::detector::MasterDetector>(
2716 namespace scheduler {
2719 template <
typename Mesos,
typename Event>
2723 MOCK_METHOD1_T(connected,
void(
Mesos*));
2724 MOCK_METHOD1_T(disconnected,
void(
Mesos*));
2725 MOCK_METHOD1_T(heartbeat,
void(
Mesos*));
2726 MOCK_METHOD2_T(subscribed,
void(
Mesos*,
const typename Event::Subscribed&));
2727 MOCK_METHOD2_T(offers,
void(
Mesos*,
const typename Event::Offers&));
2730 void(
Mesos*,
const typename Event::InverseOffers&));
2731 MOCK_METHOD2_T(rescind,
void(
Mesos*,
const typename Event::Rescind&));
2733 rescindInverseOffers,
2734 void(
Mesos*,
const typename Event::RescindInverseOffer&));
2735 MOCK_METHOD2_T(
update,
void(
Mesos*,
const typename Event::Update&));
2737 updateOperationStatus,
2738 void(
Mesos*,
const typename Event::UpdateOperationStatus&));
2739 MOCK_METHOD2_T(message,
void(
Mesos*,
const typename Event::Message&));
2740 MOCK_METHOD2_T(failure,
void(
Mesos*,
const typename Event::Failure&));
2741 MOCK_METHOD2_T(
error,
void(
Mesos*,
const typename Event::Error&));
2745 while (!events.empty()) {
2746 Event event = std::move(events.front());
2749 switch (event.type()) {
2750 case Event::SUBSCRIBED:
2751 subscribed(mesos, event.subscribed());
2754 offers(mesos, event.offers());
2756 case Event::INVERSE_OFFERS:
2757 inverseOffers(mesos, event.inverse_offers());
2759 case Event::RESCIND:
2760 rescind(mesos, event.rescind());
2762 case Event::RESCIND_INVERSE_OFFER:
2763 rescindInverseOffers(mesos, event.rescind_inverse_offer());
2766 update(mesos, event.update());
2768 case Event::UPDATE_OPERATION_STATUS:
2769 updateOperationStatus(mesos, event.update_operation_status());
2771 case Event::MESSAGE:
2772 message(mesos, event.message());
2775 failure(mesos, event.failure());
2778 error(mesos, event.error());
2780 case Event::HEARTBEAT:
2784 LOG(FATAL) <<
"Received unexpected UNKNOWN event";
2794 template <
typename Mesos,
typename Event>
2799 const std::string&
master,
2802 const Option<std::shared_ptr<mesos::master::detector::MasterDetector>>&
2848 namespace scheduler {
2866 foreach (
const Offer& offer, arg.offers()) {
2867 foreach (
const Resource& resource, offer.resources()) {
2880 MATCHER_P(OperationStatusUpdateOperationIdEq, operationId,
"")
2882 return arg.status().has_operation_id() &&
2883 arg.status().operation_id() == operationId;
2891 call.set_type(Call::DECLINE);
2893 Call::Decline* decline = call.mutable_decline();
2895 foreach (
const Offer& offer,
arg1.offers()) {
2896 decline->add_offer_ids()->CopyFrom(offer.id());
2898 if (!call.has_framework_id()) {
2899 call.mutable_framework_id()->CopyFrom(offer.framework_id());
2910 call.set_type(Call::SUBSCRIBE);
2911 call.mutable_subscribe()->mutable_framework_info()->CopyFrom(frameworkInfo);
2920 call.set_type(Call::SUBSCRIBE);
2921 call.mutable_framework_id()->CopyFrom(frameworkId);
2922 call.mutable_subscribe()->mutable_framework_info()->CopyFrom(frameworkInfo);
2923 call.mutable_subscribe()->mutable_framework_info()->mutable_id()->CopyFrom(
2933 call.set_type(Call::ACKNOWLEDGE);
2934 call.mutable_framework_id()->CopyFrom(frameworkId);
2936 Call::Acknowledge* acknowledge = call.mutable_acknowledge();
2937 acknowledge->mutable_task_id()->CopyFrom(
arg1.status().task_id());
2938 acknowledge->mutable_agent_id()->CopyFrom(agentId);
2939 acknowledge->set_uuid(
arg1.status().uuid());
2946 SendAcknowledgeOperationStatus, frameworkId, agentId)
2949 call.set_type(Call::ACKNOWLEDGE_OPERATION_STATUS);
2950 call.mutable_framework_id()->CopyFrom(frameworkId);
2952 Call::AcknowledgeOperationStatus* acknowledge =
2953 call.mutable_acknowledge_operation_status();
2955 acknowledge->mutable_agent_id()->CopyFrom(agentId);
2956 acknowledge->set_uuid(
arg1.status().uuid().value());
2957 acknowledge->mutable_operation_id()->CopyFrom(
arg1.status().operation_id());
2964 SendAcknowledgeOperationStatus, frameworkId, agentId, resourceProviderId)
2967 call.set_type(Call::ACKNOWLEDGE_OPERATION_STATUS);
2968 call.mutable_framework_id()->CopyFrom(frameworkId);
2970 Call::AcknowledgeOperationStatus* acknowledge =
2971 call.mutable_acknowledge_operation_status();
2973 acknowledge->mutable_agent_id()->CopyFrom(agentId);
2974 acknowledge->mutable_resource_provider_id()->CopyFrom(resourceProviderId);
2975 acknowledge->set_uuid(
arg1.status().uuid().value());
2976 acknowledge->mutable_operation_id()->CopyFrom(
arg1.status().operation_id());
2990 namespace executor {
2993 template <
typename Mesos,
typename Event>
2997 MOCK_METHOD1_T(connected,
void(
Mesos*));
2998 MOCK_METHOD1_T(disconnected,
void(
Mesos*));
2999 MOCK_METHOD2_T(subscribed,
void(
Mesos*,
const typename Event::Subscribed&));
3000 MOCK_METHOD2_T(
launch,
void(
Mesos*,
const typename Event::Launch&));
3001 MOCK_METHOD2_T(launchGroup,
void(
Mesos*,
const typename Event::LaunchGroup&));
3002 MOCK_METHOD2_T(
kill,
void(
Mesos*,
const typename Event::Kill&));
3003 MOCK_METHOD2_T(message,
void(
Mesos*,
const typename Event::Message&));
3005 MOCK_METHOD2_T(
error,
void(
Mesos*,
const typename Event::Error&));
3006 MOCK_METHOD2_T(acknowledged,
3007 void(
Mesos*,
const typename Event::Acknowledged&));
3011 while (!events.empty()) {
3012 Event event = std::move(events.front());
3015 switch (event.type()) {
3016 case Event::SUBSCRIBED:
3017 subscribed(mesos, event.subscribed());
3020 launch(mesos, event.launch());
3023 launchGroup(mesos, event.launch_group());
3026 kill(mesos, event.kill());
3028 case Event::ACKNOWLEDGED:
3029 acknowledged(mesos, event.acknowledged());
3031 case Event::MESSAGE:
3032 message(mesos, event.message());
3034 case Event::SHUTDOWN:
3038 error(mesos, event.error());
3040 case Event::HEARTBEAT:
3043 LOG(FATAL) <<
"Received unexpected UNKNOWN event";
3053 template <
typename Mesos,
typename Event>
3060 const std::map<std::string, std::string>&
environment)
3080 namespace executor {
3098 call.mutable_framework_id()->CopyFrom(frameworkId);
3099 call.mutable_executor_id()->CopyFrom(executorId);
3101 call.set_type(mesos::v1::executor::Call::SUBSCRIBE);
3103 call.mutable_subscribe();
3109 ACTION_P3(SendUpdateFromTask, frameworkId, executorId, state)
3111 mesos::v1::TaskStatus
status;
3112 status.mutable_task_id()->CopyFrom(
arg1.task().task_id());
3113 status.mutable_executor_id()->CopyFrom(executorId);
3114 status.set_state(state);
3115 status.set_source(mesos::v1::TaskStatus::SOURCE_EXECUTOR);
3119 call.mutable_framework_id()->CopyFrom(frameworkId);
3120 call.mutable_executor_id()->CopyFrom(executorId);
3122 call.set_type(mesos::v1::executor::Call::UPDATE);
3124 call.mutable_update()->mutable_status()->CopyFrom(status);
3130 ACTION_P3(SendUpdateFromTaskID, frameworkId, executorId, state)
3132 mesos::v1::TaskStatus
status;
3133 status.mutable_task_id()->CopyFrom(
arg1.task_id());
3134 status.mutable_executor_id()->CopyFrom(executorId);
3135 status.set_state(state);
3136 status.set_source(mesos::v1::TaskStatus::SOURCE_EXECUTOR);
3140 call.mutable_framework_id()->CopyFrom(frameworkId);
3141 call.mutable_executor_id()->CopyFrom(executorId);
3143 call.set_type(mesos::v1::executor::Call::UPDATE);
3145 call.mutable_update()->mutable_status()->CopyFrom(status);
3159 namespace resource_provider {
3165 typename ResourceProviderInfo,
3166 typename ResourceProviderID,
3169 typename OperationState,
3176 ResourceProviderInfo,
3185 const ResourceProviderInfo& _info,
3189 resources(_resources)
3191 auto self = this->
self();
3193 ON_CALL(*
this, connected()).WillByDefault(Invoke([
self]() {
3194 dispatch(
self, &TestResourceProviderProcess::connectedDefault);
3196 EXPECT_CALL(*
this, connected()).WillRepeatedly(DoDefault());
3198 ON_CALL(*
this, subscribed(_))
3200 Invoke([
self](
const typename Event::Subscribed& subscribed) {
3203 &TestResourceProviderProcess::subscribedDefault,
3206 EXPECT_CALL(*
this, subscribed(_)).WillRepeatedly(DoDefault());
3208 ON_CALL(*
this, applyOperation(_))
3210 Invoke([
self](
const typename Event::ApplyOperation& operation) {
3213 &TestResourceProviderProcess::operationDefault,
3216 EXPECT_CALL(*
this, applyOperation(_)).WillRepeatedly(DoDefault());
3218 ON_CALL(*
this, publishResources(_))
3220 Invoke([
self](
const typename Event::PublishResources& publish) {
3223 &TestResourceProviderProcess::publishDefault,
3226 EXPECT_CALL(*
this, publishResources(_)).WillRepeatedly(DoDefault());
3228 ON_CALL(*
this, teardown()).WillByDefault(Invoke([
self]() {
3229 dispatch(
self, &TestResourceProviderProcess::teardownDefault);
3231 EXPECT_CALL(*
this, teardown()).WillRepeatedly(DoDefault());
3234 MOCK_METHOD0_T(connected,
void());
3235 MOCK_METHOD0_T(disconnected,
void());
3236 MOCK_METHOD1_T(subscribed,
void(
const typename Event::Subscribed&));
3237 MOCK_METHOD1_T(applyOperation,
void(
const typename Event::ApplyOperation&));
3240 void(
const typename Event::PublishResources&));
3242 acknowledgeOperationStatus,
3243 void(
const typename Event::AcknowledgeOperationStatus&));
3245 reconcileOperations,
3246 void(
const typename Event::ReconcileOperations&));
3247 MOCK_METHOD0_T(teardown,
void());
3251 while (!events.empty()) {
3252 Event event = events.front();
3256 switch (event.type()) {
3257 case Event::SUBSCRIBED:
3258 subscribed(event.subscribed());
3260 case Event::APPLY_OPERATION:
3261 applyOperation(event.apply_operation());
3263 case Event::PUBLISH_RESOURCES:
3264 publishResources(event.publish_resources());
3266 case Event::ACKNOWLEDGE_OPERATION_STATUS:
3267 acknowledgeOperationStatus(event.acknowledge_operation_status());
3269 case Event::RECONCILE_OPERATIONS:
3270 reconcileOperations(event.reconcile_operations());
3272 case Event::TEARDOWN:
3276 LOG(FATAL) <<
"Received unexpected UNKNOWN event";
3284 if (driver !=
nullptr) {
3285 return driver->send(call);
3297 #ifdef USE_SSL_SOCKET 3299 DEFAULT_JWT_SECRET_KEY);
3306 claims[
"foo"] =
"bar";
3312 token = secretGenerator.
generate(principal).then(
3314 return secret.value().data();
3316 #endif // USE_SSL_SOCKET 3320 std::make_shared<process::Owned<EndpointDetector>>(std::move(detector));
3323 driver.reset(
new Driver(
3324 std::move(*detector_),
3326 process::defer(this->
self(), &TestResourceProviderProcess::connected),
3328 this->
self(), &TestResourceProviderProcess::disconnected),
3330 this->
self(), &TestResourceProviderProcess::events, lambda::_1),
3347 call.set_type(Call::SUBSCRIBE);
3348 call.mutable_subscribe()->mutable_resource_provider_info()->CopyFrom(info);
3351 .
onFailed([](
const std::string& failure) {
3352 LOG(INFO) <<
"Failed to send call: " << failure;
3358 info.mutable_id()->CopyFrom(subscribed.provider_id());
3360 providerId.set(subscribed.provider_id());
3362 if (resources.isSome()) {
3365 foreach (Resource resource, resources.get()) {
3366 resource.mutable_provider_id()->CopyFrom(info.id());
3367 injected += resource;
3371 call.set_type(Call::UPDATE_STATE);
3372 call.mutable_resource_provider_id()->CopyFrom(info.id());
3374 typename Call::UpdateState*
update = call.mutable_update_state();
3375 update->mutable_resources()->CopyFrom(injected);
3376 update->mutable_resource_version_uuid()->set_value(
3380 .
onFailed([](
const std::string& failure) {
3381 LOG(INFO) <<
"Failed to send call: " << failure;
3388 CHECK(info.has_id());
3391 call.set_type(Call::UPDATE_OPERATION_STATUS);
3392 call.mutable_resource_provider_id()->CopyFrom(info.id());
3394 typename Call::UpdateOperationStatus*
update =
3395 call.mutable_update_operation_status();
3396 update->mutable_framework_id()->CopyFrom(operation.framework_id());
3397 update->mutable_operation_uuid()->CopyFrom(operation.operation_uuid());
3399 update->mutable_status()->set_state(
3400 OperationState::OPERATION_FINISHED);
3402 switch (operation.info().type()) {
3421 update->mutable_status()->add_converted_resources()->CopyFrom(
3422 operation.info().create_disk().source());
3423 update->mutable_status()
3424 ->mutable_converted_resources(0)
3427 ->set_type(operation.info().create_disk().target_type());
3428 if (operation.info().create_disk().has_target_profile()) {
3429 update->mutable_status()
3430 ->mutable_converted_resources(0)
3433 ->set_profile(operation.info().create_disk().target_profile());
3437 update->mutable_status()->add_converted_resources()->CopyFrom(
3438 operation.info().destroy_disk().source());
3439 update->mutable_status()
3440 ->mutable_converted_resources(0)
3443 ->set_type(Resource::DiskInfo::Source::RAW);
3449 update->mutable_status()->mutable_uuid()->set_value(
3452 update->mutable_status()->mutable_resource_provider_id()->CopyFrom(
3455 update->mutable_latest_status()->CopyFrom(update->status());
3458 .
onFailed([](
const std::string& failure) {
3459 LOG(INFO) <<
"Failed to send call: " << failure;
3465 CHECK(info.has_id());
3468 call.set_type(Call::UPDATE_PUBLISH_RESOURCES_STATUS);
3469 call.mutable_resource_provider_id()->CopyFrom(info.id());
3471 typename Call::UpdatePublishResourcesStatus*
update =
3472 call.mutable_update_publish_resources_status();
3473 update->mutable_uuid()->CopyFrom(publish.uuid());
3474 update->set_status(Call::UpdatePublishResourcesStatus::OK);
3477 .
onFailed([](
const std::string& failure) {
3478 LOG(INFO) <<
"Failed to send call: " << failure;
3487 ResourceProviderInfo info;
3490 std::unique_ptr<Driver> driver;
3499 typename ResourceProviderInfo,
3500 typename ResourceProviderID,
3503 typename OperationState,
3509 const ResourceProviderInfo& _info,
3529 std::move(detector),
3544 mesos::v1::ResourceProviderInfo,
3545 mesos::v1::ResourceProviderID,
3546 mesos::v1::Resource,
3548 mesos::v1::OperationState,
3551 std::unique_ptr<TestResourceProviderProcessT>
process;
3558 std::string scheme =
"http";
3560 #ifdef USE_SSL_SOCKET 3570 pid.
id +
"/api/v1/resource_provider");
3579 namespace resource_provider {
3593 mesos::v1::ResourceProviderInfo,
3594 mesos::v1::ResourceProviderID,
3595 mesos::v1::Resource,
3597 mesos::v1::OperationState,
3603 mesos::v1::resource_provider::Driver,
3604 mesos::v1::ResourceProviderInfo,
3605 mesos::v1::ResourceProviderID,
3606 mesos::v1::Resource,
3607 mesos::v1::Resources,
3608 mesos::v1::OperationState,
3628 const authorization::Action& action));
3658 status.mutable_task_id()->MergeFrom(
arg1.task_id());
3659 status.set_state(state);
3660 arg0->sendStatusUpdate(status);
3667 status.mutable_task_id()->MergeFrom(
arg1);
3668 status.set_state(state);
3669 arg0->sendStatusUpdate(status);
3675 arg0->sendFrameworkMessage(data);
3679 #define FUTURE_PROTOBUF(message, from, to) \ 3680 FutureProtobuf(message, from, to) 3683 #define DROP_PROTOBUF(message, from, to) \ 3684 FutureProtobuf(message, from, to, true) 3687 #define DROP_PROTOBUFS(message, from, to) \ 3688 DropProtobufs(message, from, to) 3691 #define EXPECT_NO_FUTURE_PROTOBUFS(message, from, to) \ 3692 ExpectNoFutureProtobufs(message, from, to) 3695 #define FUTURE_HTTP_PROTOBUF(message, path, contentType) \ 3696 FutureHttp(message, path, contentType) 3699 #define DROP_HTTP_PROTOBUF(message, path, contentType) \ 3700 FutureHttp(message, path, contentType, true) 3703 #define DROP_HTTP_PROTOBUFS(message, path, contentType) \ 3704 DropHttpProtobufs(message, path, contentType) 3707 #define EXPECT_NO_FUTURE_HTTP_PROTOBUFS(message, path, contentType) \ 3708 ExpectNoFutureHttpProtobufs(message, path, contentType) 3719 #define FUTURE_CALL(message, unionType, from, to) \ 3720 FutureUnionProtobuf(message, unionType, from, to) 3723 #define DROP_CALL(message, unionType, from, to) \ 3724 FutureUnionProtobuf(message, unionType, from, to, true) 3727 #define DROP_CALLS(message, unionType, from, to) \ 3728 DropUnionProtobufs(message, unionType, from, to) 3731 #define EXPECT_NO_FUTURE_CALLS(message, unionType, from, to) \ 3732 ExpectNoFutureUnionProtobufs(message, unionType, from, to) 3735 #define FUTURE_CALL_MESSAGE(message, unionType, from, to) \ 3736 process::FutureUnionMessage(message, unionType, from, to) 3739 #define DROP_CALL_MESSAGE(message, unionType, from, to) \ 3740 process::FutureUnionMessage(message, unionType, from, to, true) 3743 #define FUTURE_HTTP_CALL(message, unionType, path, contentType) \ 3744 FutureUnionHttp(message, unionType, path, contentType) 3747 #define DROP_HTTP_CALL(message, unionType, path, contentType) \ 3748 FutureUnionHttp(message, unionType, path, contentType, true) 3751 #define DROP_HTTP_CALLS(message, unionType, path, contentType) \ 3752 DropUnionHttpProtobufs(message, unionType, path, contentType) 3755 #define EXPECT_NO_FUTURE_HTTP_CALLS(message, unionType, path, contentType) \ 3756 ExpectNoFutureUnionHttpProtobufs(message, unionType, path, contentType) 3760 template <
typename T>
3764 template <
typename T,
typename From,
typename To>
3768 { google::protobuf::Message* m = &t; (void) m; }
3775 template <
typename Message,
typename UnionType,
typename From,
typename To>
3777 Message message, UnionType unionType, From from, To to,
bool drop =
false)
3780 { google::protobuf::Message* m = &message; (void) m; }
3783 .then(
lambda::bind(&_FutureProtobuf<Message>, lambda::_1));
3787 template <
typename Message,
typename Path>
3795 { google::protobuf::Message* m = &message; (void) m; }
3798 lambda::bind(&deserialize<Message>, contentType, lambda::_1);
3802 return deserializer(request.
body).get();
3807 template <
typename Message,
typename UnionType,
typename Path>
3810 UnionType unionType,
3816 { google::protobuf::Message* m = &message; (void) m; }
3819 lambda::bind(&deserialize<Message>, contentType, lambda::_1);
3822 message, unionType, path, deserializer, drop)
3824 return deserializer(request.
body).get();
3829 template <
typename T>
3833 t.ParseFromString(message.
body);
3838 template <
typename T,
typename From,
typename To>
3842 { google::protobuf::Message* m = &t; (void) m; }
3848 template <
typename Message,
typename UnionType,
typename From,
typename To>
3852 { google::protobuf::Message* m = &message; (void) m; }
3858 template <
typename Message,
typename Path>
3866 { google::protobuf::Message* m = &message; (void) m; }
3869 lambda::bind(&deserialize<Message>, contentType, lambda::_1);
3875 template <
typename Message,
typename UnionType,
typename Path>
3878 UnionType unionType,
3884 { google::protobuf::Message* m = &message; (void) m; }
3887 lambda::bind(&deserialize<Message>, contentType, lambda::_1);
3893 template <
typename T,
typename From,
typename To>
3897 { google::protobuf::Message* m = &t; (void) m; }
3903 template <
typename Message,
typename UnionType,
typename From,
typename To>
3905 Message message, UnionType unionType, From from, To to)
3908 { google::protobuf::Message* m = &message; (void) m; }
3914 template <
typename Message,
typename Path>
3922 { google::protobuf::Message* m = &message; (void) m; }
3925 lambda::bind(&deserialize<Message>, contentType, lambda::_1);
3931 template <
typename Message,
typename UnionType,
typename Path>
3934 UnionType unionType,
3940 { google::protobuf::Message* m = &message; (void) m; }
3943 lambda::bind(&deserialize<Message>, contentType, lambda::_1);
3946 message, unionType, path, deserializer);
3954 foreach (
const Offer& offer, arg) {
3955 foreach (
const Resource& resource, offer.resources()) {
3970 foreach (
const Offer& offer, arg) {
3971 Resources resources = offer.resources();
3975 if (!resource.has_allocation_info()) {
3979 if (resources.
contains(resource)) {
3991 return arg.task_id() == taskId;
3998 return arg.state() == taskState;
4006 return arg.status().task_id() == taskId;
4014 return arg.status().state() == taskState;
4022 if (!arg.has_object()) {
4026 if (!arg.object().has_task_info()) {
4030 return arg.object().task_info().task_id() == taskId;
4037 return arg.isNone() ?
false : arg->task_id() == taskId;
4049 foreach(
const TaskInfo& taskInfo, arg->tasks()) {
4050 if (taskInfo.task_id() == taskId) {
4065 const ::testing::TestParamInfo<ParamExecutorType>& info)
const 4067 switch (info.param.type) {
4069 return "CommandExecutor";
4071 return "DefaultExecutor";
4114 std::string operator()(
4115 const ::testing::TestParamInfo<ParamDiskQuota::Type>& info)
const;
4118 static std::vector<Type> parameters();
4125 #endif // __TESTS_MESOS_HPP__ TVolume createVolumeFromDockerImage(const std::string &containerPath, const std::string &imageName, const typename TVolume::Mode &mode)
Definition: mesos.hpp:843
TVolume createVolumeHostPath(const std::string &containerPath, const std::string &hostPath, const typename TVolume::Mode &mode, const Option< typename TMountPropagation::Mode > &mountPropagationMode=None())
Definition: mesos.hpp:816
mesos::v1::Resource createDiskResource(Args &&...args)
Definition: mesos.hpp:2196
std::string generate(const std::string &prefix="")
Returns 'prefix(N)' where N represents the number of instances where the same prefix (wrt...
TOffer::Operation UNRESERVE(const TResources &resources, const Option< TOperationID > &operationId=None())
Definition: mesos.hpp:1459
Definition: mesos.hpp:222
static constexpr uint64_t MEGABYTES
Definition: bytes.hpp:35
Future< process::Message > FutureUnionMessage(Message message, UnionType unionType, From from, To to, bool drop=false)
Definition: gmock.hpp:518
#define DEFAULT_FRAMEWORK_INFO
Definition: mesos.hpp:2509
Definition: mesos.hpp:579
SlaveOptions & withResourceEstimator(const Option< mesos::slave::ResourceEstimator * > &resourceEstimator)
Definition: mesos.hpp:164
Definition: nothing.hpp:16
constexpr const char * arg1
Definition: shell.hpp:43
static TFrameworkInfo create()
Definition: mesos.hpp:594
ContentType
Definition: http.hpp:43
Definition: capabilities.hpp:42
mesos::v1::Resource createReservedResource(Args &&...args)
Definition: mesos.hpp:2144
Definition: option.hpp:29
Try< bool > update(const std::string &link, const Handle &parent, uint16_t protocol, const action::Mirror &mirror)
DomainInfo createDomainInfo(Args &&...args)
Definition: mesos.hpp:1924
process::Owned< EndpointDetector > createEndpointDetector(const process::UPID &pid)
Definition: mesos.hpp:3554
Try< Bytes > size(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:130
mesos::v1::ExecutorInfo createExecutorInfo(Args &&...args)
Definition: mesos.hpp:2021
Definition: executor.hpp:147
Future< Response > request(const Request &request, bool streamedResponse=false)
Asynchronously sends an HTTP request to the process and returns the HTTP response once the entire res...
Definition: mesos.hpp:124
T & get()&
Definition: try.hpp:80
mesos::v1::scheduler::Call createCallAcknowledgeOperationStatus(const mesos::v1::FrameworkID &frameworkId, const mesos::v1::AgentID &agentId, const Option< mesos::v1::ResourceProviderID > &resourceProviderId, const mesos::v1::scheduler::Event::UpdateOperationStatus &update)
Definition: mesos.hpp:2395
Definition: master.hpp:27
Option< mesos::SecretGenerator * > secretGenerator
Definition: mesos.hpp:213
network::inet::Address address
Definition: pid.hpp:177
mesos::v1::Resource::ReservationInfo createDynamicReservationInfo(const std::string &role, const Option< std::string > &principal=None(), const Option< mesos::v1::Labels > &labels=None())
Definition: mesos.hpp:2133
mesos::v1::scheduler::Call createCallSubscribe(const mesos::v1::FrameworkInfo &frameworkInfo, const Option< mesos::v1::FrameworkID > &frameworkId=None())
Definition: mesos.hpp:2469
void DropHttpProtobufs(Message message, Path path, ContentType contentType, bool drop=false)
Definition: mesos.hpp:3859
Definition: future.hpp:668
mesos::v1::TaskInfo createTask(Args &&...args)
Definition: mesos.hpp:2102
mesos::v1::executor::Event Event
Definition: mesos.hpp:3085
mesos::v1::resource_provider::Event Event
Definition: mesos.hpp:3584
void teardownDefault()
Definition: mesos.hpp:3482
void ExpectNoFutureUnionMessages(Message message, UnionType unionType, From from, To to)
Definition: gmock.hpp:675
Definition: message.hpp:22
void setAgentID(mesos::v1::TaskInfo *task, const mesos::v1::AgentID &agentId)
Definition: mesos.hpp:934
Result< std::string > user(Option< uid_t > uid=None())
Definition: su.hpp:284
SlaveOptions(mesos::master::detector::MasterDetector *detector, bool mock=false)
Definition: mesos.hpp:126
Result< ProcessStatus > status(pid_t pid)
Definition: proc.hpp:166
mesos::v1::NetworkInfo createNetworkInfo(Args &&...args)
Definition: mesos.hpp:2083
mesos::v1::Volume createVolumeHostPath(Args &&...args)
Definition: mesos.hpp:2058
mesos::v1::Offer::Operation SHRINK_VOLUME(Args &&...args)
Definition: mesos.hpp:2291
virtual Status launchTasks(const std::vector< OfferID > &offerIds, const std::vector< TaskInfo > &tasks, const Filters &filters=Filters())=0
mesos::v1::Offer::Operation CREATE_DISK(Args &&...args)
Definition: mesos.hpp:2320
mesos::v1::scheduler::Call Call
Definition: mesos.hpp:2851
Definition: resources.hpp:83
mesos::v1::Offer::Operation RESERVE(Args &&...args)
Definition: mesos.hpp:2241
Definition: mesos.hpp:3054
Definition: scheduler.hpp:399
std::unique_ptr< TestResourceProviderProcessT > process
Definition: mesos.hpp:3551
const Future< T > & onFailed(FailedCallback &&callback) const
Definition: future.hpp:1398
std::string encode(const std::string &s)
Encode a string to Base64 with the standard Base64 alphabet.
Definition: base64.hpp:170
process::Future< ResourceProviderID > id() const
Definition: mesos.hpp:3484
SlaveOptions & withCsiServer(const process::Owned< slave::CSIServer > &csiServer)
Definition: mesos.hpp:198
static void SetUpTestCase()
Definition: mesos.hpp:2720
bool isCommandExecutor() const
Definition: mesos.hpp:4088
SlaveOptions & withGc(const Option< slave::GarbageCollector * > &gc)
Definition: mesos.hpp:151
TestMesos(const std::string &master, ContentType contentType, const std::shared_ptr< MockHTTPScheduler< Mesos, Event >> &scheduler, const Option< std::shared_ptr< mesos::master::detector::MasterDetector >> &detector=None(), const mesos::v1::Credential &credential=v1::DEFAULT_CREDENTIAL)
Definition: mesos.hpp:2798
Option< slave::Flags > flags
Definition: mesos.hpp:206
mesos::v1::ContainerInfo createContainerInfo(const Option< std::string > &imageName=None(), const std::vector< mesos::v1::Volume > &volumes={})
Definition: mesos.hpp:2091
Definition: lambda.hpp:30
Option< mesos::slave::QoSController * > qosController
Definition: mesos.hpp:212
void DropUnionHttpRequests(Message message, UnionType unionType, Path path, Deserializer deserializer, bool drop=false)
Definition: gmock.hpp:602
Definition: scheduler.hpp:70
Operation
Definition: cgroups.hpp:444
mesos::v1::Resource::DiskInfo::Source createDiskSourceMount(Args &&...args)
Definition: mesos.hpp:2169
UPID spawn(ProcessBase *process, bool manage=false)
Spawn a new process.
T _FutureProtobuf(const process::Message &message)
Definition: mesos.hpp:3830
Mode
Definition: paths.hpp:90
void terminate(const UPID &pid, bool inject=true)
Sends a TerminateEvent to the given process.
mesos::v1::Offer::Operation DESTROY_DISK(Args &&...args)
Definition: mesos.hpp:2331
Try< Nothing > start(const std::string &name)
Starts the slice with the given name (via 'systemctl start <name>').
mesos::v1::CommandInfo createCommandInfo(const Option< std::string > &value=None(), const std::vector< std::string > &arguments={})
Definition: mesos.hpp:2033
Definition: mesos.hpp:4112
STOUT_NODISCARD Resources pushReservation(const Resource::ReservationInfo &reservation) const
TResource createReservedResource(const std::string &name, const std::string &value, const TReservationInfos &...reservations)
Definition: mesos.hpp:1105
mesos::slave::ContainerConfig createContainerConfig(const CommandInfo &commandInfo, const std::string &resources, const std::string &sandboxDirectory, const Option< ContainerInfo > &containerInfo=None(), const Option< std::string > &user=None())
Definition: mesos.hpp:1720
void DropUnionProtobufs(Message message, UnionType unionType, From from, To to)
Definition: mesos.hpp:3849
bool isSome() const
Definition: option.hpp:116
Creates a VALUE-type secret containing a JWT.
Definition: jwt_secret_generator.hpp:36
Definition: mesos.hpp:4104
void connectedDefault()
Definition: mesos.hpp:3344
constexpr const char * arg0
Definition: shell.hpp:42
void publishDefault(const typename Event::PublishResources &publish)
Definition: mesos.hpp:3463
TOffer::Operation DESTROY_DISK(const TResource &source, const Option< TOperationID > &operationId=None())
Definition: mesos.hpp:1607
TResource::ReservationInfo createDynamicReservationInfo(const std::string &role, const Option< std::string > &principal=None(), const Option< TLabels > &labels=None())
Definition: mesos.hpp:1079
TContainerInfo createContainerInfo(const Option< std::string > &imageName=None(), const std::vector< TVolume > &volumes={})
Definition: mesos.hpp:896
mesos::v1::scheduler::Event Event
Definition: mesos.hpp:2852
mesos::v1::Volume createVolumeSandboxPath(Args &&...args)
Definition: mesos.hpp:2050
static Try< Resource > parse(const std::string &name, const std::string &value, const std::string &role)
Returns a Resource with the given name, value, and role.
Resource provider driver.
Definition: resource_provider.hpp:56
void DropHttpRequests(Message message, Path path, Deserializer deserializer, bool drop=false)
Definition: gmock.hpp:581
mesos::v1::Resource::DiskInfo::Source createDiskSourcePath(Args &&...args)
Definition: mesos.hpp:2160
void dispatch(const PID< T > &pid, void(T::*method)())
Definition: dispatch.hpp:174
TestingMesosSchedulerDriver(Scheduler *scheduler, mesos::master::detector::MasterDetector *_detector, const FrameworkInfo &framework, bool implicitAcknowledgements, const Credential &credential)
Definition: mesos.hpp:2695
Definition: resource_estimator.hpp:37
Environment * environment
Option< std::string > id
Definition: mesos.hpp:207
process::Future< Message > FutureUnionHttp(Message message, UnionType unionType, Path path, ContentType contentType, bool drop=false)
Definition: mesos.hpp:3808
std::vector< std::string > tokenize(const std::string &s, const std::string &delims, const Option< size_t > &maxTokens=None())
Definition: strings.hpp:139
This interface is used to enable an identity service or any other back end to check authorization pol...
Definition: authorizer.hpp:268
mesos::v1::Volume createVolumeCsi(Args &&...args)
Definition: mesos.hpp:2075
TExecutorInfo createExecutorInfo(const TExecutorID &executorId, const Option< TCommandInfo > &command, const Option< TResources > &resources, const Option< typename TExecutorInfo::Type > &type, const Option< TFrameworkID > &frameworkId)
Definition: mesos.hpp:659
mesos::v1::Resource::DiskInfo::Source createDiskSourceRaw(Args &&...args)
Definition: mesos.hpp:2187
mesos::v1::scheduler::APIResult APIResult
Definition: mesos.hpp:2850
Definition: scheduler.hpp:186
mesos::v1::TaskGroupInfo createTaskGroupInfo(const std::vector< mesos::v1::TaskInfo > &tasks)
Definition: mesos.hpp:2117
#define CHECK_SOME(expression)
Definition: check.hpp:50
mesos::v1::Resource::ReservationInfo createStaticReservationInfo(const std::string &role)
Definition: mesos.hpp:2126
Definition: mesos.hpp:2658
void start(process::Owned< mesos::internal::EndpointDetector > detector, ContentType contentType)
Definition: mesos.hpp:3291
Definition: containerizer.hpp:64
~TestResourceProvider()
Definition: mesos.hpp:3516
static UUID random()
Definition: uuid.hpp:38
void DropUnionMessages(Message message, UnionType unionType, From from, To to)
Definition: gmock.hpp:569
An "untyped" PID, used to encapsulate the process ID for lower-layer abstractions (eg...
Definition: pid.hpp:39
const ExecutorID id
Definition: mesos.hpp:2654
process::PID< master::Master > launch(const Flags &flags, mesos::allocator::Allocator *_allocator=nullptr)
Try< std::vector< Info > > infos(int familiy, int states)
mesos::v1::Offer::Operation UNRESERVE(Args &&...args)
Definition: mesos.hpp:2251
void events(Mesos *mesos, std::queue< Event > events)
Definition: mesos.hpp:2743
mesos::v1::Image createDockerImage(Args &&...args)
Definition: mesos.hpp:2042
Result< std::vector< Filter< Classifier > > > filters(const std::string &_link, const Handle &parent)
Definition: internal.hpp:769
mesos::v1::Volume createVolumeFromDockerImage(Args &&...args)
Definition: mesos.hpp:2067
void SetUp() override
Definition: utils.hpp:37
#define DEFAULT_CREDENTIAL
Definition: mesos.hpp:2505
TOffer::Operation SHRINK_VOLUME(const TResource &volume, const TValueScalar &subtract, const Option< TOperationID > &operationId=None())
Definition: mesos.hpp:1533
TOffer::Operation DESTROY(const TResources &volumes, const Option< TOperationID > &operationId=None())
Definition: mesos.hpp:1493
Represents a POSIX or Windows file system path and offers common path manipulations.
Definition: path.hpp:212
constexpr char READWRITE_HTTP_AUTHENTICATION_REALM[]
Definition: mesos.hpp:112
Definition: mesos.hpp:4062
Try< long > cpus()
Definition: os.hpp:265
void ExpectNoFutureUnionProtobufs(Message message, UnionType unionType, From from, To to)
Definition: mesos.hpp:3904
Definition: mesos.hpp:4108
SlaveOptions & withAuthorizer(const Option< Authorizer * > &authorizer)
Definition: mesos.hpp:185
Definition: mesos.hpp:592
Definition: mesos.hpp:565
Definition: mesos.hpp:3644
constexpr char READONLY_HTTP_AUTHENTICATION_REALM[]
Definition: mesos.hpp:111
Definition: mesos.hpp:3171
mesos::v1::Offer::Operation DESTROY(Args &&...args)
Definition: mesos.hpp:2271
virtual Status declineOffer(const OfferID &offerId, const Filters &filters=Filters())=0
uint16_t port
Definition: address.hpp:141
static Option< T > none()
Definition: option.hpp:32
constexpr char DEFAULT_TEST_ROLE[]
Definition: mesos.hpp:113
TOffer::Operation RESERVE(const TResources &resources, const Option< TOperationID > &operationId=None())
Definition: mesos.hpp:1442
std::string operator()(const ::testing::TestParamInfo< ParamExecutorType > &info) const
Definition: mesos.hpp:4064
Resources toUnreserved() const
Try< ImageManifest > parse(const std::string &value)
Definition: parse.hpp:36
void DropProtobufs(T t, From from, To to)
Definition: mesos.hpp:3839
Definition: mesos.hpp:4059
mesos::v1::scheduler::Call createCallReconcileOperations(const mesos::v1::FrameworkID &frameworkId, const std::vector< mesos::v1::scheduler::Call::ReconcileOperations::Operation > &operations={})
Definition: mesos.hpp:2445
const T & get() const &
Definition: option.hpp:119
process::http::Headers createBasicAuthHeaders(Args &&...args)
Definition: mesos.hpp:2216
Definition: resources.hpp:84
process::Future< Secret > generate(const process::http::authentication::Principal &principal) override
#define foreachpair(KEY, VALUE, ELEMS)
Definition: foreach.hpp:51
static ParamExecutorType defaultExecutor()
Definition: mesos.hpp:4083
Definition: mesos.hpp:3633
The SecretGenerator interface represents a mechanism to create a secret from a principal.
Definition: secret_generator.hpp:34
const int UNKNOWN
Definition: diagnosis.hpp:39
Try< int_fd > accept(int_fd s)
Definition: network.hpp:31
Definition: scheduler.hpp:70
static Try< URL > parse(const std::string &url)
Definition: url.hpp:75
SlaveOptions & withTaskStatusUpdateManager(const Option< slave::TaskStatusUpdateManager * > &taskStatusUpdateManager)
Definition: mesos.hpp:157
void subscribedDefault(const typename Event::Subscribed &subscribed)
Definition: mesos.hpp:3356
Definition: executor.hpp:75
process::Future< Message > FutureHttp(Message message, Path path, ContentType contentType, bool drop=false)
Definition: mesos.hpp:3788
mesos::v1::Parameters parameterize(Args &&...args)
Definition: mesos.hpp:2341
bool wait(const UPID &pid, const Duration &duration=Seconds(-1))
Wait for the process to exit for no more than the specified seconds.
Definition: executor.hpp:55
void dispatch(const UPID &pid, std::unique_ptr< lambda::CallableOnce< void(ProcessBase *)>> f, const Option< const std::type_info * > &functionType=None())
mesos::v1::resource_provider::Call Call
Definition: mesos.hpp:3583
void events(std::queue< Event > events)
Definition: mesos.hpp:3249
Definition: detector.hpp:36
bool isDefaultExecutor() const
Definition: mesos.hpp:4089
mesos::v1::Resource::DiskInfo::Source createDiskSourceBlock(Args &&...args)
Definition: mesos.hpp:2178
JSON::Proxy jsonify(const T &)
Definition: jsonify.hpp:702
#define UNREACHABLE()
Definition: unreachable.hpp:22
Future< X > then(lambda::CallableOnce< Future< X >(const T &)> f) const
Definition: future.hpp:1576
Type
Definition: mesos.hpp:4106
static ParamExecutorType commandExecutor()
Definition: mesos.hpp:4078
Basic model of an allocator: resources are allocated to a framework in the form of offers...
Definition: allocator.hpp:172
mesos::v1::executor::Call Call
Definition: mesos.hpp:3084
Future< Message > FutureMessage(Name name, From from, To to, bool drop=false)
Definition: gmock.hpp:499
void events(Mesos *mesos, std::queue< Event > events)
Definition: mesos.hpp:3009
void ExpectNoFutureUnionHttpRequests(Message message, UnionType unionType, Path path, Deserializer deserializer, bool drop=false)
Definition: gmock.hpp:643
Iterable< V > map(F &&f, const Iterable< U, Us... > &input)
Definition: lambda.hpp:46
Definition: protobuf.hpp:821
#define flags
Definition: decoder.hpp:18
process::Future< Message > FutureUnionProtobuf(Message message, UnionType unionType, From from, To to, bool drop=false)
Definition: mesos.hpp:3776
bool mock
Definition: mesos.hpp:205
Definition: mesos.hpp:2795
URI image(const std::string &repository, const std::string &reference, const std::string ®istry, const Option< std::string > &scheme=None(), const Option< int > &port=None())
Definition: docker.hpp:30
Definition: attributes.hpp:24
Contains information associated with an authenticated principal.
Definition: authenticator.hpp:41
void ExpectNoFutureMessages(Name name, From from, To to)
Definition: gmock.hpp:663
TestingMesosSchedulerDriver(Scheduler *scheduler, mesos::master::detector::MasterDetector *_detector, const FrameworkInfo &framework, bool implicitAcknowledgements=true)
Definition: mesos.hpp:2677
std::string error(const std::string &msg, uint32_t code)
SlaveOptions & withFlags(const Option< slave::Flags > &flags)
Definition: mesos.hpp:132
void ExpectNoFutureUnionHttpProtobufs(Message message, UnionType unionType, Path path, ContentType contentType, bool drop=false)
Definition: mesos.hpp:3932
Definition: executor.hpp:48
void ExpectNoFutureHttpProtobufs(Message message, Path path, ContentType contentType, bool drop=false)
Definition: mesos.hpp:3915
Type
Definition: capabilities.hpp:82
mesos::v1::scheduler::Call createCallKill(const mesos::v1::FrameworkID &frameworkId, const mesos::v1::TaskID &taskId, const Option< mesos::v1::AgentID > &agentId=None(), const Option< mesos::v1::KillPolicy > &killPolicy=None())
Definition: mesos.hpp:2420
mesos::v1::Offer::Operation CREATE(Args &&...args)
Definition: mesos.hpp:2261
TTaskInfo createTask(const TSlaveID &slaveId, const TResources &resourceRequests, const TCommandInfo &command, const Option< TExecutorID > &executorId=None(), const std::string &name="test-task", const std::string &id=id::UUID::random().toString(), const google::protobuf::Map< std::string, TScalar > &resourceLimits={})
Definition: mesos.hpp:953
process::Future< Nothing > send(const Call &call)
Definition: mesos.hpp:3533
Definition: mesos.hpp:392
std::string body
Definition: http.hpp:578
void start(process::Owned< mesos::internal::EndpointDetector > detector, ContentType contentType)
Definition: mesos.hpp:3522
uint64_t bytes() const
Definition: bytes.hpp:79
Definition: mesos.hpp:3615
TResource createPersistentVolume(const Bytes &size, const std::string &role, const std::string &persistenceId, const std::string &containerPath, const Option< std::string > &reservationPrincipal=None(), const Option< typename TResource::DiskInfo::Source > &source=None(), const Option< std::string > &creatorPrincipal=None(), bool isShared=false)
Definition: mesos.hpp:1296
std::string body
Definition: message.hpp:27
process::Future< Nothing > send(const Call &call)
Definition: mesos.hpp:3282
Future< http::Request > FutureUnionHttpRequest(Message message, UnionType unionType, Path path, Deserializer deserializer, bool drop=false)
Definition: gmock.hpp:473
SlaveOptions & withId(const Option< std::string > &id)
Definition: mesos.hpp:138
TestResourceProviderProcess(const ResourceProviderInfo &_info, const Option< Resources > &_resources=None())
Definition: mesos.hpp:3184
Option< zookeeper::URL > zookeeperUrl
Definition: mesos.hpp:360
An abstraction of a Master detector which can be used to detect the leading master from a group...
Definition: detector.hpp:38
TestMesos(ContentType contentType, const std::shared_ptr< MockHTTPExecutor< Mesos, Event >> &executor, const std::map< std::string, std::string > &environment)
Definition: mesos.hpp:3057
ACTION_P3(SendUpdateFromTaskID, frameworkId, executorId, state)
Definition: mesos.hpp:3130
Try< uint32_t > type(const std::string &path)
TResource createDiskResource(const std::string &value, const std::string &role, const Option< std::string > &persistenceID, const Option< std::string > &containerPath, const Option< typename TResource::DiskInfo::Source > &source=None(), bool isShared=false)
Definition: mesos.hpp:1265
TOffer::Operation LAUNCH_GROUP(const TExecutorInfo &executorInfo, const TTaskGroupInfo &taskGroup)
Definition: mesos.hpp:1566
Try< mode_t > mode(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:168
ACTION_P5(LaunchTasks, executor, tasks, cpus, mem, role)
Definition: mesos.hpp:2548
static TCredential create()
Definition: mesos.hpp:581
void allocate(const std::string &role)
void ExpectNoFutureProtobufs(T t, From from, To to)
Definition: mesos.hpp:3894
SlaveOptions & withFutureTracker(const Option< PendingFutureTracker * > &futureTracker)
Definition: mesos.hpp:191
Option< process::Owned< slave::CSIServer > > csiServer
Definition: mesos.hpp:216
process::Future< T > FutureProtobuf(T t, From from, To to, bool drop=false)
Definition: mesos.hpp:3765
hashmap< std::string, double > convertToHashmap(Args &&...args)
Definition: mesos.hpp:2233
Option< mesos::slave::ResourceEstimator * > resourceEstimator
Definition: mesos.hpp:211
TTaskGroupInfo createTaskGroupInfo(const std::vector< TTaskInfo > &tasks)
Definition: mesos.hpp:1057
Option< Resources > find(const Resources &targets) const
constexpr int FAILURE
Definition: decoder.hpp:50
Definition: mesos.hpp:2636
mesos::master::detector::MasterDetector * detector
Definition: mesos.hpp:204
Try< Nothing > kill(const std::string &hierarchy, const std::string &cgroup, int signal)
mesos::v1::Offer::Operation LAUNCH(const std::vector< mesos::v1::TaskInfo > &tasks)
Definition: mesos.hpp:2302
Option< Authorizer * > authorizer
Definition: mesos.hpp:214
Try< Nothing > bind(int_fd s, const Address &address)
Definition: network.hpp:46
struct process::UPID::ID id
mesos::v1::Resource createPersistentVolume(Args &&...args)
Definition: mesos.hpp:2206
Definition: qos_controller.hpp:44
mesos::v1::scheduler::Call createCallAccept(const mesos::v1::FrameworkID &frameworkId, const mesos::v1::Offer &offer, const std::vector< mesos::v1::Offer::Operation > &operations, const Option< mesos::v1::Filters > &filters=None())
Definition: mesos.hpp:2348
Definition: zookeeper_test_server.hpp:36
Option< slave::GarbageCollector * > gc
Definition: mesos.hpp:209
ACTION_P2(InvokeRecoverResourcesWithFilters, allocator, timeout)
Definition: allocator.hpp:193
google::protobuf::RepeatedPtrField< mesos::v1::WeightInfo > createWeightInfos(Args &&...args)
Definition: mesos.hpp:2225
mesos::v1::scheduler::Response Response
Definition: mesos.hpp:2854
TOffer::Operation GROW_VOLUME(const TResource &volume, const TResource &addition, const Option< TOperationID > &operationId=None())
Definition: mesos.hpp:1510
static void pause()
Pauses the clock e.g.
#define ASSERT_SOME(actual)
Definition: gtest.hpp:128
constexpr char DEFAULT_JWT_SECRET_KEY[]
Definition: mesos.hpp:114
std::string stringify(int flags)
Definition: mesos.hpp:4109
net::IP ip
Definition: address.hpp:140
TOffer::Operation CREATE_DISK(const TResource &source, const TTargetType &targetType, const Option< std::string > &targetProfile=None(), const Option< TOperationID > &operationId=None())
Definition: mesos.hpp:1583
Definition: mesos.hpp:3505
~TestMesos() override
Definition: mesos.hpp:2821
bool contains(const Resources &that) const
ACTION_P(InvokeInitialize, allocator)
Definition: allocator.hpp:61
Option< PendingFutureTracker * > futureTracker
Definition: mesos.hpp:215
Definition: process.hpp:505
TestResourceProvider(const ResourceProviderInfo &_info, const Option< Resources > &_resources=None())
Definition: mesos.hpp:3508
mesos::v1::Offer::Operation LAUNCH_GROUP(Args &&...args)
Definition: mesos.hpp:2310
mesos::v1::AgentID getAgentID(const mesos::v1::Offer &offer)
Definition: mesos.hpp:922
Deferred< void()> defer(const PID< T > &pid, void(T::*method)())
Definition: defer.hpp:35
Definition: mesos.hpp:2994
SlaveOptions & withQosController(const Option< mesos::slave::QoSController * > &qosController)
Definition: mesos.hpp:171
TestingMesosSchedulerDriver(Scheduler *scheduler, mesos::master::detector::MasterDetector *_detector)
Definition: mesos.hpp:2661
mesos::v1::Offer::Operation GROW_VOLUME(Args &&...args)
Definition: mesos.hpp:2281
TOffer::Operation CREATE(const TResources &volumes, const Option< TOperationID > &operationId=None())
Definition: mesos.hpp:1476
static bool paused()
Check whether clock is currently running.
static TCredential create()
Definition: mesos.hpp:567
void ExpectNoFutureHttpRequests(Message message, Path path, Deserializer deserializer, bool drop=false)
Definition: gmock.hpp:622
ACTION(DeclineOffers)
Definition: mesos.hpp:2598
void stop()
Definition: mesos.hpp:3339
Future< http::Request > FutureHttpRequest(Message message, Path path, Deserializer deserializer, bool drop=false)
Definition: gmock.hpp:445
constexpr const char * name
Definition: shell.hpp:41
void DropUnionHttpProtobufs(Message message, UnionType unionType, Path path, ContentType contentType, bool drop=false)
Definition: mesos.hpp:3876
mesos::v1::Resource::DiskInfo createDiskInfo(Args &&...args)
Definition: mesos.hpp:2152
Option< slave::Containerizer * > containerizer
Definition: mesos.hpp:208
SlaveOptions & withSecretGenerator(const Option< mesos::SecretGenerator * > &secretGenerator)
Definition: mesos.hpp:178
void operationDefault(const typename Event::ApplyOperation &operation)
Definition: mesos.hpp:3386
void TearDown() override
Definition: utils.hpp:44
SlaveOptions & withContainerizer(const Option< slave::Containerizer * > &containerizer)
Definition: mesos.hpp:144
Option< slave::TaskStatusUpdateManager * > taskStatusUpdateManager
Definition: mesos.hpp:210
mesos::v1::executor::Mesos Mesos
Definition: mesos.hpp:3086
mesos::v1::scheduler::Call createCallAcknowledge(const mesos::v1::FrameworkID &frameworkId, const mesos::v1::AgentID &agentId, const mesos::v1::scheduler::Event::Update &update)
Definition: mesos.hpp:2373
Try< std::set< std::string > > subsystems()
Definition: mesos.hpp:2516
void filter(Filter *filter)
virtual master::Flags CreateMasterFlags()
MATCHER_P(OffersHaveAnyResource, filter,"")
Definition: mesos.hpp:3952
void DropMessages(Name name, From from, To to)
Definition: gmock.hpp:557
Future< size_t > send(const int_fd &fd, const void *buf, size_t size)
mesos::Environment createEnvironment(const hashmap< std::string, std::string > &map)
Definition: mesos.hpp:2488