Skip to content

Commit

Permalink
chore(test): add test for cri_settings
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <[email protected]>
  • Loading branch information
therealbobo authored and poiana committed Jan 16, 2024
1 parent 93a8bd8 commit 4ef81e1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions userspace/libsinsp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ set(LIBSINSP_UNIT_TESTS_SOURCES
thread_table.ut.cpp
public_sinsp_API/event_related.cpp
public_sinsp_API/sinsp_logger.cpp
cri_settings.ut.cpp
"${TEST_PLUGINS}"
"${SINSP_PARSERS_SUITE}"
"${SINSP_CLASSES_SUITE}"
Expand Down
43 changes: 43 additions & 0 deletions userspace/libsinsp/test/cri_settings.ut.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2024 The Falco Authors.
Licensed 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.
*/

#include <gtest/gtest.h>
#include <cri.h>
#include <cri.hpp>
#include "./sinsp_with_test_input.h"


TEST_F(sinsp_with_test_input, default_cri_socket_paths)
{
libsinsp::cri::settings* cri_settings = libsinsp::cri::settings::instance();

if (!cri_settings->get_cri_unix_socket_paths().empty())
{
cri_settings->clear_cri_unix_socket_paths();
}

add_default_init_thread();
open_inspector();

auto socket_paths = cri_settings->get_cri_unix_socket_paths();

ASSERT_EQ(socket_paths.size(), 3);
ASSERT_TRUE("/run/containerd/containerd.sock"==socket_paths[0]);
ASSERT_TRUE("/run/crio/crio.sock"==socket_paths[1]);
ASSERT_TRUE("/run/k3s/containerd/containerd.sock"==socket_paths[2]);
}

0 comments on commit 4ef81e1

Please sign in to comment.