Ejemplo n.º 1
0
            public void Enforced()
            {
                Container1 = CreateContainer(Container1Handle);
                Container1.LimitDisk(10 * 1024);

                var pSpec = new ProcessSpec
                {
                    ExecutablePath     = "cmd",
                    DisablePathMapping = true,
                    Privileged         = false,
                    WorkingDirectory   = Container1.Directory.UserPath,
                };
                var io1 = new StringProcessIO();

                var passed = 0;
                var failed = 0;

                for (int i = 0; i < 20; i++)
                {
                    pSpec.Arguments = new[] { "/C", "echo Hi Bob > bob" + i + ".txt" };
                    var proc     = Container1.Run(pSpec, io1);
                    var exitCode = proc.WaitForExit();

                    if (exitCode == 0)
                    {
                        passed++;
                    }
                    else
                    {
                        failed++;
                    }
                }
                Assert.Equal(13, passed);
                Assert.Equal(7, failed);
            }
Ejemplo n.º 2
0
            public void CanSetLargeQuota()
            {
                const ulong limit = 7UL * 1024 * 1024 * 1024;

                Container1 = CreateContainer(Container1Handle);
                Container1.LimitDisk(limit);
                Assert.Equal(limit, Container1.CurrentDiskLimit());
            }
Ejemplo n.º 3
0
            public void DeletingContainer_DeletesDiskQuota()
            {
                Container1 = CreateContainer(Container1Handle);
                Container1.LimitDisk(5000);

                Assert.Equal(5000UL, Container1.CurrentDiskLimit());

                ContainerService.DestroyContainer(Container1Handle);

                Assert.Equal(0UL, Container1.CurrentDiskLimit());
            }
Ejemplo n.º 4
0
            public void Enforced()
            {
                if (Environment.GetEnvironmentVariable("APPVEYOR") != null)
                {
                    return;
                }

                const ulong diskLimit = (ulong)7e+6;

                Container1 = CreateContainer(Container1Handle);
                Container1.LimitDisk(diskLimit);

                Container1.ImpersonateContainerUser(() => File.WriteAllBytes(Container1.Directory.MapUserPath("file.txt"), new byte[diskLimit]));
                Assert.Throws <IOException>(() => Container1.ImpersonateContainerUser(() => File.WriteAllBytes(Container1.Directory.MapUserPath("file.txt"), new byte[diskLimit + 1024])));
            }