Пример #1
0
        public virtual void setUp()
        {
            recursiveDelete(testName() + " (SetUp)", trash, false, true);

            mockSystemReader = new MockSystemReader();
            mockSystemReader.userGitConfig = new FileBasedConfig(new FileInfo(Path.Combine(trash.FullName, "usergitconfig")));
            SystemReader.setInstance(mockSystemReader);

            long now = mockSystemReader.getCurrentTime();
            int  tz  = mockSystemReader.getTimezone(now);

            author = new PersonIdent("J. Author", "*****@*****.**");
            author = new PersonIdent(author, now, tz);

            committer = new PersonIdent("J. Committer", "*****@*****.**");
            committer = new PersonIdent(committer, now, tz);

            WindowCacheConfig c = new WindowCacheConfig();

            c.PackedGitLimit      = (128 * WindowCacheConfig.Kb);
            c.PackedGitWindowSize = (8 * WindowCacheConfig.Kb);
            c.PackedGitMMAP       = (useMMAP);
            c.DeltaBaseCacheLimit = (8 * WindowCacheConfig.Kb);
            WindowCache.reconfigure(c);
        }
Пример #2
0
        public override void tearDown()
        {
            base.tearDown();
            var windowCacheConfig = new WindowCacheConfig();

            WindowCache.reconfigure(windowCacheConfig);
        }
Пример #3
0
        private static void WhackCache()
        {
            var config = new WindowCacheConfig {
                PackedGitOpenFiles = 1
            };

            WindowCache.reconfigure(config);
        }
Пример #4
0
        public void testConfigureCache_PackedGitLimit_0()
        {
            var cfg = new WindowCacheConfig {
                PackedGitLimit = 0
            };

            AssertHelper.Throws <ArgumentException>(() => WindowCache.reconfigure(cfg));
        }
Пример #5
0
        public override void setUp()
        {
            var windowCacheConfig = new WindowCacheConfig {
                PackedGitOpenFiles = 1
            };

            WindowCache.reconfigure(windowCacheConfig);
            base.setUp();
        }
Пример #6
0
        private static void CheckLimits(WindowCacheConfig cfg)
        {
            WindowCache cache = WindowCache.Instance;

            Assert.IsTrue(cache.getOpenFiles() <= cfg.PackedGitOpenFiles);
            Assert.IsTrue(cache.getOpenBytes() <= cfg.PackedGitLimit);
            Assert.IsTrue(0 < cache.getOpenFiles());
            Assert.IsTrue(0 < cache.getOpenBytes());
        }
 public void testConfigureCache_Limits1()
 {
     // This test is just to force coverage over some lower bounds for
     // the table. We don't want the table to wind up with too small
     // of a size. This is highly dependent upon the table allocation
     // algorithm actually implemented in WindowCache.
     //
     var cfg = new WindowCacheConfig { PackedGitLimit = 6 * 4096 / 5, PackedGitWindowSize = 4096 };
     WindowCache.reconfigure(cfg);
 }
Пример #8
0
        public void testCache_TooSmallLimit()
        {
            var cfg = new WindowCacheConfig {
                PackedGitWindowSize = 4096, PackedGitLimit = 4096
            };

            WindowCache.reconfigure(cfg);
            DoCacheTests();
            CheckLimits(cfg);
        }
Пример #9
0
        public void testCache_TooFewFiles()
        {
            var cfg = new WindowCacheConfig {
                PackedGitOpenFiles = 2
            };

            WindowCache.reconfigure(cfg);
            DoCacheTests();
            CheckLimits(cfg);
        }
	public void testConfigureCache_PackedGitLimit_0() {
		try {
			final WindowCacheConfig cfg = new WindowCacheConfig();
			cfg.setPackedGitLimit(0);
			WindowCache.reconfigure(cfg);
			fail("incorrectly permitted PackedGitLimit = 0");
		} catch (IllegalArgumentException e) {
			//
		}
	}
	public void testConfigureCache_PackedGitWindowSize_4097() {
		try {
			final WindowCacheConfig cfg = new WindowCacheConfig();
			cfg.setPackedGitWindowSize(4097);
			WindowCache.reconfigure(cfg);
			fail("incorrectly permitted PackedGitWindowSize = 4097");
		} catch (IllegalArgumentException e) {
			assertEquals("Window size must be power of 2", e.getMessage());
		}
	}
	public void testConfigureCache_PackedGitWindowSize_512() {
		try {
			final WindowCacheConfig cfg = new WindowCacheConfig();
			cfg.setPackedGitWindowSize(512);
			WindowCache.reconfigure(cfg);
			fail("incorrectly permitted PackedGitWindowSize = 512");
		} catch (IllegalArgumentException e) {
			assertEquals("Invalid window size", e.getMessage());
		}
	}
Пример #13
0
        public void testConfigureCache_Limits1()
        {
            // This test is just to force coverage over some lower bounds for
            // the table. We don't want the table to wind up with too small
            // of a size. This is highly dependent upon the table allocation
            // algorithm actually implemented in WindowCache.
            //
            var cfg = new WindowCacheConfig {
                PackedGitLimit = 6 * 4096 / 5, PackedGitWindowSize = 4096
            };

            WindowCache.reconfigure(cfg);
        }
Пример #14
0
        public void testCache_Defaults()
        {
            var cfg = new WindowCacheConfig();

            WindowCache.reconfigure(cfg);
            DoCacheTests();
            CheckLimits(cfg);

            WindowCache cache = WindowCache.Instance;

            Assert.AreEqual(6, cache.getOpenFiles());
            Assert.AreEqual(17346, cache.getOpenBytes());
        }
 public void testConfigureCache_PackedGitOpenFiles_0()
 {
     try
     {
         var cfg = new WindowCacheConfig { PackedGitOpenFiles = 0 };
         WindowCache.reconfigure(cfg);
         Assert.Fail("incorrectly permitted PackedGitOpenFiles = 0");
     }
     catch (ArgumentException e)
     {
         Assert.AreEqual("Open files must be >= 1", e.Message);
     }
 }
Пример #16
0
 public void testConfigureCache_PackedGitWindowSize_4097()
 {
     try
     {
         var cfg = new WindowCacheConfig {
             PackedGitWindowSize = 4097
         };
         WindowCache.reconfigure(cfg);
         Assert.Fail("incorrectly permitted PackedGitWindowSize = 4097");
     }
     catch (ArgumentException e)
     {
         Assert.AreEqual("Window size must be power of 2", e.Message);
     }
 }
Пример #17
0
 public void testConfigureCache_PackedGitOpenFiles_0()
 {
     try
     {
         var cfg = new WindowCacheConfig {
             PackedGitOpenFiles = 0
         };
         WindowCache.reconfigure(cfg);
         Assert.Fail("incorrectly permitted PackedGitOpenFiles = 0");
     }
     catch (ArgumentException e)
     {
         Assert.AreEqual("Open files must be >= 1", e.Message);
     }
 }
Пример #18
0
 public void testConfigureCache_PackedGitWindowSize_512()
 {
     try
     {
         var cfg = new WindowCacheConfig {
             PackedGitWindowSize = 512
         };
         WindowCache.reconfigure(cfg);
         Assert.Fail("incorrectly permitted PackedGitWindowSize = 512");
     }
     catch (ArgumentException e)
     {
         Assert.AreEqual("Invalid window size", e.Message);
     }
 }
Пример #19
0
 public void testConfigureCache_PackedGitWindowSizeAbovePackedGitLimit()
 {
     try
     {
         var cfg = new WindowCacheConfig {
             PackedGitLimit = 1024, PackedGitWindowSize = 8192
         };
         WindowCache.reconfigure(cfg);
         Assert.Fail("incorrectly permitted PackedGitWindowSize > PackedGitLimit");
     }
     catch (ArgumentException e)
     {
         Assert.AreEqual("Window size must be < limit", e.Message);
     }
 }
Пример #20
0
        public void test029_mapObject_using_memory_mapped_file()
        {
            WindowCacheConfig c = new WindowCacheConfig();

            c.PackedGitLimit      = (128 * WindowCacheConfig.Kb);
            c.PackedGitWindowSize = (8 * WindowCacheConfig.Kb);
            c.PackedGitMMAP       = (true);
            c.DeltaBaseCacheLimit = (8 * WindowCacheConfig.Kb);
            WindowCache.reconfigure(c);

            var repo = createWorkRepository();

            Assert.AreEqual((new byte[0].GetType()), repo.MapObject(ObjectId.FromString("5b6e7c66c276e7610d4a73c70ec1a1f7c1003259"), null).GetType());
            Assert.AreEqual(typeof(global::GitSharp.Core.Commit), repo.MapObject(ObjectId.FromString("540a36d136cf413e4b064c2b0e0a4db60f77feab"), null).GetType());
            Assert.AreEqual(typeof(global::GitSharp.Core.Tree), repo.MapObject(ObjectId.FromString("aabf2ffaec9b497f0950352b3e582d73035c2035"), null).GetType());
            Assert.AreEqual(typeof(global::GitSharp.Core.Tag), repo.MapObject(ObjectId.FromString("17768080a2318cd89bba4c8b87834401e2095703"), null).GetType());
        }
        public virtual void SetUp()
        {
            lock (this)
            {
                if (shutdownHook == null)
                {
                    shutdownHook = new _Thread_117(this);
                    // On windows accidentally open files or memory
                    // mapped regions may prevent files from being deleted.
                    // Suggesting a GC increases the likelihood that our
                    // test repositories actually get removed after the
                    // tests, even in the case of failure.
                    Runtime.GetRuntime().AddShutdownHook(shutdownHook);
                }
            }
            RecursiveDelete(TestId(), trash, true, false);
            mockSystemReader = new MockSystemReader();
            mockSystemReader.userGitConfig = new FileBasedConfig(new FilePath(trash, "usergitconfig"
                                                                              ), FS.DETECTED);
            CeilTestDirectories(GetCeilings());
            SystemReader.SetInstance(mockSystemReader);
            long now = mockSystemReader.GetCurrentTime();
            int  tz  = mockSystemReader.GetTimezone(now);

            author    = new PersonIdent("J. Author", "*****@*****.**");
            author    = new PersonIdent(author, now, tz);
            committer = new PersonIdent("J. Committer", "*****@*****.**");
            committer = new PersonIdent(committer, now, tz);
            WindowCacheConfig c = new WindowCacheConfig();

            c.SetPackedGitLimit(128 * WindowCacheConfig.KB);
            c.SetPackedGitWindowSize(8 * WindowCacheConfig.KB);
            c.SetPackedGitMMAP(useMMAP);
            c.SetDeltaBaseCacheLimit(8 * WindowCacheConfig.KB);
            WindowCache.Reconfigure(c);
        }
 public void testConfigureCache_PackedGitWindowSizeAbovePackedGitLimit()
 {
     try
     {
         var cfg = new WindowCacheConfig { PackedGitLimit = 1024, PackedGitWindowSize = 8192 };
         WindowCache.reconfigure(cfg);
         Assert.Fail("incorrectly permitted PackedGitWindowSize > PackedGitLimit");
     }
     catch (ArgumentException e)
     {
         Assert.AreEqual("Window size must be < limit", e.Message);
     }
 }
Пример #23
0
        public void testCache_Defaults()
        {
            var cfg = new WindowCacheConfig();
            WindowCache.reconfigure(cfg);
            DoCacheTests();
            CheckLimits(cfg);

            WindowCache cache = WindowCache.Instance;
            Assert.AreEqual(6, cache.getOpenFiles());
            Assert.AreEqual(17346, cache.getOpenBytes());
        }
Пример #24
0
 public void testCache_TooFewFiles()
 {
     var cfg = new WindowCacheConfig { PackedGitOpenFiles = 2 };
     WindowCache.reconfigure(cfg);
     DoCacheTests();
     CheckLimits(cfg);
 }
 public void testConfigureCache_PackedGitWindowSize_512()
 {
     try
     {
         var cfg = new WindowCacheConfig { PackedGitWindowSize = 512 };
         WindowCache.reconfigure(cfg);
         Assert.Fail("incorrectly permitted PackedGitWindowSize = 512");
     }
     catch (ArgumentException e)
     {
         Assert.AreEqual("Invalid window size", e.Message);
     }
 }
Пример #26
0
 public override void setUp()
 {
     var windowCacheConfig = new WindowCacheConfig { PackedGitOpenFiles = 1 };
     WindowCache.reconfigure(windowCacheConfig);
     base.setUp();
 }
Пример #27
0
 public void testCache_TooSmallLimit()
 {
     var cfg = new WindowCacheConfig { PackedGitWindowSize = 4096, PackedGitLimit = 4096 };
     WindowCache.reconfigure(cfg);
     DoCacheTests();
     CheckLimits(cfg);
 }
Пример #28
0
 public override void tearDown()
 {
     base.tearDown();
     var windowCacheConfig = new WindowCacheConfig();
     WindowCache.reconfigure(windowCacheConfig);
 }
	public void testConfigureCache_PackedGitWindowSizeAbovePackedGitLimit() {
		try {
			final WindowCacheConfig cfg = new WindowCacheConfig();
			cfg.setPackedGitLimit(1024);
			cfg.setPackedGitWindowSize(8192);
			WindowCache.reconfigure(cfg);
			fail("incorrectly permitted PackedGitWindowSize > PackedGitLimit");
		} catch (IllegalArgumentException e) {
			assertEquals("Window size must be < limit", e.getMessage());
		}
	}
 public void testConfigureCache_PackedGitLimit_0()
 {
     var cfg = new WindowCacheConfig { PackedGitLimit = 0 };
     AssertHelper.Throws<ArgumentException>(() => WindowCache.reconfigure(cfg));
 }
 public void testConfigureCache_PackedGitWindowSize_4097()
 {
     try
     {
         var cfg = new WindowCacheConfig { PackedGitWindowSize = 4097 };
         WindowCache.reconfigure(cfg);
         Assert.Fail("incorrectly permitted PackedGitWindowSize = 4097");
     }
     catch (ArgumentException e)
     {
         Assert.AreEqual("Window size must be power of 2", e.Message);
     }
 }
Пример #32
0
 private static void CheckLimits(WindowCacheConfig cfg)
 {
     WindowCache cache = WindowCache.Instance;
     Assert.IsTrue(cache.getOpenFiles() <= cfg.PackedGitOpenFiles);
     Assert.IsTrue(cache.getOpenBytes() <= cfg.PackedGitLimit);
     Assert.IsTrue(0 < cache.getOpenFiles());
     Assert.IsTrue(0 < cache.getOpenBytes());
 }
	public void testConfigureCache_PackedGitOpenFiles_0() {
		try {
			final WindowCacheConfig cfg = new WindowCacheConfig();
			cfg.setPackedGitOpenFiles(0);
			WindowCache.reconfigure(cfg);
			fail("incorrectly permitted PackedGitOpenFiles = 0");
		} catch (IllegalArgumentException e) {
			assertEquals("Open files must be >= 1", e.getMessage());
		}
	}
Пример #34
0
 private static void WhackCache()
 {
     var config = new WindowCacheConfig { PackedGitOpenFiles = 1 };
     WindowCache.reconfigure(config);
 }