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 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);
        }
        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);
        }
Exemple #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);
        }
Exemple #5
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);
        }