Skip to content

Commit

Permalink
fix namespace_service_test
Browse files Browse the repository at this point in the history
  • Loading branch information
bai-charisu authored and YunhuiChen committed Aug 26, 2020
1 parent a9c30ec commit 7a99248
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions test/mds/nameserver2/namespace_service_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,8 @@ TEST_F(NameSpaceServiceTest, deletefiletests) {
ASSERT_TRUE(false);
}

while (1) {
int attempts = 0;
while (attempts < 100) {
cntl.Reset();
CheckSnapShotStatusRequest checkRequest;
CheckSnapShotStatusResponse checkResponse;
Expand All @@ -1488,12 +1489,15 @@ TEST_F(NameSpaceServiceTest, deletefiletests) {
} else {
ASSERT_EQ(checkResponse.statuscode(), StatusCode::kOK);
sleep(1);
++attempts;
}
} else {
ASSERT_TRUE(false);
break;
}
}
ASSERT_LE(attempts, 100)
<< "max attempts for check snapshot status exhausted";


// 2 如果目录下有文件,那么删除目录返回kDirNotEmpty
Expand Down Expand Up @@ -1718,25 +1722,31 @@ TEST_F(NameSpaceServiceTest, deletefiletests) {
ASSERT_TRUE(false);
}

sleep(1);

cntl.Reset();
date = TimeUtility::GetTimeofDayUs();
str2sig = Authenticator::GetString2Signature(date,
attempts = 0;
while (attempts < 100) {
cntl.Reset();
date = TimeUtility::GetTimeofDayUs();
str2sig = Authenticator::GetString2Signature(date,
authOptions.rootOwner);
sig = Authenticator::CalcString2Signature(str2sig,
sig = Authenticator::CalcString2Signature(str2sig,
authOptions.rootPassword);
listRequest.set_signature(sig);
listRequest.set_filename(RECYCLEBINDIR);
listRequest.set_owner(authOptions.rootOwner);
listRequest.set_date(date);
stub.ListDir(&cntl, &listRequest, &listResponse, NULL);
if (!cntl.Failed()) {
ASSERT_EQ(listResponse.statuscode(), StatusCode::kOK);
ASSERT_EQ(listResponse.fileinfo_size(), 0);
listRequest.set_signature(sig);
listRequest.set_filename(RECYCLEBINDIR);
listRequest.set_owner(authOptions.rootOwner);
listRequest.set_date(date);
stub.ListDir(&cntl, &listRequest, &listResponse, NULL);
if (!cntl.Failed() && listResponse.statuscode() == StatusCode::kOK) {
if (listResponse.fileinfo_size() == 0) {
break;
} else {
sleep(1);
++attempts;
}
} else {
ASSERT_TRUE(false);
ASSERT_TRUE(false);
}
}
ASSERT_LE(attempts, 100) << "max attempts for list /RecycleBin exhausted";

// 删除文件时,如果文件名不满足要求,会返回失败
cntl.Reset();
Expand Down

0 comments on commit 7a99248

Please sign in to comment.