public void PackfileMaintenanceFailGitProcessIds()
        {
            this.TestSetup(DateTime.UtcNow.AddDays(-1));

            Mock <GitProcessChecker> mockChecker = new Mock <GitProcessChecker>();

            mockChecker.Setup(checker => checker.GetRunningGitProcessIds())
            .Returns(new int[] { 1 });

            PackfileMaintenanceStep step = new PackfileMaintenanceStep(
                this.context,
                requireObjectCacheLock: false,
                forceRun: false,
                gitProcessChecker: mockChecker.Object);

            step.Execute();

            mockChecker.Verify(checker => checker.GetRunningGitProcessIds(), Times.Once());

            this.tracer.StartActivityTracer.RelatedErrorEvents.Count.ShouldEqual(0);
            this.tracer.StartActivityTracer.RelatedWarningEvents.Count.ShouldEqual(1);
            List <string> commands = this.gitProcess.CommandsRun;

            commands.Count.ShouldEqual(0);
        }
        public void PackfileMaintenanceRewriteOnBadVerify()
        {
            this.TestSetup(DateTime.UtcNow, failOnVerify: true);

            this.gitProcess.SetExpectedCommandResult(
                this.WriteCommand,
                () => new GitProcess.Result(string.Empty, string.Empty, GitProcess.Result.SuccessCode));

            PackfileMaintenanceStep step = new PackfileMaintenanceStep(this.context, requireObjectCacheLock: false, forceRun: true);

            step.Execute();

            this.tracer.StartActivityTracer.RelatedErrorEvents.Count.ShouldEqual(2);
            this.tracer.StartActivityTracer.RelatedWarningEvents.Count.ShouldEqual(0);

            List <string> commands = this.gitProcess.CommandsRun;

            commands.Count.ShouldEqual(6);
            commands[0].ShouldEqual(this.ExpireCommand);
            commands[1].ShouldEqual(this.VerifyCommand);
            commands[2].ShouldEqual(this.WriteCommand);
            commands[3].ShouldEqual(this.RepackCommand);
            commands[4].ShouldEqual(this.VerifyCommand);
            commands[5].ShouldEqual(this.WriteCommand);
        }
        public void PackfileMaintenancePassTimeRestriction()
        {
            this.TestSetup(DateTime.UtcNow.AddDays(-1));

            Mock <GitProcessChecker> mockChecker = new Mock <GitProcessChecker>();

            mockChecker.Setup(checker => checker.GetRunningGitProcessIds())
            .Returns(Array.Empty <int>());

            PackfileMaintenanceStep step = new PackfileMaintenanceStep(
                this.context,
                requireObjectCacheLock: false,
                forceRun: false,
                gitProcessChecker: mockChecker.Object);

            step.Execute();

            mockChecker.Verify(checker => checker.GetRunningGitProcessIds(), Times.Once());

            this.tracer.StartActivityTracer.RelatedErrorEvents.Count.ShouldEqual(0);
            this.tracer.StartActivityTracer.RelatedWarningEvents.Count.ShouldEqual(0);
            List <string> commands = this.gitProcess.CommandsRun;

            commands.Count.ShouldEqual(5);
            commands[0].ShouldEqual(this.WriteCommand);
            commands[1].ShouldEqual(this.ExpireCommand);
            commands[2].ShouldEqual(this.VerifyCommand);
            commands[3].ShouldEqual(this.RepackCommand);
            commands[4].ShouldEqual(this.VerifyCommand);
        }
Example #4
0
        public void PackfileMaintenanceFailTimeRestriction()
        {
            this.TestSetup(DateTime.UtcNow);

            PackfileMaintenanceStep step = new PackfileMaintenanceStep(this.context, requireObjectCacheLock: false, forceRun: false);

            step.Execute();

            this.tracer.StartActivityTracer.RelatedErrorEvents.Count.ShouldEqual(0);
            this.tracer.StartActivityTracer.RelatedWarningEvents.Count.ShouldEqual(1);
            List <string> commands = this.gitProcess.CommandsRun;

            commands.Count.ShouldEqual(0);
        }
Example #5
0
        public void CleanStaleIdxFiles()
        {
            this.TestSetup(DateTime.UtcNow);

            PackfileMaintenanceStep step = new PackfileMaintenanceStep(this.context, requireObjectCacheLock: false, forceRun: false);

            List <string> staleIdx = step.CleanStaleIdxFiles(out int numDeletionBlocked);

            staleIdx.Count.ShouldEqual(1);
            staleIdx[0].ShouldEqual(StaleIdxName);

            this.context
            .FileSystem
            .FileExists(Path.Combine(this.context.Enlistment.GitPackRoot, StaleIdxName))
            .ShouldBeFalse();
        }
Example #6
0
        public void CountPackFiles()
        {
            this.TestSetup(DateTime.UtcNow);

            PackfileMaintenanceStep step = new PackfileMaintenanceStep(this.context, requireObjectCacheLock: false, forceRun: false);

            step.GetPackFilesInfo(out int count, out long size, out bool hasKeep);
            count.ShouldEqual(3);
            size.ShouldEqual(11);
            hasKeep.ShouldEqual(true);

            this.context.FileSystem.DeleteFile(Path.Combine(this.context.Enlistment.GitPackRoot, KeepName));

            step.GetPackFilesInfo(out count, out size, out hasKeep);
            count.ShouldEqual(3);
            size.ShouldEqual(11);
            hasKeep.ShouldEqual(false);
        }
Example #7
0
        public void PackfileMaintenancePassTimeRestriction()
        {
            this.TestSetup(DateTime.UtcNow.AddDays(-1));

            PackfileMaintenanceStep step = new PackfileMaintenanceStep(this.context, requireObjectCacheLock: false, forceRun: false);

            step.Execute();

            this.tracer.StartActivityTracer.RelatedErrorEvents.Count.ShouldEqual(0);
            this.tracer.StartActivityTracer.RelatedWarningEvents.Count.ShouldEqual(0);
            List <string> commands = this.gitProcess.CommandsRun;

            commands.Count.ShouldEqual(4);
            commands[0].ShouldEqual(this.ExpireCommand);
            commands[1].ShouldEqual(this.VerifyCommand);
            commands[2].ShouldEqual(this.RepackCommand);
            commands[3].ShouldEqual(this.VerifyCommand);
        }