Fixed filters in test `ROOT_ReconcileDroppedOperation` for consistency.

Review: https://reviews.apache.org/r/67257


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/261fcca2
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/261fcca2
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/261fcca2

Branch: refs/heads/master
Commit: 261fcca27314a0264ff4818b186210de63ca1bd2
Parents: 1a1f0ba
Author: Chun-Hung Hsiao <chhs...@mesosphere.io>
Authored: Tue May 22 15:51:17 2018 -0700
Committer: Chun-Hung Hsiao <chhs...@mesosphere.io>
Committed: Thu May 31 18:29:56 2018 -0700

----------------------------------------------------------------------
 .../storage_local_resource_provider_tests.cpp   | 27 ++++++++++++--------
 1 file changed, 16 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/261fcca2/src/tests/storage_local_resource_provider_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/storage_local_resource_provider_tests.cpp 
b/src/tests/storage_local_resource_provider_tests.cpp
index 17df704..1afe8a8 100644
--- a/src/tests/storage_local_resource_provider_tests.cpp
+++ b/src/tests/storage_local_resource_provider_tests.cpp
@@ -3476,6 +3476,15 @@ TEST_F(StorageLocalResourceProviderTest, 
ROOT_ReconcileDroppedOperation)
 
   EXPECT_CALL(sched, registered(&driver, _, _));
 
+  // We use the following filter to filter offers that do not have
+  // wanted resources for 365 days (the maximum).
+  Filters declineFilters;
+  declineFilters.set_refuse_seconds(Days(365).secs());
+
+  // Decline offers that do not contain wanted resources.
+  EXPECT_CALL(sched, resourceOffers(&driver, _))
+    .WillRepeatedly(DeclineOffers(declineFilters));
+
   // We are only interested in pre-existing volumes, which have IDs but no
   // profile. We use pre-existing volumes to make it easy to send multiple
   // operations on multiple resources.
@@ -3486,21 +3495,12 @@ TEST_F(StorageLocalResourceProviderTest, 
ROOT_ReconcileDroppedOperation)
       !r.disk().source().has_profile();
   };
 
-  // We use the filter explicitly here so that the resources will not
-  // be filtered for 5 seconds (the default).
-  Filters filters;
-  filters.set_refuse_seconds(0);
-
-  // Decline offers that contain only the agent's default resources.
-  EXPECT_CALL(sched, resourceOffers(&driver, _))
-    .WillRepeatedly(DeclineOffers(filters));
-
   Future<vector<Offer>> offersBeforeOperations;
 
   EXPECT_CALL(sched, resourceOffers(&driver, OffersHaveAnyResource(
       isPreExistingVolume)))
     .WillOnce(FutureArg<1>(&offersBeforeOperations))
-    .WillRepeatedly(DeclineOffers(filters)); // Decline further matching 
offers.
+    .WillRepeatedly(DeclineOffers(declineFilters)); // Decline further offers.
 
   driver.start();
 
@@ -3528,12 +3528,17 @@ TEST_F(StorageLocalResourceProviderTest, 
ROOT_ReconcileDroppedOperation)
   Future<UpdateOperationStatusMessage> operationFinishedStatus =
     FUTURE_PROTOBUF(UpdateOperationStatusMessage(), _, _);
 
+  // We use the following filter so that the resources will not be
+  // filtered for 5 seconds (the default).
+  Filters acceptFilters;
+  acceptFilters.set_refuse_seconds(0);
+
   // Attempt the creation of two volumes.
   driver.acceptOffers(
       {offersBeforeOperations->at(0).id()},
       {CREATE_VOLUME(sources.at(0), Resource::DiskInfo::Source::MOUNT),
        CREATE_VOLUME(sources.at(1), Resource::DiskInfo::Source::MOUNT)},
-      filters);
+      acceptFilters);
 
   // Ensure that the operations are processed.
   Clock::settle();

Reply via email to