-
Notifications
You must be signed in to change notification settings - Fork 470
Expand file tree
/
Copy pathTicketTest.java
More file actions
122 lines (107 loc) · 3.45 KB
/
Copy pathTicketTest.java
File metadata and controls
122 lines (107 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package org.influxdb;
import java.io.IOException;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import org.influxdb.dto.BatchPoints;
import org.influxdb.dto.Point;
import org.influxdb.dto.Query;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.runner.RunWith;
/**
* Test the InfluxDB API.
*
* @author stefan.majer [at] gmail.com
*
*/
@DisplayName("Test for github issues")
@RunWith(JUnitPlatform.class)
public class TicketTest {
private InfluxDB influxDB;
/**
* Create a influxDB connection before all tests start.
*
* @throws InterruptedException
* @throws IOException
*/
@BeforeEach
public void setUp() throws InterruptedException, IOException {
this.influxDB = TestUtils.connectToInfluxDB();
}
/**
* Test for ticket #38
*
*/
@Test
public void testTicket38() {
String dbName = "ticket38_" + System.currentTimeMillis();
this.influxDB.query(new Query("CREATE DATABASE " + dbName));
Point point1 = Point
.measurement("metric")
.time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
.addField("value", 5.0)
.tag("host", "host A")
.tag("host", "host-B")
.tag("host", "host-\"C")
.tag("region", "region")
.build();
this.influxDB.write(dbName, TestUtils.defaultRetentionPolicy(this.influxDB.version()), point1);
this.influxDB.query(new Query("DROP DATABASE " + dbName));
}
/**
* Test for ticket #39
*
*/
@Test
public void testTicket39() {
String dbName = "ticket39_" + System.currentTimeMillis();
this.influxDB.query(new Query("CREATE DATABASE " + dbName));
BatchPoints batchPoints = BatchPoints
.database(dbName)
.tag("async", "true")
.retentionPolicy(TestUtils.defaultRetentionPolicy(this.influxDB.version()))
.consistency(InfluxDB.ConsistencyLevel.ALL)
.build();
Point.Builder builder = Point.measurement("my_type");
builder.addField("my_field", "string_value");
Point point = builder.build();
batchPoints.point(point);
this.influxDB.write(batchPoints);
this.influxDB.query(new Query("DROP DATABASE " + dbName));
}
/**
* Test for ticket #40
*/
@Test
public void testTicket40() {
String dbName = "ticket40_" + System.currentTimeMillis();
this.influxDB.query(new Query("CREATE DATABASE " + dbName));
this.influxDB.enableBatch(100, 100, TimeUnit.MICROSECONDS);
for (int i = 0; i < 1000; i++) {
Point point = Point.measurement("cpu").addField("idle", 99.0).build();
this.influxDB.write(dbName, TestUtils.defaultRetentionPolicy(this.influxDB.version()), point);
}
this.influxDB.query(new Query("DROP DATABASE " + dbName));
}
/**
* Test for ticket #303
*
*/
@Test
public void testTicket303() {
String dbName = "ticket303_" + System.currentTimeMillis();
this.influxDB.query(new Query("CREATE DATABASE " + dbName));
Date rundate1 = new Date() ;
long rundate1Sec = rundate1.getTime() / 1000;
Point point1 = Point
.measurement("TestSlash")
.time(rundate1Sec, TimeUnit.SECONDS)
.tag("precision", "Second")
.addField("MultipleSlash" , "echo \\\".ll 12.0i\\\";")
.build();
this.influxDB.write(dbName, TestUtils.defaultRetentionPolicy(this.influxDB.version()), point1);
this.influxDB.query(new Query("DROP DATABASE " + dbName));
}
}