예제 #1
0
        public async static void testInfluxDBClient()
        {
            Random      rnd    = new Random();
            int         month  = rnd.Next(1, 100);
            Measurement m      = new Measurement("unittest").AddField("value1", month).AddField("value2", month - 1).AddTag("name", "Tony");
            var         retval = await manager.Write(m);

            Console.Write("connected");
        }
예제 #2
0
        public async Task Write_WithValidMeasurementFields_IsSuccessful()
        {
            //  Arrange
            InfluxManager mgr = new InfluxManager(_influxEndpoint, _influxDatabase);
            Measurement m = new Measurement()
            {
                Name = "unittest",
                IntegerFields = new List<IntegerField>()
                {
                    new IntegerField() { Name="count", Value=44 }
                },
                Timestamp = DateTime.Parse("10/26/2015 13:48")
            };

            //  Act
            Task<HttpResponseMessage> asyncretval = mgr.Write(m);
            Debug.WriteLine(DateTime.Now); // Log the time right after the call:

            HttpResponseMessage retval = await asyncretval; // Await the return
            Debug.WriteLine(DateTime.Now); // Log the time right after the return:

            //  Assert
            Assert.IsNotNull(retval);
            Assert.AreEqual(204, (int)retval.StatusCode);
        }
예제 #3
0
        public async Task Write_WithValidMeasurementFields_IsSuccessful()
        {
            //  Arrange
            InfluxManager mgr = new InfluxManager(_influxEndpoint, _influxDatabase);
            Measurement   m   = new Measurement()
            {
                Name          = "unittest",
                IntegerFields = new List <IntegerField>()
                {
                    new IntegerField()
                    {
                        Name = "count", Value = 44
                    }
                },
                Timestamp = DateTime.Parse("2015-10-26 13:48")
            };

            //  Act
            Task <HttpResponseMessage> asyncretval = mgr.Write(m);

            Debug.WriteLine(DateTime.Now);                  // Log the time right after the call:

            HttpResponseMessage retval = await asyncretval; // Await the return

            Debug.WriteLine(DateTime.Now);                  // Log the time right after the return:

            //  Assert
            Assert.IsNotNull(retval);
            Assert.AreEqual(204, (int)retval.StatusCode);
        }
예제 #4
0
        public async Task Write_WithMultipleValidMeasurementFieldsNoTimestamp_IsSuccessful()
        {
            //  Arrange
            InfluxManager      mgr          = new InfluxManager(_influxEndpoint, _influxDatabase);
            List <Measurement> measurements = new List <Measurement>()
            {
                new Measurement()
                {
                    Name          = "unittest",
                    IntegerFields = new List <Fields.IntegerField>()
                    {
                        new IntegerField()
                        {
                            Name = "count", Value = 91
                        }
                    },
                    Tags = new List <Tag>()
                    {
                        new Tag()
                        {
                            Name = "element", Value = "1"
                        }
                    }
                },
                new Measurement()
                {
                    Name          = "unittest",
                    IntegerFields = new List <Fields.IntegerField>()
                    {
                        new IntegerField()
                        {
                            Name = "count", Value = 92
                        }
                    },
                    Tags = new List <Tag>()
                    {
                        new Tag()
                        {
                            Name = "element", Value = "2"
                        }
                    }
                }
            };

            //  Act
            Task <HttpResponseMessage> asyncretval = mgr.Write(measurements);

            Debug.WriteLine("{0} - Right after the call", DateTime.Now);   // Log the time right after the call:

            HttpResponseMessage retval = await asyncretval;                // Await the return

            Debug.WriteLine("{0} - Right after the return", DateTime.Now); // Log the time right after the return:

            //  Assert
            Assert.IsNotNull(retval);
            Assert.AreEqual(204, (int)retval.StatusCode);
        }
예제 #5
0
        public async Task Write_WithNoMeasurementFields_ThrowsException()
        {
            //  Arrange
            InfluxManager mgr = new InfluxManager(_influxEndpoint, _influxDatabase, true);
            //  ---- Note that we have to request exceptions in order to see this   ^^^^

            Measurement m = new Measurement()
            {
                Name = "unittest"
            };

            //  Act
            var retval = await mgr.Write(m);

            //  Assert
            //  Should throw an exception and not get here
        }
예제 #6
0
        public async Task Write_WithNoMeasurementFields_ThrowsException()
        {
            //  Arrange
            InfluxManager mgr = new InfluxManager(_influxEndpoint, _influxDatabase, true);
            //  ---- Note that we have to request exceptions in order to see this   ^^^^

            Measurement m = new Measurement()
            {
                Name = "unittest"
            };

            //  Act
            var retval = await mgr.Write(m);

            //  Assert
            //  Should throw an exception and not get here
        }
예제 #7
0
        public async Task Write_WithCredentialsAndValidMeasurementFields_IsSuccessful()
        {
            //  Arrange
            InfluxManager mgr = new InfluxManager(_influxEndpoint, _influxDatabase, _influxUser, _influxPassword);
            Measurement   m   = new Measurement("unittest").AddField("count", 42);

            //  Act
            Task <HttpResponseMessage> asyncretval = mgr.Write(m);

            Debug.WriteLine(DateTime.Now);                  // Log the time right after the call:

            HttpResponseMessage retval = await asyncretval; // Await the return

            Debug.WriteLine(DateTime.Now);                  // Log the time right after the return:

            //  Assert
            Assert.IsNotNull(retval);
            Assert.AreEqual(204, (int)retval.StatusCode);
        }
예제 #8
0
        public async Task Write_WithCredentialsAndValidMeasurementFields_IsSuccessful()
        {
            //  Arrange
            InfluxManager mgr = new InfluxManager(_influxEndpoint, _influxDatabase, _influxUser, _influxPassword);
            Measurement m = new Measurement("unittest").AddField("count", 42);

            //  Act
            Task<HttpResponseMessage> asyncretval = mgr.Write(m);
            Debug.WriteLine(DateTime.Now); // Log the time right after the call:

            HttpResponseMessage retval = await asyncretval; // Await the return
            Debug.WriteLine(DateTime.Now); // Log the time right after the return:

            //  Assert
            Assert.IsNotNull(retval);
            Assert.AreEqual(204, (int)retval.StatusCode);
        }
예제 #9
0
        public async Task Write_WithMultipleValidMeasurementFieldsNoTimestamp_IsSuccessful()
        {
            //  Arrange
            InfluxManager mgr = new InfluxManager(_influxEndpoint, _influxDatabase);
            List<Measurement> measurements = new List<Measurement>()
            {
                new Measurement()
                {
                    Name = "unittest",
                    IntegerFields = new List<Fields.IntegerField>()
                    {
                        new IntegerField() { Name="count", Value=91 }
                    },
                    Tags = new List<Tag>()
                    {
                        new Tag() { Name="element", Value="1" }
                    }
                },
                new Measurement()
                {
                    Name = "unittest",
                    IntegerFields = new List<Fields.IntegerField>()
                    {
                        new IntegerField() { Name="count", Value=92 }
                    },
                    Tags = new List<Tag>()
                    {
                        new Tag() { Name="element", Value="2" }
                    }
                }
            };

            //  Act
            Task<HttpResponseMessage> asyncretval = mgr.Write(measurements);
            Debug.WriteLine("{0} - Right after the call", DateTime.Now); // Log the time right after the call:

            HttpResponseMessage retval = await asyncretval; // Await the return
            Debug.WriteLine("{0} - Right after the return", DateTime.Now); // Log the time right after the return:

            //  Assert
            Assert.IsNotNull(retval);
            Assert.AreEqual(204, (int)retval.StatusCode);
        }