Skip to content

Commit

Permalink
curvefs/client: rm create fs in init
Browse files Browse the repository at this point in the history
curvefs_tool has add create-fs
  • Loading branch information
Cyber-SiKu committed Dec 28, 2021
1 parent 81ef9ff commit f3a86f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 39 deletions.
12 changes: 3 additions & 9 deletions curvefs/src/client/fuse_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,9 @@ CURVEFS_ERROR FuseClient::FuseOpInit(void *userdata,
FSStatusCode ret = mdsClient_->GetFsInfo(fsName, &fsInfo);
if (ret != FSStatusCode::OK) {
if (FSStatusCode::NOT_FOUND == ret) {
LOG(INFO) << "The fsName not exist, try to CreateFs"
<< ", fsName = " << fsName;

CURVEFS_ERROR ret2 = CreateFs(userdata, &fsInfo);
if (ret2 != CURVEFS_ERROR::OK) {
LOG(ERROR) << "CreateFs failed, ret = " << ret2
<< ", fsName = " << fsName;
return ret2;
}
LOG(ERROR) << "The fsName not exist, try to CreateFs"
<< ", fsName = " << fsName;
return CURVEFS_ERROR::NOTEXIST;
} else {
LOG(ERROR) << "GetFsInfo failed, FSStatusCode = " << ret
<< ", FSStatusCode_Name = "
Expand Down
32 changes: 2 additions & 30 deletions curvefs/test/client/test_fuse_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,29 +188,12 @@ TEST_F(TestFuseVolumeClient, FuseOpInit_when_fs_not_exist) {
EXPECT_CALL(*mdsClient_, GetFsInfo(fsName, _))
.WillOnce(Return(FSStatusCode::NOT_FOUND));

EXPECT_CALL(*blockDeviceClient_, Stat(volName, user, _))
.WillOnce(Return(CURVEFS_ERROR::OK));

EXPECT_CALL(*mdsClient_, CreateFs(_, _, _))
.WillOnce(Return(FSStatusCode::OK));

FsInfo fsInfoExp;
fsInfoExp.set_fsid(100);
fsInfoExp.set_fsname(fsName);
EXPECT_CALL(*mdsClient_, MountFs(fsName, _, _))
.WillOnce(DoAll(SetArgPointee<2>(fsInfoExp), Return(FSStatusCode::OK)));

EXPECT_CALL(*blockDeviceClient_, Open(volName, user))
.WillOnce(Return(CURVEFS_ERROR::OK));

CURVEFS_ERROR ret = client_->FuseOpInit(&mOpts, nullptr);
ASSERT_EQ(CURVEFS_ERROR::OK, ret);

auto fsInfo = client_->GetFsInfo();
ASSERT_NE(fsInfo, nullptr);

ASSERT_EQ(fsInfo->fsid(), fsInfoExp.fsid());
ASSERT_EQ(fsInfo->fsname(), fsInfoExp.fsname());
ASSERT_EQ(CURVEFS_ERROR::NOTEXIST, ret);
}

TEST_F(TestFuseVolumeClient, FuseOpDestroy) {
Expand Down Expand Up @@ -1718,23 +1701,12 @@ TEST_F(TestFuseS3Client, FuseOpInit_when_fs_not_exist) {
EXPECT_CALL(*mdsClient_, GetFsInfo(fsName, _))
.WillOnce(Return(FSStatusCode::NOT_FOUND));

EXPECT_CALL(*mdsClient_, CreateFsS3(_, _, _))
.WillOnce(Return(FSStatusCode::OK));

FsInfo fsInfoExp;
fsInfoExp.set_fsid(100);
fsInfoExp.set_fsname(fsName);
EXPECT_CALL(*mdsClient_, MountFs(fsName, _, _))
.WillOnce(DoAll(SetArgPointee<2>(fsInfoExp), Return(FSStatusCode::OK)));

CURVEFS_ERROR ret = client_->FuseOpInit(&mOpts, nullptr);
ASSERT_EQ(CURVEFS_ERROR::OK, ret);

auto fsInfo = client_->GetFsInfo();
ASSERT_NE(fsInfo, nullptr);

ASSERT_EQ(fsInfo->fsid(), fsInfoExp.fsid());
ASSERT_EQ(fsInfo->fsname(), fsInfoExp.fsname());
ASSERT_EQ(CURVEFS_ERROR::NOTEXIST, ret);
}

TEST_F(TestFuseS3Client, FuseOpDestroy) {
Expand Down

0 comments on commit f3a86f9

Please sign in to comment.