Ejemplo n.º 1
0
        public void TestSparkJobInfo()
        {
            const int jobId = 65536;
            int[] stageIds = new[] { 100, 102, 104 };
            const string status = "RUNNING";

            // arrange
            Mock<IStatusTrackerProxy> statusTrackerProxy = new Mock<IStatusTrackerProxy>();
            var expectedJobInfo = new SparkJobInfo(jobId, stageIds, status);
            statusTrackerProxy.Setup(m => m.GetJobInfo(It.IsAny<int>())).Returns(expectedJobInfo);
            var tracker = new StatusTracker(statusTrackerProxy.Object);

            // act
            SparkJobInfo jobInfo = tracker.GetJobInfo(jobId);

            // assert
            Assert.IsNotNull(jobInfo);
            Assert.AreEqual(jobId, jobInfo.JobId);
            Assert.AreEqual(stageIds, jobInfo.StageIds);
            Assert.AreEqual(status, jobInfo.Status);
        }
Ejemplo n.º 2
0
        public void TestStatusTrackerMethods()
        {
            // arrange
            Mock<IStatusTrackerProxy> statusTrackerProxy = new Mock<IStatusTrackerProxy>();

            // GetJobIdsForGroup
            const string jobGroup = "group-0";
            int[] expectedJobIds = new[] { 1001, 1002, 1003 };
            statusTrackerProxy.Setup(m => m.GetJobIdsForGroup(It.IsAny<string>())).Returns(expectedJobIds);

            // GetActiveJobsIds
            int[] expectedActiveJobIds = new[] { 1001, 1003 };
            statusTrackerProxy.Setup(m => m.GetActiveJobsIds()).Returns(expectedActiveJobIds);

            // GetActiveStageIds
            int[] expectedActiveStageIds = new[] { 666, 667, 668 };
            statusTrackerProxy.Setup(m => m.GetActiveStageIds()).Returns(expectedActiveStageIds);

            var tracker = new StatusTracker(statusTrackerProxy.Object);

            // act
            var jobIds = tracker.GetJobIdsForGroup(jobGroup);
            var activeJobIds = tracker.GetActiveJobsIds();
            var activeStageIds = tracker.GetActiveStageIds();

            // assert
            // GetJobIdsForGroup
            Assert.IsNotNull(jobIds);
            Assert.AreEqual(expectedJobIds, jobIds);

            // GetActiveJobsIds
            Assert.IsNotNull(activeJobIds);
            Assert.AreEqual(expectedActiveJobIds, activeJobIds);

            // GetActiveStageIds
            Assert.IsNotNull(activeStageIds);
            Assert.AreEqual(expectedActiveStageIds, activeStageIds);
        }
Ejemplo n.º 3
0
        public void TestSparkStageInfo()
        {
            const int stageId = 65536;
            const int currentAttemptId = 1;
            long submissionTime = DateTime.Now.Millisecond;
            const string name = "name-1";
            const int numTasks = 20;
            const int numActiveTasks = 10;
            const int numCompletedTasks = 5;
            const int numFailedTasks = 0;

            // arrange
            Mock<IStatusTrackerProxy> statusTrackerProxy = new Mock<IStatusTrackerProxy>();
            var expectedStageInfo = new SparkStageInfo(stageId, currentAttemptId, submissionTime, name, numTasks, numActiveTasks, numCompletedTasks, numFailedTasks);
            statusTrackerProxy.Setup(m => m.GetStageInfo(It.IsAny<int>())).Returns(expectedStageInfo);
            var tracker = new StatusTracker(statusTrackerProxy.Object);

            // act
            SparkStageInfo stageInfo = tracker.GetStageInfo(stageId);

            // assert
            Assert.IsNotNull(stageInfo);
            Assert.AreEqual(stageId, stageInfo.StageId);
            Assert.AreEqual(currentAttemptId, stageInfo.CurrentAttemptId);
            Assert.AreEqual(submissionTime, stageInfo.SubmissionTime);
            Assert.AreEqual(name, stageInfo.Name);
            Assert.AreEqual(numTasks, stageInfo.NumTasks);
            Assert.AreEqual(numActiveTasks, stageInfo.NumActiveTasks);
            Assert.AreEqual(numCompletedTasks, stageInfo.NumCompletedTasks);
            Assert.AreEqual(numFailedTasks, stageInfo.NumFailedTasks);
        }