Пример #1
0
        public void TestAliveJob(string url, string job, int numberTables)
        {
            //if this does not work and you have already a jenkins running in docker-compose
            //run this
            //docker exec docker_jenkins_1 bash -c "cat /var/jenkins_home/jenkinsjob.xml | java -jar /var/jenkins_home/war/WEB-INF/jenkins-cli.jar -s http://localhost:8080 create-job newmyjob"

            IReceive receiver = null;

            IDataToSent data = null;
            string      nl   = Environment.NewLine;

            $"When I create the {nameof(ReceiverJenkinsJob)} for the {url}".w(() => receiver = new ReceiverJenkinsJob(url, job));
            $"And I read the data".w(async() => data = await receiver.TransformData(null));
            $"Then should be a data".w(() => data.Should().NotBeNull());
            $"With {numberTables} table".w(() =>
            {
                data.DataToBeSentFurther.Should().NotBeNull();
                data.DataToBeSentFurther.Count.Should().BeGreaterOrEqualTo(numberTables);
            });
            $"and should have data success".w(() =>
            {
                var res = AliveStatus.FromTable(data.DataToBeSentFurther.First().Value);
                res.Should().NotBeNull();
                res.Count().Should().Be(1);
                res.First().IsSuccess.Should().Be(true);
            });
        }
Пример #2
0
        private async Task PublishData(MonitorOptions opt, DataTable res)
        {
            var dataToBeSent = AliveStatus.FromTable(res)
                               .Select(d => opt.DataFromResult(d))
                               .ToArray();

            using (var scope = sc.CreateScope())
            {
                var mediator = scope.ServiceProvider.GetRequiredService <IMediator>();
                foreach (var item in dataToBeSent)
                {
                    await mediator.Publish(item);
                }
            }
        }
Пример #3
0
        public async Task AliveStatusFromPing()
        {
            #region arrange
            var r = new ReceiverPing("127.0.0.1");
            #endregion
            #region act
            var dt = await r.TransformData(null);

            var res = AliveStatus.FromTable(dt.DataToBeSentFurther.First().Value);
            #endregion
            #region assert
            res.Should().NotBeNull();
            res.Count().Should().Be(1);
            res.First().IsSuccess.Should().Be(true);
            #endregion
        }
Пример #4
0
        public async Task <ActionResult <ResultWithData[]> > Get(
            [FromServices] IMediator mediator,
            [FromServices] IOptionsSnapshot <MonitorOptions> opt)
        //[FromServices]MonitorOptions optVal)
        {
            var optVal = opt.Value;
            var toExec = optVal.ToExecuteCRON().Select(it => it.Execute()).ToArray();
            //var exec = await Task.WhenAll(optVal.AllItems().Select(it => it.Execute()).ToArray());
            var exec = await Task.WhenAll(toExec);

            var all = exec
                      .Select(it => AliveStatus.FromTable(it))
                      .SelectMany(it => it)
                      .Select(it => optVal.DataFromResult(it))
                      .ToArray();

            foreach (var item in all)
            {
                await mediator.Publish(item);
            }
            return(all);
        }
Пример #5
0
        public void TestAlive(string url, int numberTables)
        {
            IReceive receiver = null;

            IDataToSent data = null;
            string      nl   = Environment.NewLine;

            $"When I create the {nameof(ReceiverJenkins)} for the {url}".w(() => receiver = new ReceiverJenkins(url));
            $"And I read the data".w(async() => data = await receiver.TransformData(null));
            $"Then should be a data".w(() => data.Should().NotBeNull());
            $"With {numberTables} table".w(() =>
            {
                data.DataToBeSentFurther.Should().NotBeNull();
                data.DataToBeSentFurther.Count.Should().BeGreaterOrEqualTo(numberTables);
            });
            $"and should have data success".w(() =>
            {
                var res = AliveStatus.FromTable(data.DataToBeSentFurther.First().Value);
                res.Should().NotBeNull();
                res.Count().Should().Be(1);
                res.First().IsSuccess.Should().Be(true);
            });
        }