test_tasktable.cpp 15.4 KB
Newer Older
J
jinhai 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

W
wxyu 已提交
18
#include <gtest/gtest.h>
W
wxyu 已提交
19
#include "scheduler/TaskTable.h"
W
wxyu 已提交
20
#include "scheduler/task/TestTask.h"
W
wxyu 已提交
21
#include "scheduler/tasklabel/DefaultLabel.h"
W
wxyu 已提交
22

W
wxyu 已提交
23 24
/************ TaskTableBaseTest ************/

W
wxyu 已提交
25
class TaskTableItemTest : public ::testing::Test {
S
starlord 已提交
26
 protected:
W
wxyu 已提交
27 28
    void
    SetUp() override {
S
starlord 已提交
29
        std::vector<milvus::scheduler::TaskTableItemState> states{
W
wxyu 已提交
30 31 32 33 34
            milvus::scheduler::TaskTableItemState::INVALID,   milvus::scheduler::TaskTableItemState::START,
            milvus::scheduler::TaskTableItemState::LOADING,   milvus::scheduler::TaskTableItemState::LOADED,
            milvus::scheduler::TaskTableItemState::EXECUTING, milvus::scheduler::TaskTableItemState::EXECUTED,
            milvus::scheduler::TaskTableItemState::MOVING,    milvus::scheduler::TaskTableItemState::MOVED};
        for (auto& state : states) {
S
starlord 已提交
35
            auto item = std::make_shared<milvus::scheduler::TaskTableItem>();
W
wxyu 已提交
36 37 38
            item->state = state;
            items_.emplace_back(item);
        }
W
wxyu 已提交
39 40
    }

S
starlord 已提交
41 42
    milvus::scheduler::TaskTableItem default_;
    std::vector<milvus::scheduler::TaskTableItemPtr> items_;
W
wxyu 已提交
43 44
};

S
starlord 已提交
45
TEST_F(TaskTableItemTest, CONSTRUCT) {
W
wxyu 已提交
46
    ASSERT_EQ(default_.id, 0);
W
wxyu 已提交
47
    ASSERT_EQ(default_.task, nullptr);
S
starlord 已提交
48
    ASSERT_EQ(default_.state, milvus::scheduler::TaskTableItemState::INVALID);
W
wxyu 已提交
49 50
}

S
starlord 已提交
51
TEST_F(TaskTableItemTest, DESTRUCT) {
S
starlord 已提交
52
    auto p_item = new milvus::scheduler::TaskTableItem();
W
wxyu 已提交
53 54 55
    delete p_item;
}

S
starlord 已提交
56
TEST_F(TaskTableItemTest, IS_FINISH) {
W
wxyu 已提交
57 58 59
    for (auto& item : items_) {
        if (item->state == milvus::scheduler::TaskTableItemState::EXECUTED ||
            item->state == milvus::scheduler::TaskTableItemState::MOVED) {
W
wxyu 已提交
60 61 62 63 64 65 66
            ASSERT_TRUE(item->IsFinish());
        } else {
            ASSERT_FALSE(item->IsFinish());
        }
    }
}

S
starlord 已提交
67
TEST_F(TaskTableItemTest, DUMP) {
W
wxyu 已提交
68
    for (auto& item : items_) {
W
wxyu 已提交
69 70 71 72
        ASSERT_FALSE(item->Dump().empty());
    }
}

S
starlord 已提交
73
TEST_F(TaskTableItemTest, LOAD) {
W
wxyu 已提交
74
    for (auto& item : items_) {
W
wxyu 已提交
75 76
        auto before_state = item->state;
        auto ret = item->Load();
S
starlord 已提交
77
        if (before_state == milvus::scheduler::TaskTableItemState::START) {
W
wxyu 已提交
78
            ASSERT_TRUE(ret);
S
starlord 已提交
79
            ASSERT_EQ(item->state, milvus::scheduler::TaskTableItemState::LOADING);
W
wxyu 已提交
80 81 82 83 84 85 86
        } else {
            ASSERT_FALSE(ret);
            ASSERT_EQ(item->state, before_state);
        }
    }
}

S
starlord 已提交
87
TEST_F(TaskTableItemTest, LOADED) {
W
wxyu 已提交
88
    for (auto& item : items_) {
W
wxyu 已提交
89 90
        auto before_state = item->state;
        auto ret = item->Loaded();
S
starlord 已提交
91
        if (before_state == milvus::scheduler::TaskTableItemState::LOADING) {
W
wxyu 已提交
92
            ASSERT_TRUE(ret);
S
starlord 已提交
93
            ASSERT_EQ(item->state, milvus::scheduler::TaskTableItemState::LOADED);
W
wxyu 已提交
94 95 96 97 98 99 100
        } else {
            ASSERT_FALSE(ret);
            ASSERT_EQ(item->state, before_state);
        }
    }
}

S
starlord 已提交
101
TEST_F(TaskTableItemTest, EXECUTE) {
W
wxyu 已提交
102
    for (auto& item : items_) {
W
wxyu 已提交
103 104
        auto before_state = item->state;
        auto ret = item->Execute();
S
starlord 已提交
105
        if (before_state == milvus::scheduler::TaskTableItemState::LOADED) {
W
wxyu 已提交
106
            ASSERT_TRUE(ret);
S
starlord 已提交
107
            ASSERT_EQ(item->state, milvus::scheduler::TaskTableItemState::EXECUTING);
W
wxyu 已提交
108 109 110 111 112 113 114
        } else {
            ASSERT_FALSE(ret);
            ASSERT_EQ(item->state, before_state);
        }
    }
}

S
starlord 已提交
115
TEST_F(TaskTableItemTest, EXECUTED) {
W
wxyu 已提交
116
    for (auto& item : items_) {
W
wxyu 已提交
117 118
        auto before_state = item->state;
        auto ret = item->Executed();
S
starlord 已提交
119
        if (before_state == milvus::scheduler::TaskTableItemState::EXECUTING) {
W
wxyu 已提交
120
            ASSERT_TRUE(ret);
S
starlord 已提交
121
            ASSERT_EQ(item->state, milvus::scheduler::TaskTableItemState::EXECUTED);
W
wxyu 已提交
122 123 124 125 126 127 128
        } else {
            ASSERT_FALSE(ret);
            ASSERT_EQ(item->state, before_state);
        }
    }
}

S
starlord 已提交
129
TEST_F(TaskTableItemTest, MOVE) {
W
wxyu 已提交
130
    for (auto& item : items_) {
W
wxyu 已提交
131 132
        auto before_state = item->state;
        auto ret = item->Move();
S
starlord 已提交
133
        if (before_state == milvus::scheduler::TaskTableItemState::LOADED) {
W
wxyu 已提交
134
            ASSERT_TRUE(ret);
S
starlord 已提交
135
            ASSERT_EQ(item->state, milvus::scheduler::TaskTableItemState::MOVING);
W
wxyu 已提交
136 137 138 139 140 141 142
        } else {
            ASSERT_FALSE(ret);
            ASSERT_EQ(item->state, before_state);
        }
    }
}

S
starlord 已提交
143
TEST_F(TaskTableItemTest, MOVED) {
W
wxyu 已提交
144
    for (auto& item : items_) {
W
wxyu 已提交
145 146
        auto before_state = item->state;
        auto ret = item->Moved();
S
starlord 已提交
147
        if (before_state == milvus::scheduler::TaskTableItemState::MOVING) {
W
wxyu 已提交
148
            ASSERT_TRUE(ret);
S
starlord 已提交
149
            ASSERT_EQ(item->state, milvus::scheduler::TaskTableItemState::MOVED);
W
wxyu 已提交
150 151 152 153 154 155
        } else {
            ASSERT_FALSE(ret);
            ASSERT_EQ(item->state, before_state);
        }
    }
}
W
wxyu 已提交
156 157 158 159

/************ TaskTableBaseTest ************/

class TaskTableBaseTest : public ::testing::Test {
S
starlord 已提交
160
 protected:
W
wxyu 已提交
161 162
    void
    SetUp() override {
S
starlord 已提交
163
        milvus::scheduler::TableFileSchemaPtr dummy = nullptr;
W
wxyu 已提交
164
        invalid_task_ = nullptr;
S
starlord 已提交
165 166 167
        auto label = std::make_shared<milvus::scheduler::DefaultLabel>();
        task1_ = std::make_shared<milvus::scheduler::TestTask>(dummy, label);
        task2_ = std::make_shared<milvus::scheduler::TestTask>(dummy, label);
W
wxyu 已提交
168 169
    }

S
starlord 已提交
170 171 172 173
    milvus::scheduler::TaskPtr invalid_task_;
    milvus::scheduler::TaskPtr task1_;
    milvus::scheduler::TaskPtr task2_;
    milvus::scheduler::TaskTable empty_table_;
W
wxyu 已提交
174 175
};

S
starlord 已提交
176
TEST_F(TaskTableBaseTest, SUBSCRIBER) {
W
wxyu 已提交
177
    bool flag = false;
W
wxyu 已提交
178
    auto callback = [&]() { flag = true; };
W
wxyu 已提交
179 180 181 182 183
    empty_table_.RegisterSubscriber(callback);
    empty_table_.Put(task1_);
    ASSERT_TRUE(flag);
}

S
starlord 已提交
184
TEST_F(TaskTableBaseTest, PUT_TASK) {
W
wxyu 已提交
185
    empty_table_.Put(task1_);
186
    ASSERT_EQ(empty_table_.at(0)->task, task1_);
W
wxyu 已提交
187 188
}

S
starlord 已提交
189
TEST_F(TaskTableBaseTest, PUT_INVALID_TEST) {
W
wxyu 已提交
190
    empty_table_.Put(invalid_task_);
191
    ASSERT_EQ(empty_table_.at(0)->task, invalid_task_);
W
wxyu 已提交
192 193
}

S
starlord 已提交
194
TEST_F(TaskTableBaseTest, PUT_BATCH) {
S
starlord 已提交
195
    std::vector<milvus::scheduler::TaskPtr> tasks{task1_, task2_};
196 197 198
    for (auto& task : tasks) {
        empty_table_.Put(task);
    }
199 200
    ASSERT_EQ(empty_table_.at(0)->task, task1_);
    ASSERT_EQ(empty_table_.at(1)->task, task2_);
W
wxyu 已提交
201 202
}

S
starlord 已提交
203
TEST_F(TaskTableBaseTest, SIZE) {
204
    ASSERT_EQ(empty_table_.size(), 0);
W
wxyu 已提交
205
    empty_table_.Put(task1_);
206
    ASSERT_EQ(empty_table_.size(), 1);
W
wxyu 已提交
207 208
}

S
starlord 已提交
209
TEST_F(TaskTableBaseTest, OPERATOR) {
W
wxyu 已提交
210
    empty_table_.Put(task1_);
211
    ASSERT_EQ(empty_table_.at(0), empty_table_[0]);
W
wxyu 已提交
212 213
}

S
starlord 已提交
214
TEST_F(TaskTableBaseTest, PICK_TO_LOAD) {
W
wxyu 已提交
215 216 217 218
    const size_t NUM_TASKS = 10;
    for (size_t i = 0; i < NUM_TASKS; ++i) {
        empty_table_.Put(task1_);
    }
S
starlord 已提交
219 220
    empty_table_[0]->state = milvus::scheduler::TaskTableItemState::MOVED;
    empty_table_[1]->state = milvus::scheduler::TaskTableItemState::EXECUTED;
W
wxyu 已提交
221 222 223

    auto indexes = empty_table_.PickToLoad(1);
    ASSERT_EQ(indexes.size(), 1);
224
    ASSERT_EQ(indexes[0] % empty_table_.capacity(), 2);
W
wxyu 已提交
225 226
}

S
starlord 已提交
227
TEST_F(TaskTableBaseTest, PICK_TO_LOAD_LIMIT) {
W
wxyu 已提交
228 229 230 231
    const size_t NUM_TASKS = 10;
    for (size_t i = 0; i < NUM_TASKS; ++i) {
        empty_table_.Put(task1_);
    }
S
starlord 已提交
232 233
    empty_table_[0]->state = milvus::scheduler::TaskTableItemState::MOVED;
    empty_table_[1]->state = milvus::scheduler::TaskTableItemState::EXECUTED;
W
wxyu 已提交
234 235 236

    auto indexes = empty_table_.PickToLoad(3);
    ASSERT_EQ(indexes.size(), 3);
237 238 239
    ASSERT_EQ(indexes[0] % empty_table_.capacity(), 2);
    ASSERT_EQ(indexes[1] % empty_table_.capacity(), 3);
    ASSERT_EQ(indexes[2] % empty_table_.capacity(), 4);
W
wxyu 已提交
240 241
}

S
starlord 已提交
242
TEST_F(TaskTableBaseTest, PICK_TO_LOAD_CACHE) {
W
wxyu 已提交
243 244 245 246
    const size_t NUM_TASKS = 10;
    for (size_t i = 0; i < NUM_TASKS; ++i) {
        empty_table_.Put(task1_);
    }
S
starlord 已提交
247 248
    empty_table_[0]->state = milvus::scheduler::TaskTableItemState::MOVED;
    empty_table_[1]->state = milvus::scheduler::TaskTableItemState::EXECUTED;
W
wxyu 已提交
249 250 251 252

    // first pick, non-cache
    auto indexes = empty_table_.PickToLoad(1);
    ASSERT_EQ(indexes.size(), 1);
253
    ASSERT_EQ(indexes[0] % empty_table_.capacity(), 2);
W
wxyu 已提交
254 255 256

    // second pick, iterate from 2
    // invalid state change
S
starlord 已提交
257
    empty_table_[1]->state = milvus::scheduler::TaskTableItemState::START;
W
wxyu 已提交
258 259
    indexes = empty_table_.PickToLoad(1);
    ASSERT_EQ(indexes.size(), 1);
260
    ASSERT_EQ(indexes[0] % empty_table_.capacity(), 2);
W
wxyu 已提交
261 262
}

S
starlord 已提交
263
TEST_F(TaskTableBaseTest, PICK_TO_EXECUTE) {
W
wxyu 已提交
264 265 266 267
    const size_t NUM_TASKS = 10;
    for (size_t i = 0; i < NUM_TASKS; ++i) {
        empty_table_.Put(task1_);
    }
S
starlord 已提交
268 269 270
    empty_table_[0]->state = milvus::scheduler::TaskTableItemState::MOVED;
    empty_table_[1]->state = milvus::scheduler::TaskTableItemState::EXECUTED;
    empty_table_[2]->state = milvus::scheduler::TaskTableItemState::LOADED;
W
wxyu 已提交
271 272 273

    auto indexes = empty_table_.PickToExecute(1);
    ASSERT_EQ(indexes.size(), 1);
274
    ASSERT_EQ(indexes[0] % empty_table_.capacity(), 2);
W
wxyu 已提交
275 276
}

S
starlord 已提交
277
TEST_F(TaskTableBaseTest, PICK_TO_EXECUTE_LIMIT) {
W
wxyu 已提交
278 279 280 281
    const size_t NUM_TASKS = 10;
    for (size_t i = 0; i < NUM_TASKS; ++i) {
        empty_table_.Put(task1_);
    }
S
starlord 已提交
282 283 284 285
    empty_table_[0]->state = milvus::scheduler::TaskTableItemState::MOVED;
    empty_table_[1]->state = milvus::scheduler::TaskTableItemState::EXECUTED;
    empty_table_[2]->state = milvus::scheduler::TaskTableItemState::LOADED;
    empty_table_[3]->state = milvus::scheduler::TaskTableItemState::LOADED;
W
wxyu 已提交
286 287 288

    auto indexes = empty_table_.PickToExecute(3);
    ASSERT_EQ(indexes.size(), 2);
289 290
    ASSERT_EQ(indexes[0] % empty_table_.capacity(), 2);
    ASSERT_EQ(indexes[1] % empty_table_.capacity(), 3);
W
wxyu 已提交
291 292
}

S
starlord 已提交
293
TEST_F(TaskTableBaseTest, PICK_TO_EXECUTE_CACHE) {
W
wxyu 已提交
294 295 296 297
    const size_t NUM_TASKS = 10;
    for (size_t i = 0; i < NUM_TASKS; ++i) {
        empty_table_.Put(task1_);
    }
S
starlord 已提交
298 299 300
    empty_table_[0]->state = milvus::scheduler::TaskTableItemState::MOVED;
    empty_table_[1]->state = milvus::scheduler::TaskTableItemState::EXECUTED;
    empty_table_[2]->state = milvus::scheduler::TaskTableItemState::LOADED;
W
wxyu 已提交
301 302 303 304

    // first pick, non-cache
    auto indexes = empty_table_.PickToExecute(1);
    ASSERT_EQ(indexes.size(), 1);
305
    ASSERT_EQ(indexes[0] % empty_table_.capacity(), 2);
W
wxyu 已提交
306 307 308

    // second pick, iterate from 2
    // invalid state change
S
starlord 已提交
309
    empty_table_[1]->state = milvus::scheduler::TaskTableItemState::START;
W
wxyu 已提交
310 311
    indexes = empty_table_.PickToExecute(1);
    ASSERT_EQ(indexes.size(), 1);
312
    ASSERT_EQ(indexes[0] % empty_table_.capacity(), 2);
W
wxyu 已提交
313 314
}

W
wxyu 已提交
315 316 317
/************ TaskTableAdvanceTest ************/

class TaskTableAdvanceTest : public ::testing::Test {
S
starlord 已提交
318
 protected:
W
wxyu 已提交
319 320
    void
    SetUp() override {
S
starlord 已提交
321
        milvus::scheduler::TableFileSchemaPtr dummy = nullptr;
W
wxyu 已提交
322
        for (uint64_t i = 0; i < 8; ++i) {
S
starlord 已提交
323 324
            auto label = std::make_shared<milvus::scheduler::DefaultLabel>();
            auto task = std::make_shared<milvus::scheduler::TestTask>(dummy, label);
W
wxyu 已提交
325 326 327
            table1_.Put(task);
        }

328 329 330 331 332 333 334 335
        table1_.at(0)->state = milvus::scheduler::TaskTableItemState::INVALID;
        table1_.at(1)->state = milvus::scheduler::TaskTableItemState::START;
        table1_.at(2)->state = milvus::scheduler::TaskTableItemState::LOADING;
        table1_.at(3)->state = milvus::scheduler::TaskTableItemState::LOADED;
        table1_.at(4)->state = milvus::scheduler::TaskTableItemState::EXECUTING;
        table1_.at(5)->state = milvus::scheduler::TaskTableItemState::EXECUTED;
        table1_.at(6)->state = milvus::scheduler::TaskTableItemState::MOVING;
        table1_.at(7)->state = milvus::scheduler::TaskTableItemState::MOVED;
W
wxyu 已提交
336 337
    }

S
starlord 已提交
338
    milvus::scheduler::TaskTable table1_;
W
wxyu 已提交
339 340
};

S
starlord 已提交
341
TEST_F(TaskTableAdvanceTest, LOAD) {
S
starlord 已提交
342
    std::vector<milvus::scheduler::TaskTableItemState> before_state;
343
    for (size_t i = 0; i < table1_.size(); ++i) {
W
wxyu 已提交
344
        before_state.push_back(table1_[i]->state);
W
wxyu 已提交
345 346
    }

347
    for (size_t i = 0; i < table1_.size(); ++i) {
W
wxyu 已提交
348 349 350
        table1_.Load(i);
    }

351
    for (size_t i = 0; i < table1_.size(); ++i) {
S
starlord 已提交
352
        if (before_state[i] == milvus::scheduler::TaskTableItemState::START) {
353
            ASSERT_EQ(table1_.at(i)->state, milvus::scheduler::TaskTableItemState::LOADING);
W
wxyu 已提交
354
        } else {
355
            ASSERT_EQ(table1_.at(i)->state, before_state[i]);
W
wxyu 已提交
356 357 358 359
        }
    }
}

S
starlord 已提交
360
TEST_F(TaskTableAdvanceTest, LOADED) {
S
starlord 已提交
361
    std::vector<milvus::scheduler::TaskTableItemState> before_state;
362
    for (size_t i = 0; i < table1_.size(); ++i) {
W
wxyu 已提交
363
        before_state.push_back(table1_[i]->state);
W
wxyu 已提交
364 365
    }

366
    for (size_t i = 0; i < table1_.size(); ++i) {
W
wxyu 已提交
367 368
        table1_.Loaded(i);
    }
W
wxyu 已提交
369

370
    for (size_t i = 0; i < table1_.size(); ++i) {
S
starlord 已提交
371
        if (before_state[i] == milvus::scheduler::TaskTableItemState::LOADING) {
372
            ASSERT_EQ(table1_.at(i)->state, milvus::scheduler::TaskTableItemState::LOADED);
W
wxyu 已提交
373
        } else {
374
            ASSERT_EQ(table1_.at(i)->state, before_state[i]);
W
wxyu 已提交
375 376
        }
    }
W
wxyu 已提交
377 378
}

S
starlord 已提交
379
TEST_F(TaskTableAdvanceTest, EXECUTE) {
S
starlord 已提交
380
    std::vector<milvus::scheduler::TaskTableItemState> before_state;
381
    for (size_t i = 0; i < table1_.size(); ++i) {
W
wxyu 已提交
382
        before_state.push_back(table1_[i]->state);
W
wxyu 已提交
383 384
    }

385
    for (size_t i = 0; i < table1_.size(); ++i) {
W
wxyu 已提交
386 387
        table1_.Execute(i);
    }
W
wxyu 已提交
388

389
    for (size_t i = 0; i < table1_.size(); ++i) {
S
starlord 已提交
390
        if (before_state[i] == milvus::scheduler::TaskTableItemState::LOADED) {
391
            ASSERT_EQ(table1_.at(i)->state, milvus::scheduler::TaskTableItemState::EXECUTING);
W
wxyu 已提交
392
        } else {
393
            ASSERT_EQ(table1_.at(i)->state, before_state[i]);
W
wxyu 已提交
394 395 396 397
        }
    }
}

S
starlord 已提交
398
TEST_F(TaskTableAdvanceTest, EXECUTED) {
S
starlord 已提交
399
    std::vector<milvus::scheduler::TaskTableItemState> before_state;
400
    for (size_t i = 0; i < table1_.size(); ++i) {
W
wxyu 已提交
401
        before_state.push_back(table1_[i]->state);
W
wxyu 已提交
402 403
    }

404
    for (size_t i = 0; i < table1_.size(); ++i) {
W
wxyu 已提交
405 406 407
        table1_.Executed(i);
    }

408
    for (size_t i = 0; i < table1_.size(); ++i) {
S
starlord 已提交
409
        if (before_state[i] == milvus::scheduler::TaskTableItemState::EXECUTING) {
410
            ASSERT_EQ(table1_.at(i)->state, milvus::scheduler::TaskTableItemState::EXECUTED);
W
wxyu 已提交
411
        } else {
412
            ASSERT_EQ(table1_.at(i)->state, before_state[i]);
W
wxyu 已提交
413 414
        }
    }
W
wxyu 已提交
415 416
}

S
starlord 已提交
417
TEST_F(TaskTableAdvanceTest, MOVE) {
S
starlord 已提交
418
    std::vector<milvus::scheduler::TaskTableItemState> before_state;
419
    for (size_t i = 0; i < table1_.size(); ++i) {
W
wxyu 已提交
420
        before_state.push_back(table1_[i]->state);
W
wxyu 已提交
421 422
    }

423
    for (size_t i = 0; i < table1_.size(); ++i) {
W
wxyu 已提交
424 425 426
        table1_.Move(i);
    }

427
    for (size_t i = 0; i < table1_.size(); ++i) {
S
starlord 已提交
428
        if (before_state[i] == milvus::scheduler::TaskTableItemState::LOADED) {
429
            ASSERT_EQ(table1_.at(i)->state, milvus::scheduler::TaskTableItemState::MOVING);
W
wxyu 已提交
430
        } else {
431
            ASSERT_EQ(table1_.at(i)->state, before_state[i]);
W
wxyu 已提交
432 433 434
        }
    }
}
W
wxyu 已提交
435

S
starlord 已提交
436
TEST_F(TaskTableAdvanceTest, MOVED) {
S
starlord 已提交
437
    std::vector<milvus::scheduler::TaskTableItemState> before_state;
438
    for (size_t i = 0; i < table1_.size(); ++i) {
W
wxyu 已提交
439
        before_state.push_back(table1_[i]->state);
W
wxyu 已提交
440 441
    }

442
    for (size_t i = 0; i < table1_.size(); ++i) {
W
wxyu 已提交
443 444 445
        table1_.Moved(i);
    }

446
    for (size_t i = 0; i < table1_.size(); ++i) {
S
starlord 已提交
447
        if (before_state[i] == milvus::scheduler::TaskTableItemState::MOVING) {
448
            ASSERT_EQ(table1_.at(i)->state, milvus::scheduler::TaskTableItemState::MOVED);
W
wxyu 已提交
449
        } else {
450
            ASSERT_EQ(table1_.at(i)->state, before_state[i]);
W
wxyu 已提交
451 452
        }
    }
W
wxyu 已提交
453
}