forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcgroup_cpu_simple_integration_test.cc
More file actions
44 lines (31 loc) · 1.35 KB
/
cgroup_cpu_simple_integration_test.cc
File metadata and controls
44 lines (31 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifdef __linux__
#include "source/server/cgroup_cpu_util.h"
#endif
#include "source/common/filesystem/filesystem_impl.h"
#include "gtest/gtest.h"
namespace Envoy {
namespace Server {
namespace {
#ifdef __linux__
// This test runs in CI with Docker CPU limits (--cpus=2) to verify 'cgroups' detection.
// Tagged 'manual' to run only in controlled environments with CPU limits.
// Tests basic cgroup detection without heavy server integration dependencies.
class CgroupCpuSimpleIntegrationTest : public testing::Test {};
// Test basic cgroup CPU detection functionality
// In CI environment with Docker CPU limits (--cpus=2), we expect to detect 'cgroups' limits
TEST_F(CgroupCpuSimpleIntegrationTest, CgroupDetectionBasicFunctionality) {
CgroupDetectorImpl detector;
Filesystem::InstanceImpl fs;
auto cpu_limit = detector.getCpuLimit(fs);
// In CI environment with Docker CPU limits, we MUST detect 'cgroups'
ASSERT_TRUE(cpu_limit.has_value())
<< "Cgroups not detected in CI environment - Docker CPU limits not working";
// Should be exactly 2 for our Docker --cpus=2 configuration
uint32_t limit = cpu_limit.value();
EXPECT_EQ(2U, limit) << "Expected 2 CPUs from Docker --cpus=2 setting, got: " << limit;
ENVOY_LOG_MISC(info, "Cgroup CPU limit detected: {}", limit);
}
#endif // __linux__
} // namespace
} // namespace Server
} // namespace Envoy