mirror of
https://github.com/akuker/RASCSI.git
synced 2026-04-26 06:18:10 +00:00
Add statistics and make scsictl accept generic key/value parameters (#1237/#1238) (#1262)
* Add statistics and make scsictl accept generic key/value parameters
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "mocks.h"
|
||||
#include "shared/piscsi_version.h"
|
||||
#include "shared/protobuf_util.h"
|
||||
#include "controllers/controller_manager.h"
|
||||
#include "devices/device_factory.h"
|
||||
#include "generated/piscsi_interface.pb.h"
|
||||
@@ -16,6 +17,7 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
using namespace piscsi_interface;
|
||||
using namespace protobuf_util;
|
||||
|
||||
TEST(PiscsiResponseTest, Operation_Count)
|
||||
{
|
||||
@@ -178,15 +180,41 @@ TEST(PiscsiResponseTest, GetServerInfo)
|
||||
const unordered_set<shared_ptr<PrimaryDevice>> devices;
|
||||
const unordered_set<int> ids = { 1, 3 };
|
||||
|
||||
PbServerInfo info;
|
||||
response.GetServerInfo(info, devices, ids, "default_folder", "", "", 1234);
|
||||
EXPECT_EQ(piscsi_major_version, info.version_info().major_version());
|
||||
EXPECT_EQ(piscsi_minor_version, info.version_info().minor_version());
|
||||
EXPECT_EQ(piscsi_patch_version, info.version_info().patch_version());
|
||||
EXPECT_EQ(level::level_string_views[get_level()], info.log_level_info().current_log_level());
|
||||
EXPECT_EQ("default_folder", info.image_files_info().default_image_folder());
|
||||
EXPECT_EQ(1234, info.image_files_info().depth());
|
||||
EXPECT_EQ(2, info.reserved_ids_info().ids().size());
|
||||
PbCommand command;
|
||||
PbServerInfo info1;
|
||||
response.GetServerInfo(info1, command, devices, ids, "default_folder", 1234);
|
||||
EXPECT_TRUE(info1.has_version_info());
|
||||
EXPECT_TRUE(info1.has_log_level_info());
|
||||
EXPECT_TRUE(info1.has_device_types_info());
|
||||
EXPECT_TRUE(info1.has_image_files_info());
|
||||
EXPECT_TRUE(info1.has_network_interfaces_info());
|
||||
EXPECT_TRUE(info1.has_mapping_info());
|
||||
EXPECT_TRUE(info1.has_statistics_info());
|
||||
EXPECT_FALSE(info1.has_devices_info());
|
||||
EXPECT_TRUE(info1.has_reserved_ids_info());
|
||||
EXPECT_TRUE(info1.has_operation_info());
|
||||
|
||||
EXPECT_EQ(piscsi_major_version, info1.version_info().major_version());
|
||||
EXPECT_EQ(piscsi_minor_version, info1.version_info().minor_version());
|
||||
EXPECT_EQ(piscsi_patch_version, info1.version_info().patch_version());
|
||||
EXPECT_EQ(level::level_string_views[get_level()], info1.log_level_info().current_log_level());
|
||||
EXPECT_EQ("default_folder", info1.image_files_info().default_image_folder());
|
||||
EXPECT_EQ(1234, info1.image_files_info().depth());
|
||||
EXPECT_EQ(2, info1.reserved_ids_info().ids().size());
|
||||
|
||||
SetParam(command, "operations", "log_level_info,mapping_info");
|
||||
PbServerInfo info2;
|
||||
response.GetServerInfo(info2, command, devices, ids, "default_folder", 1234);
|
||||
EXPECT_FALSE(info2.has_version_info());
|
||||
EXPECT_TRUE(info2.has_log_level_info());
|
||||
EXPECT_FALSE(info2.has_device_types_info());
|
||||
EXPECT_FALSE(info2.has_image_files_info());
|
||||
EXPECT_FALSE(info2.has_network_interfaces_info());
|
||||
EXPECT_TRUE(info2.has_mapping_info());
|
||||
EXPECT_FALSE(info2.has_statistics_info());
|
||||
EXPECT_FALSE(info2.has_devices_info());
|
||||
EXPECT_FALSE(info2.has_reserved_ids_info());
|
||||
EXPECT_FALSE(info2.has_operation_info());
|
||||
}
|
||||
|
||||
TEST(PiscsiResponseTest, GetVersionInfo)
|
||||
|
||||
@@ -53,27 +53,38 @@ TEST(ProtobufUtil, ParseParameters)
|
||||
TestSpecialDevice("services");
|
||||
}
|
||||
|
||||
TEST(ProtobufUtil, SetPatternParams)
|
||||
TEST(ProtobufUtil, SetCommandParams)
|
||||
{
|
||||
PbCommand command1;
|
||||
SetPatternParams(command1, "file");
|
||||
SetCommandParams(command1, "file");
|
||||
EXPECT_EQ("", GetParam(command1, "folder_pattern"));
|
||||
EXPECT_EQ("file", GetParam(command1, "file_pattern"));
|
||||
|
||||
PbCommand command2;
|
||||
SetPatternParams(command2, ":file");
|
||||
SetCommandParams(command2, ":file");
|
||||
EXPECT_EQ("", GetParam(command2, "folder_pattern"));
|
||||
EXPECT_EQ("file", GetParam(command2, "file_pattern"));
|
||||
|
||||
PbCommand command3;
|
||||
SetPatternParams(command3, "folder:");
|
||||
EXPECT_EQ("folder", GetParam(command3, "folder_pattern"));
|
||||
EXPECT_EQ("", GetParam(command3, "file_pattern"));
|
||||
SetCommandParams(command3, "file:");
|
||||
EXPECT_EQ("file", GetParam(command3, "file_pattern"));
|
||||
EXPECT_EQ("", GetParam(command3, "folder_pattern"));
|
||||
|
||||
PbCommand command4;
|
||||
SetPatternParams(command4, "folder:file");
|
||||
SetCommandParams(command4, "folder:file");
|
||||
EXPECT_EQ("folder", GetParam(command4, "folder_pattern"));
|
||||
EXPECT_EQ("file", GetParam(command4, "file_pattern"));
|
||||
|
||||
PbCommand command5;
|
||||
SetCommandParams(command5, "folder:file:");
|
||||
EXPECT_EQ("folder", GetParam(command5, "folder_pattern"));
|
||||
EXPECT_EQ("file", GetParam(command5, "file_pattern"));
|
||||
|
||||
PbCommand command6;
|
||||
SetCommandParams(command6, "folder:file:operations");
|
||||
EXPECT_EQ("folder", GetParam(command6, "folder_pattern"));
|
||||
EXPECT_EQ("file", GetParam(command6, "file_pattern"));
|
||||
EXPECT_EQ("operations", GetParam(command6, "operations"));
|
||||
}
|
||||
|
||||
TEST(ProtobufUtil, ListDevices)
|
||||
|
||||
Reference in New Issue
Block a user