Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validate_container_rows helper for integration tests #6485

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 1 addition & 5 deletions tests/integration/tables/deb_packages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ TEST_F(DebPackages, test_sanity) {
ASSERT_EQ(all_packages.count("dpkg"), 1u);

if (isPlatform(PlatformType::TYPE_LINUX)) {
rows = execute_query(
"select *, pid_with_namespace, mount_namespace_id from deb_packages");
row_map["pid_with_namespace"] = IntType;
row_map["mount_namespace_id"] = NormalType;
validate_rows(rows, row_map);
validate_container_rows("deb_packages", row_map);
}

} else {
Expand Down
9 changes: 9 additions & 0 deletions tests/integration/tables/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,15 @@ bool validate_value_using_flags(const std::string& value, int flags) {
return true;
}

void validate_container_rows(const std::string& table_name,
ValidationMap& validation_map) {
auto rows = execute_query(
"select *, pid_with_namespace, mount_namespace_id from " + table_name);
validation_map["pid_with_namespace"] = IntType;
validation_map["mount_namespace_id"] = NormalType;
validate_rows(rows, validation_map);
}

void setUpEnvironment() {
Initializer::platformSetup();
registryAndPluginInit();
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/tables/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ void validate_row(const Row& row, const ValidationMap& validation_map);
void validate_rows(const std::vector<Row>& rows,
const ValidationMap& validation_map);
bool validate_value_using_flags(const std::string& value, int flags);
void validate_container_rows(const std::string& table_name,
ValidationMap& validation_map);
bool is_valid_hex(const std::string& value);

void setUpEnvironment();
Expand Down
6 changes: 1 addition & 5 deletions tests/integration/tables/npm_packages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ TEST_F(NpmPackagesTest, test_sanity) {
validate_rows(data, row_map);

if (isPlatform(PlatformType::TYPE_LINUX)) {
data = execute_query(
"select *, pid_with_namespace, mount_namespace_id from npm_packages");
row_map["pid_with_namespace"] = IntType;
row_map["mount_namespace_id"] = NormalType;
validate_rows(data, row_map);
validate_container_rows("npm_packages", row_map);
}
}

Expand Down
8 changes: 1 addition & 7 deletions tests/integration/tables/os_version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,7 @@ TEST_F(OsVersion, test_sanity) {

// Query again with hidden columns too
if (isPlatform(PlatformType::TYPE_LINUX)) {
data = execute_query(
"select *, pid_with_namespace, mount_namespace_id from os_version");

row_map["pid_with_namespace"] = IntType;
row_map["mount_namespace_id"] = NormalType;

validate_rows(data, row_map);
validate_container_rows("os_version", row_map);
}
}

Expand Down
6 changes: 1 addition & 5 deletions tests/integration/tables/rpm_packages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ TEST_F(rpmPackages, test_sanity) {
validate_rows(rows, row_map);

if (isPlatform(PlatformType::TYPE_LINUX)) {
rows = execute_query(
"select *, pid_with_namespace, mount_namespace_id from rpm_packages");
row_map["pid_with_namespace"] = IntType;
row_map["mount_namespace_id"] = NormalType;
validate_rows(rows, row_map);
validate_container_rows("rpm_packages", row_map);
}
} else {
LOG(WARNING) << "Empty results of query from 'rpm_packages', assume there "
Expand Down