コード例 #1
0
        public void IsUpdateSampleStatusFinished_Should_Fail_If_Invalid_Json(Mock <IAppConfig> config,
                                                                             Mock <IJobProxy> jobProxy,
                                                                             Mock <ILogging> logging,
                                                                             Mock <IIAM> iam,
                                                                             Mock <ITaskLogging> taskLogging,
                                                                             Mock <IValidation> validation,
                                                                             Mock <IWorkStatusProxy> workStatusProxy,
                                                                             IOrchestrationJob orchestrationJob,
                                                                             Mock <IRouterClient> routerClient,
                                                                             string customerShortName,
                                                                             string projectShortName,
                                                                             Guid id)

        {
            var fixture = new Fixture();
            var runId   = orchestrationJob.flowchartRunRequest.First().flowchartRunUUID;

            config.SetupGet(x => x.IAMCustomerManagementUri).Returns(fixture.Create <Uri>().ToString());
            config.SetupGet(x => x.AnalyticsEngineUri).Returns(fixture.Create <Uri>().ToString());
            orchestrationJob.lastRouterRequests.Add($"UpdateSampleStatus_{runId.ToString()}", Guid.NewGuid().ToString());
            jobProxy.Setup(x => x.GetJob(customerShortName, projectShortName, id)).Returns(orchestrationJob);

            var setupRun = new SetupRunController(config.Object, jobProxy.Object, iam.Object, logging.Object, taskLogging.Object, validation.Object, workStatusProxy.Object);

            Assert.Throws <JsonReaderException>(() => setupRun.IsUpdateSampleStatusFinished(routerClient.Object, customerShortName, projectShortName, id, orchestrationJob.flowchartRunRequest.First().flowchartRunUUID));
        }
コード例 #2
0
ファイル: MetaData_Test.cs プロジェクト: Dhanas-git/dotnet
        public void TestLongRunning_Test(int timeout,
                                         Mock <IIAM> iam,
                                         Mock <IAppConfig> config,
                                         Mock <IDataClient> dataClient,
                                         Mock <IJobProxy> jobProxy,
                                         Mock <IStoredProcedureRequest> greenplumRequest,
                                         Mock <ILogging> logging,
                                         Mock <ITaskLogging> taskLogging,
                                         Mock <IValidation> validation,
                                         Mock <IWorkStatusProxy> workStatusProxy,
                                         IOrchestrationJob orchestrationJob,
                                         ProjectConfig projectConfig,
                                         string customerShortName,
                                         string projectShortName,
                                         Guid id)
        {
            var fixture = new Fixture();

            config.SetupGet(x => x.IAMCustomerManagementUri).Returns(fixture.Create <Uri>().ToString());
            projectConfig.GreenplumConfig.RawConnectionString = Utilities.ValidConnectionString;

            dataClient.Setup(x => x.ExecuteScalar <object>(greenplumRequest.Object)).Returns(It.IsAny <object>());
            iam.Setup(x => x.GetProjectConfig(customerShortName, projectShortName)).Returns(projectConfig);

            var metaData = new MetadataController(config.Object, jobProxy.Object, logging.Object, taskLogging.Object, validation.Object, workStatusProxy.Object);
            var result   = metaData.TestLongRunning(dataClient.Object, iam.Object, customerShortName, projectShortName, timeout);

            result.Should().BeOfType <OkResult>();
        }
コード例 #3
0
        public void LogOperation(string customerShortName,
                                 string projectShortName,
                                 string operation,
                                 IOrchestrationJob job,
                                 TimeSpan span,
                                 int fallbackProgress = 0,
                                 bool writeChildren   = true,
                                 bool canCancel       = true)
        {
            var lastStatus = _workStatusProxy.GetLastStatus(customerShortName, projectShortName, job.analyticsRunUUID);
            var progress   = lastStatus != null ? lastStatus.Progress : fallbackProgress;

            var content = $"Operation {operation} finished with a time of: {span.ToString("c")}.";

            var messages = new List <WorkStatusMessage>()
            {
                new WorkStatusMessage()
                {
                    Content           = content,
                    Severity          = TraceEventType.Information,
                    Timestamp         = DateTime.Now,
                    ViewLevelProperty = WorkStatusMessage.ViewLevel.Internal
                }
            };

            _workStatusProxy.Add(job, AnalyticsRunStatus.Running, messages, progress, writeChildren, canCancel);
            LogOperationPCF(job.analyticsRunUUID, RunType.Analytics, content);
        }
コード例 #4
0
        /// <summary>
        /// Updates an orchestration job in the job repository.
        /// </summary>
        /// <param name="job">job to update</param>
        public void UpdateJob(IOrchestrationJob job)
        {
            var uri      = new Uri(_address, "put");
            var json     = JsonConvert.SerializeObject(job);
            var response = _jsonManagerClient.Client.PutAsync(uri.ToString(), new StringContent(json, Encoding.UTF8, "application/json")).Result;

            _validation.ValidateResponse(response);
        }
コード例 #5
0
ファイル: CacheDB.cs プロジェクト: Dhanas-git/dotnet
        private void AddTasks(IStonebranchClient stonebranchClient, IOrchestrationJob job, string workflowInstanceId, string finishTaskId)
        {
            int vertexX = 200;
            int vertexY = 450;

            var stonebranch       = new Stonebranch(stonebranchClient, _validation);
            var tasks             = stonebranch.GetCurrentTasks(workflowInstanceId, $"*{_config.CacheDBTaskFilter}*");
            var predecessor       = _config.CacheDBPredecessor;
            var flowchartRunCount = job.flowchartRunRequest.Count;
            var i = 1;

            job.flowchartRunRequest.ToList().ForEach(flowchart =>
            {
                var alias      = $"{job.clientName}_{job.projectName}_CacheDB__{flowchart.flowchartRunUUID}";
                var successors = new List <String>();

                if (i == flowchartRunCount)
                {
                    successors.Add(_config.FinishTask);
                }

                if (!tasks.Any(x => x.Name == alias))
                {
                    var data = new TaskInsert()
                    {
                        Alias        = alias,
                        Name         = "CacheDB",
                        Predecessors = new List <String>()
                        {
                            predecessor
                        },
                        Successors         = successors,
                        VertexX            = vertexX,
                        VertexY            = vertexY,
                        WorkflowInstanceId = workflowInstanceId
                    };

                    var connection = new Uri(new Uri(_config.StonebranchUri), "taskinstance/ops-task-insert");
                    var xml        = data.ToXml();
                    var content    = new StringContent(xml, Encoding.UTF8, "application/xml");

                    var response = stonebranchClient.Client.PostAsync(connection.ToString(), content).Result;

                    _validation.ValidateResponse(response);
                    _validation.ValidateStonebranchResponse(response.Content.ReadAsStringAsync().Result);

                    if (i == flowchartRunCount)
                    {
                        stonebranch.ReleaseTask(workflowInstanceId, finishTaskId);
                    }

                    predecessor = alias;
                    vertexX    += 200;
                }

                i++;
            });
        }
コード例 #6
0
ファイル: WorkStatusProxy.cs プロジェクト: Dhanas-git/dotnet
        public void Add(IOrchestrationJob job, AnalyticsRunStatus taskStatus, int progress, bool writeChildren, bool canCancel)
        {
            var statuses = new List <WorkStatus>();

            statuses.Add(new WorkStatus(job.analyticsRunUUID, canCancel, progress, taskStatus));

            if (writeChildren)
            {
                job.flowchartRunRequest.ToList().ForEach(x =>
                {
                    statuses.Add(new WorkStatus(x.flowchartRunUUID, progress, taskStatus));
                });
            }

            Add(statuses);
        }
コード例 #7
0
ファイル: MetaData_Test.cs プロジェクト: Dhanas-git/dotnet
        public void PublishSQL_Test(Mock <IAppConfig> config,
                                    Mock <IJobProxy> jobProxy,
                                    Mock <ILogging> logging,
                                    Mock <ITaskLogging> taskLogging,
                                    Mock <IValidation> validation,
                                    Mock <IWorkStatusProxy> workStatusProxy,
                                    IOrchestrationJob orchestrationJob,
                                    string customerShortName,
                                    string projectShortName,
                                    Guid id)

        {
            var fixture = new Fixture();

            config.SetupGet(x => x.IAMCustomerManagementUri).Returns(fixture.Create <Uri>().ToString());
            config.SetupGet(x => x.AnalyticsEngineUri).Returns(fixture.Create <Uri>().ToString());

            jobProxy.Setup(x => x.GetJob(customerShortName, projectShortName, id)).Returns(orchestrationJob);

            var metaData = new MetadataController(config.Object, jobProxy.Object, logging.Object, taskLogging.Object, validation.Object, workStatusProxy.Object);
            var result   = metaData.PublishSql(new MockReportingServicesClient("{'PublishFlowchartMetadataReportingDB_RestResult':true}"), customerShortName, projectShortName, id);

            result.Should().BeOfType <OkResult>();
        }