Пример #1
0
        public void TestCGroupContentWithInvalidData()
        {
            if (!File.Exists("/proc/self/cgroup"))
            {
                return;                                                //only run in Docker - this check can be improved
            }
            var noopLogger       = new NoopLogger();
            var systemInfoHelper = new TestSystemInfoHelper(noopLogger, "asdf:invalid-dockerid:243543");

            var systemInfo = systemInfoHelper.ParseSystemInfo();

            systemInfo.Container.Should().BeNull();
        }
Пример #2
0
        public void TestCGroupContent(string cGroupContent, string expectedContainerId)
        {
            if (!File.Exists("/proc/self/cgroup"))
            {
                return;                                                //only run in Docker - this check can be improved
            }
            var noopLogger       = new NoopLogger();
            var systemInfoHelper = new TestSystemInfoHelper(noopLogger, cGroupContent);

            var systemInfo = systemInfoHelper.ParseSystemInfo();

            systemInfo.Should().NotBeNull();
            systemInfo.Container.Should().NotBeNull();
            systemInfo.Container.Id.Should().Be(expectedContainerId);
        }
Пример #3
0
        public void TestCGroupContentWithInvalidData()
        {
            if (!File.Exists("/proc/self/cgroup"))
            {
                return;                                                //only run in Docker - this check can be improved
            }
            var noopLogger       = new NoopLogger();
            var systemInfoHelper = new TestSystemInfoHelper(noopLogger, "asdf:invalid-dockerid:243543");

            var systemInfo = systemInfoHelper.ReadContainerId(noopLogger);

            //The current implementation returns null instead of an empty System instance.
            //This may changes later, the point of the test is to make sure there is no container id
            systemInfo.Should().BeNull();
        }