> On Jan. 11, 2016, 2:13 a.m., Adam B wrote: > > src/tests/hierarchical_allocator_tests.cpp, lines 2218-2219 > > <https://reviews.apache.org/r/41672/diff/6/?file=1181569#file1181569line2218> > > > > Why hardcode 3? I'd think you could just run a while loop and actually > > assert the size that you think the allocations hashmap will be. (And what > > key will be in each entry.) > > Yongqiao Wang wrote: > allocations is a process::Queue<Allocation>, and I can not get its size > due to there is no interface can do this. Could you give me a detailed > description for your suggestions? Thanks. > > In addition, I can make sure there are 3 allocations because in my test > case, there are 4 agents and 3 frameworks, and their weights are 3:1:2, so > according to the fair share, each framework can get one allocation at least. > > Adam B wrote: > Fair point, and even if you did a `while(allocations.get() != > something)`, you'd actually be getting a future that your `while` condition > would have to AWAIT before it could evaluate. Messy. > Rather, you're iterating 3 times and AWAITing each time, therefore > asserting that there are at least 3 allocations. To prove that there are > exactly 3 (or 2 in the other cases), can you > `AWAIT_FAILED(allocations.get())` after your loops? I'm not sure if the > `Clock` would work for/against you there, especially since you're recovering > resources inside the loop instead of after it. > Looks like `process::queue::get()` returns a READY future immediately if > the offer queue isn't empty, so maybe you can get away with > `ASSERT_FALSE(allocation.isReady());` after the loop. > > Yongqiao Wang wrote: > I tested found that ASSERT_FALSE(allocations.get().isReady()) does not > work, because a new promise will be created when call allocations.get(). > > I have done this by checking whether the total resources have been > allocated to those allocations, if yes, then we can be sure there are only 3 > or 2 allocations in those cases due to no resources for any other allocation. > you can refer to the code diff for the detais, thx.
Good enough for me. Dropping the issue. Thanks for investigating. - Adam ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/41672/#review113711 ----------------------------------------------------------- On Jan. 18, 2016, 12:54 a.m., Yongqiao Wang wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://reviews.apache.org/r/41672/ > ----------------------------------------------------------- > > (Updated Jan. 18, 2016, 12:54 a.m.) > > > Review request for mesos, Adam B, Neil Conway, and Qian Zhang. > > > Bugs: MESOS-4200 > https://issues.apache.org/jira/browse/MESOS-4200 > > > Repository: mesos > > > Description > ------- > > Test case(s) for weights + allocation behaviour. > > > Diffs > ----- > > src/tests/hierarchical_allocator_tests.cpp > 9362dd306497ba01e0f387c3862456cdcac6f863 > > Diff: https://reviews.apache.org/r/41672/diff/ > > > Testing > ------- > > Make check done: > $ ./src/mesos-tests --gtest_filter=HierarchicalAllocatorTest.UpdateWeight > Source directory: /Users/yqwyq/Desktop/mesos > Build directory: /Users/yqwyq/Desktop/mesos/build > [==========] Running 1 test from 1 test case. > [----------] Global test environment set-up. > [----------] 1 test from HierarchicalAllocatorTest > [ RUN ] HierarchicalAllocatorTest.UpdateWeight > [ OK ] HierarchicalAllocatorTest.UpdateWeight (87 ms) > [----------] 1 test from HierarchicalAllocatorTest (87 ms total) > > [----------] Global test environment tear-down > [==========] 1 test from 1 test case ran. (176 ms total) > [ PASSED ] 1 test. > > > Thanks, > > Yongqiao Wang > >
