From 7d51d960a946c8483031bd0e8ef64495c0dace44 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Wed, 24 Apr 2024 16:57:47 +0200 Subject: [PATCH 01/20] fix: issue #623 - support IPv6 hosts --- .../client/InfluxDBClientOptions.java | 11 +-- .../client/InfluxDBClientOptionsTest.java | 70 ++++++++++++++++ .../influxdb/client/InfluxDBClientTest.java | 82 +++++++++++++++++++ 3 files changed, 158 insertions(+), 5 deletions(-) diff --git a/client/src/main/java/com/influxdb/client/InfluxDBClientOptions.java b/client/src/main/java/com/influxdb/client/InfluxDBClientOptions.java index 291f0f85eea..528f5418dd9 100644 --- a/client/src/main/java/com/influxdb/client/InfluxDBClientOptions.java +++ b/client/src/main/java/com/influxdb/client/InfluxDBClientOptions.java @@ -694,12 +694,13 @@ private ParsedUrl(@Nonnull final String connectionString) { HttpUrl url = this.httpUrl.newBuilder().build(); - String urlWithoutParams = url.scheme() + "://" + url.host() + ":" + url.port() + url.encodedPath(); - if (!urlWithoutParams.endsWith("/")) { - urlWithoutParams += "/"; - } + //detect IPV6 + String host = url.host().contains(":") ? "[" + url.host() + "]" : url.host(); + String urlWithoutParams = url.scheme() + "://" + host + ":" + url.port() + url.encodedPath(); - this.urlWithoutParams = urlWithoutParams; + this.urlWithoutParams = urlWithoutParams.endsWith("/") + ? urlWithoutParams + : urlWithoutParams + "/"; } } } diff --git a/client/src/test/java/com/influxdb/client/InfluxDBClientOptionsTest.java b/client/src/test/java/com/influxdb/client/InfluxDBClientOptionsTest.java index 5c18f75c3ee..c95ae134bd6 100644 --- a/client/src/test/java/com/influxdb/client/InfluxDBClientOptionsTest.java +++ b/client/src/test/java/com/influxdb/client/InfluxDBClientOptionsTest.java @@ -21,11 +21,14 @@ */ package com.influxdb.client; +import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; import com.influxdb.client.domain.WritePrecision; +import com.influxdb.exceptions.InfluxException; import okhttp3.OkHttpClient; import okhttp3.Protocol; import org.assertj.core.api.Assertions; @@ -156,4 +159,71 @@ public void customClientTypeFromProperties() { Assertions.assertThat(options.getClientType()).isEqualTo("properties-service"); } + + @Test + public void ipv6Loopback(){ + String[] loopbacks = {"[::1]", "[0000:0000:0000:0000:0000:0000:0000:0001]"}; + + for (String loopback : loopbacks) { + InfluxDBClientOptions options = InfluxDBClientOptions.builder() + .url(String.format("http://%s:9999/api/v2/", loopback)) + .authenticateToken("xyz".toCharArray()) + .org("my-org") + .build(); + + Assertions.assertThat(options.getUrl()).isEqualTo("http://[::1]:9999/api/v2/"); + Assertions.assertThat(options.getAuthScheme()).isEqualTo(InfluxDBClientOptions.AuthScheme.TOKEN); + Assertions.assertThat(options.getOkHttpClient()).isNotNull(); + Assertions.assertThat(options.getPrecision()).isEqualTo(WritePrecision.NS); + Assertions.assertThat(options.getOrg()).isEqualTo("my-org"); + } + } + + @Test + public void ipv6General(){ + Map ipv6Expected = Map.of( + "[2001:db80:0001:1000:1100:0011:1110:0111]", "[2001:db80:1:1000:1100:11:1110:111]", + "[2001:db8:1000:0000:0000:0000:0000:0001]", "[2001:db8:1000::1]", + "[2001:db8f:0ff0:00ee:0ddd:000c:bbbb:aaaa]", "[2001:db8f:ff0:ee:ddd:c:bbbb:aaaa]", + "[2001:0db8:0000:0000:0000:9876:0000:001f]", "[2001:db8::9876:0:1f]", + "[0000:0000:0000:0000:0000:0000:0000:0000]", "[::]", + "[2001:0db8:fedc:edcb:dcba:cba9:ba98:a987]", "[2001:db8:fedc:edcb:dcba:cba9:ba98:a987]"//, + //"[::1]", "" + ); + + for(String key : ipv6Expected.keySet()){ + InfluxDBClientOptions options = InfluxDBClientOptions.builder() + .url(String.format("http://%s:9999/api/v2/query?orgID=my-org", key)) + .authenticateToken("xyz".toCharArray()) + .build(); + + System.out.println(key + ": " + options.getUrl()); + + Assertions.assertThat(options.getUrl()) + .isEqualTo(String.format("http://%s:9999/api/v2/query/", ipv6Expected.get(key))); + Assertions.assertThat(options.getToken()) + .isEqualTo("xyz".toCharArray()); + } + } + + @Test + public void ipv6Invalid(){ + List invalidIpv6 = Arrays.asList( + "[:1]", + "[:::1]", + "[2001:db8:0000:1]", + "[2001:db8:00000::1]", + "[2001:db8:0000:::1]", + "[:0000::1]", + "[:::0000::1]"); + for(String ipv6 : invalidIpv6){ + Assertions.assertThatThrownBy(() -> { InfluxDBClientOptions options2 = InfluxDBClientOptions.builder() + .url(String.format("http://%s:9999/api/v2/query?orgID=my-org", ipv6)) + .authenticateToken("xyz".toCharArray()) + .build();}).isInstanceOf(InfluxException.class) + .hasMessage(String.format("Unable to parse connection string http://%s:9999/api/v2/query?orgID=my-org", ipv6)); + } + + } + } \ No newline at end of file diff --git a/client/src/test/java/com/influxdb/client/InfluxDBClientTest.java b/client/src/test/java/com/influxdb/client/InfluxDBClientTest.java index ee163c12c9a..747d667ed75 100644 --- a/client/src/test/java/com/influxdb/client/InfluxDBClientTest.java +++ b/client/src/test/java/com/influxdb/client/InfluxDBClientTest.java @@ -21,7 +21,9 @@ */ package com.influxdb.client; +import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.OutputStream; import java.net.InetSocketAddress; import java.net.Proxy; import java.util.List; @@ -31,6 +33,9 @@ import java.util.logging.Logger; import javax.annotation.Nonnull; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpServer; +import com.sun.net.httpserver.HttpHandler; import com.influxdb.LogLevel; import com.influxdb.client.domain.Authorization; import com.influxdb.client.domain.Run; @@ -469,6 +474,83 @@ public void redactedAuthorizationHeader() { Assertions.assertThat(authorizationLog.getMessage()).isEqualTo("Authorization: ██"); } + static class HTTPServerThread extends Thread { + HttpServer server; + public HTTPServerThread(ServerHandler handler) throws IOException { + server = HttpServer.create(new InetSocketAddress(44404), 0); + server.createContext("/", handler); + } + + @Override + public void run() { + server.start(); + } + } + + static class ServerHandler implements HttpHandler { + + public String lastUri; + public String lastMethod; + public String lastPostBody; + + @Override + public void handle(HttpExchange exchange) throws IOException { + lastUri = exchange.getRequestURI().toString(); + lastMethod = exchange.getRequestMethod(); + if(lastMethod.equalsIgnoreCase("POST")){ + ByteArrayOutputStream os = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + for(int length; (length = exchange.getRequestBody().read(buffer)) != -1; ) { + os.write(buffer, 0, length); + } + lastPostBody = os.toString(); + } + String response = "OK"; + exchange.sendResponseHeaders(200, response.length()); + OutputStream os = exchange.getResponseBody(); + os.write(response.getBytes()); + os.close(); + } + } + + @Test + public void ipv6Calls() throws InterruptedException, IOException { + ServerHandler handler = new ServerHandler(); + HTTPServerThread st = new HTTPServerThread(handler); + st.start(); + + InfluxDBClientOptions options = InfluxDBClientOptions.builder() + .url("http://[::1]:44404") + .bucket("my-bucket") + .org("my-org") + .build(); + InfluxDBClient client = InfluxDBClientFactory.create(options); + WriteApiBlocking writer = client.getWriteApiBlocking(); + writer.writeRecord(WritePrecision.NS, "mem,source=ff10 use=87"); + + Assertions.assertThat(handler.lastUri) + .isEqualTo("/api/v2/write?org=my-org&bucket=my-bucket&precision=ns"); + Assertions.assertThat(handler.lastMethod).isEqualTo("POST"); + Assertions.assertThat(handler.lastPostBody).isEqualTo("mem,source=ff10 use=87"); + + QueryApi queryApi = client.getQueryApi(); + String qresult = queryApi + .queryRaw("from(bucket: \"my-bucket\") " + + "|> range(start: -1h) " + + "|> filter(fn: (r) => r._field == \"cpu\""); + Assertions.assertThat("OK").isEqualTo(qresult); + Assertions.assertThat(handler.lastUri).isEqualTo("/api/v2/query?org=my-org"); + Assertions.assertThat(handler.lastMethod).isEqualTo("POST"); + Assertions.assertThat(handler.lastPostBody) + .isEqualTo("{\"query\":\"from(bucket: \\\"my-bucket\\\") " + + "|\\u003e range(start: -1h) " + + "|\\u003e filter(fn: (r) " + + "\\u003d\\u003e r._field " + + "\\u003d\\u003d \\\"cpu\\\"\",\"type\":\"flux\",\"params\":{}}"); + + st.server.stop(0); + } + private void queryAndTest(final String expected) throws InterruptedException { RecordedRequest request = takeRequest(); Assertions.assertThat(request).isNotNull(); From 584f51c97849d69698f455b436f12e1f3e02a7a5 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Wed, 24 Apr 2024 17:27:24 +0200 Subject: [PATCH 02/20] chore: troubleshoot Protocol family unavailable in CircleCI --- .../src/test/java/com/influxdb/client/InfluxDBClientTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/src/test/java/com/influxdb/client/InfluxDBClientTest.java b/client/src/test/java/com/influxdb/client/InfluxDBClientTest.java index 747d667ed75..734f6509df9 100644 --- a/client/src/test/java/com/influxdb/client/InfluxDBClientTest.java +++ b/client/src/test/java/com/influxdb/client/InfluxDBClientTest.java @@ -519,6 +519,8 @@ public void ipv6Calls() throws InterruptedException, IOException { HTTPServerThread st = new HTTPServerThread(handler); st.start(); + Thread.sleep(500); + InfluxDBClientOptions options = InfluxDBClientOptions.builder() .url("http://[::1]:44404") .bucket("my-bucket") From 04baf5058a94f169743bb2993921ecc724f9848e Mon Sep 17 00:00:00 2001 From: karel rehor Date: Thu, 25 Apr 2024 10:13:50 +0200 Subject: [PATCH 03/20] chore: troubleshoot ipv6 enable --- .circleci/config.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index e5b07abd280..882391c2451 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,10 +28,23 @@ commands: - run: name: "Post onBoarding request to InfluxDB 2" command: ./scripts/influxdb-onboarding.sh + enable-ipv6: + steps: + - run: + name: ipv6-enable + command: | + cat <<'EOF' | sudo tee /etc/docker/daemon.json + { + "ipv6": true, + "fixed-cidr-v6": "2001:db8:1::/64" + } + EOF + sudo service docker restart prepare: description: "Prepare environment to tests" steps: - checkout + - enable-ipv6 - influxdb-onboarding client-test: description: "Run tests" From 863c72c32a54816323195829ec41ef07f5da7a6b Mon Sep 17 00:00:00 2001 From: karel rehor Date: Thu, 25 Apr 2024 10:18:21 +0200 Subject: [PATCH 04/20] chore: troubleshoot of troubleshoot ipv6 enable --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 882391c2451..afb5bcca3f0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,7 +33,7 @@ commands: - run: name: ipv6-enable command: | - cat <<'EOF' | sudo tee /etc/docker/daemon.json + cat \<<'EOF' | sudo tee /etc/docker/daemon.json { "ipv6": true, "fixed-cidr-v6": "2001:db8:1::/64" From e884ea7519d7c0e8e363b2cb03031f78067a262c Mon Sep 17 00:00:00 2001 From: karel rehor Date: Thu, 25 Apr 2024 10:24:00 +0200 Subject: [PATCH 05/20] chore: specify latest circleci ubuntu image --- .circleci/config.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index afb5bcca3f0..9f715982996 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -42,6 +42,11 @@ commands: sudo service docker restart prepare: description: "Prepare environment to tests" + machine: + # The image uses the current tag, which always points to the most recent + # supported release. If stability and determinism are crucial for your CI + # pipeline, use a release date tag with your image, e.g. ubuntu-2004:202201-02 + image: ubuntu-2004:current steps: - checkout - enable-ipv6 From 177769e55b7b1fd65a3cdfae3351ec4f542e5910 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Thu, 25 Apr 2024 10:33:37 +0200 Subject: [PATCH 06/20] chore: troubleshoot where to place image definition --- .circleci/config.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9f715982996..78dd3796960 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,6 +22,12 @@ version: 2.1 +machine: + # The image uses the current tag, which always points to the most recent + # supported release. If stability and determinism are crucial for your CI + # pipeline, use a release date tag with your image, e.g. ubuntu-2004:202201-02 + image: ubuntu-2204:current + commands: influxdb-onboarding: steps: @@ -42,11 +48,6 @@ commands: sudo service docker restart prepare: description: "Prepare environment to tests" - machine: - # The image uses the current tag, which always points to the most recent - # supported release. If stability and determinism are crucial for your CI - # pipeline, use a release date tag with your image, e.g. ubuntu-2004:202201-02 - image: ubuntu-2004:current steps: - checkout - enable-ipv6 From 56e9119b42088977cc8a890dc4b7b224028dfb57 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Thu, 25 Apr 2024 10:40:35 +0200 Subject: [PATCH 07/20] chore: investigate ulimit error cause in docker --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 78dd3796960..1fbe50e16fa 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -42,7 +42,6 @@ commands: cat \<<'EOF' | sudo tee /etc/docker/daemon.json { "ipv6": true, - "fixed-cidr-v6": "2001:db8:1::/64" } EOF sudo service docker restart From 84407280419ff3ccbdeeaa079af93c26150bcf71 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Thu, 25 Apr 2024 10:45:42 +0200 Subject: [PATCH 08/20] chore: inspect docker/daemon.json --- .circleci/config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1fbe50e16fa..bdb628cca1d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,11 +39,15 @@ commands: - run: name: ipv6-enable command: | + cat /etc/docker/daemon.json + echo "=====" cat \<<'EOF' | sudo tee /etc/docker/daemon.json { "ipv6": true, } EOF + echo "=====" + cat /etc/docker/daemon.json sudo service docker restart prepare: description: "Prepare environment to tests" From d514f7e6953e34daf811e36e1337a932813099f7 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Thu, 25 Apr 2024 10:48:09 +0200 Subject: [PATCH 09/20] chore: retry inspection --- .circleci/config.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bdb628cca1d..61324cac4cd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,8 +39,6 @@ commands: - run: name: ipv6-enable command: | - cat /etc/docker/daemon.json - echo "=====" cat \<<'EOF' | sudo tee /etc/docker/daemon.json { "ipv6": true, From 5134f12d9ca2b3e15f385ec718c197f6301ff3f3 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Thu, 25 Apr 2024 10:50:04 +0200 Subject: [PATCH 10/20] chore: troubleshoot docker restart --- .circleci/config.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 61324cac4cd..f33f9509765 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,13 +39,6 @@ commands: - run: name: ipv6-enable command: | - cat \<<'EOF' | sudo tee /etc/docker/daemon.json - { - "ipv6": true, - } - EOF - echo "=====" - cat /etc/docker/daemon.json sudo service docker restart prepare: description: "Prepare environment to tests" From 40985d3c62e537f2dbe5b125c47e3803cafd1adc Mon Sep 17 00:00:00 2001 From: karel rehor Date: Thu, 25 Apr 2024 10:58:24 +0200 Subject: [PATCH 11/20] chore: inspect service commands --- .circleci/config.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f33f9509765..1f80dac57fe 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,7 +39,9 @@ commands: - run: name: ipv6-enable command: | - sudo service docker restart + sudo service docker status + sudo service docker stop + sudo service docker start prepare: description: "Prepare environment to tests" steps: From e993719db51401db4b810b270bf791d300cc1af8 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Thu, 25 Apr 2024 11:01:10 +0200 Subject: [PATCH 12/20] chore: check docker service status --- .circleci/config.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1f80dac57fe..302cb29635d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -40,8 +40,6 @@ commands: name: ipv6-enable command: | sudo service docker status - sudo service docker stop - sudo service docker start prepare: description: "Prepare environment to tests" steps: From 48240d04e4274986b9bfaa0e93aa48007d7e3f02 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Thu, 25 Apr 2024 11:04:15 +0200 Subject: [PATCH 13/20] chore: check service status in circleci --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 302cb29635d..b34855c98a7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,7 +39,7 @@ commands: - run: name: ipv6-enable command: | - sudo service docker status + sudo service --status-all prepare: description: "Prepare environment to tests" steps: From e5240c397cee36885888b153f2fe7a23d14a50fa Mon Sep 17 00:00:00 2001 From: karel rehor Date: Thu, 25 Apr 2024 11:07:49 +0200 Subject: [PATCH 14/20] chore: explicit start docker service --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index b34855c98a7..9f6014b503d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -40,6 +40,7 @@ commands: name: ipv6-enable command: | sudo service --status-all + sudo service docker start prepare: description: "Prepare environment to tests" steps: From 5960cac1a74ed93a33e239cf54090720c94cfc9b Mon Sep 17 00:00:00 2001 From: karel rehor Date: Thu, 25 Apr 2024 13:46:50 +0200 Subject: [PATCH 15/20] chore: troubleshoot tests --- .circleci/config.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9f6014b503d..3b1df9184bc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,12 +22,6 @@ version: 2.1 -machine: - # The image uses the current tag, which always points to the most recent - # supported release. If stability and determinism are crucial for your CI - # pipeline, use a release date tag with your image, e.g. ubuntu-2004:202201-02 - image: ubuntu-2204:current - commands: influxdb-onboarding: steps: @@ -40,7 +34,7 @@ commands: name: ipv6-enable command: | sudo service --status-all - sudo service docker start + sudo service docker restart prepare: description: "Prepare environment to tests" steps: @@ -120,6 +114,11 @@ commands: jobs: tests-java: + machine: + # The image uses the current tag, which always points to the most recent + # supported release. If stability and determinism are crucial for your CI + # pipeline, use a release date tag with your image, e.g. ubuntu-2004:202201-02 + image: ubuntu-2204:current parameters: maven-image: type: string From 855d62d9378614f9ff3f6202d37e8c68e603afe6 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Thu, 25 Apr 2024 13:51:54 +0200 Subject: [PATCH 16/20] chore: try different location for machine --- .circleci/config.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3b1df9184bc..1c729f266d9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -114,11 +114,6 @@ commands: jobs: tests-java: - machine: - # The image uses the current tag, which always points to the most recent - # supported release. If stability and determinism are crucial for your CI - # pipeline, use a release date tag with your image, e.g. ubuntu-2004:202201-02 - image: ubuntu-2204:current parameters: maven-image: type: string @@ -145,6 +140,11 @@ jobs: INFLUXDB_2_ONBOARDING_IP: influxdb_v2_onboarding INFLUXDB_2_ONBOARDING_PORT: 9999 resource_class: large + machine: + # The image uses the current tag, which always points to the most recent + # supported release. If stability and determinism are crucial for your CI + # pipeline, use a release date tag with your image, e.g. ubuntu-2004:202201-02 + image: ubuntu-2004:current steps: - prepare - client-test: From 1745aabaf9539d62d52dbdf20870f93c5918a92d Mon Sep 17 00:00:00 2001 From: karel rehor Date: Thu, 25 Apr 2024 13:55:45 +0200 Subject: [PATCH 17/20] chore: remove machine block --- .circleci/config.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1c729f266d9..95bd337c93b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -140,11 +140,6 @@ jobs: INFLUXDB_2_ONBOARDING_IP: influxdb_v2_onboarding INFLUXDB_2_ONBOARDING_PORT: 9999 resource_class: large - machine: - # The image uses the current tag, which always points to the most recent - # supported release. If stability and determinism are crucial for your CI - # pipeline, use a release date tag with your image, e.g. ubuntu-2004:202201-02 - image: ubuntu-2004:current steps: - prepare - client-test: From 22accd4948eef8337ab67ee93fdc14bd51ea12a6 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Thu, 25 Apr 2024 14:25:49 +0200 Subject: [PATCH 18/20] chore: restore config.yml to master verstion --- .circleci/config.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 95bd337c93b..e5b07abd280 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,18 +28,10 @@ commands: - run: name: "Post onBoarding request to InfluxDB 2" command: ./scripts/influxdb-onboarding.sh - enable-ipv6: - steps: - - run: - name: ipv6-enable - command: | - sudo service --status-all - sudo service docker restart prepare: description: "Prepare environment to tests" steps: - checkout - - enable-ipv6 - influxdb-onboarding client-test: description: "Run tests" From ea0d777c94f74c09f14b1b718579091aa4eb149b Mon Sep 17 00:00:00 2001 From: karel rehor Date: Thu, 25 Apr 2024 14:49:33 +0200 Subject: [PATCH 19/20] test: removes IPv6 dependent test - not supported by default docker in Circleci --- .../influxdb/client/InfluxDBClientTest.java | 79 ------------------- 1 file changed, 79 deletions(-) diff --git a/client/src/test/java/com/influxdb/client/InfluxDBClientTest.java b/client/src/test/java/com/influxdb/client/InfluxDBClientTest.java index 734f6509df9..af876ccf752 100644 --- a/client/src/test/java/com/influxdb/client/InfluxDBClientTest.java +++ b/client/src/test/java/com/influxdb/client/InfluxDBClientTest.java @@ -474,85 +474,6 @@ public void redactedAuthorizationHeader() { Assertions.assertThat(authorizationLog.getMessage()).isEqualTo("Authorization: ██"); } - static class HTTPServerThread extends Thread { - HttpServer server; - public HTTPServerThread(ServerHandler handler) throws IOException { - server = HttpServer.create(new InetSocketAddress(44404), 0); - server.createContext("/", handler); - } - - @Override - public void run() { - server.start(); - } - } - - static class ServerHandler implements HttpHandler { - - public String lastUri; - public String lastMethod; - public String lastPostBody; - - @Override - public void handle(HttpExchange exchange) throws IOException { - lastUri = exchange.getRequestURI().toString(); - lastMethod = exchange.getRequestMethod(); - if(lastMethod.equalsIgnoreCase("POST")){ - ByteArrayOutputStream os = new ByteArrayOutputStream(); - byte[] buffer = new byte[1024]; - for(int length; (length = exchange.getRequestBody().read(buffer)) != -1; ) { - os.write(buffer, 0, length); - } - lastPostBody = os.toString(); - } - String response = "OK"; - exchange.sendResponseHeaders(200, response.length()); - OutputStream os = exchange.getResponseBody(); - os.write(response.getBytes()); - os.close(); - } - } - - @Test - public void ipv6Calls() throws InterruptedException, IOException { - ServerHandler handler = new ServerHandler(); - HTTPServerThread st = new HTTPServerThread(handler); - st.start(); - - Thread.sleep(500); - - InfluxDBClientOptions options = InfluxDBClientOptions.builder() - .url("http://[::1]:44404") - .bucket("my-bucket") - .org("my-org") - .build(); - InfluxDBClient client = InfluxDBClientFactory.create(options); - WriteApiBlocking writer = client.getWriteApiBlocking(); - writer.writeRecord(WritePrecision.NS, "mem,source=ff10 use=87"); - - Assertions.assertThat(handler.lastUri) - .isEqualTo("/api/v2/write?org=my-org&bucket=my-bucket&precision=ns"); - Assertions.assertThat(handler.lastMethod).isEqualTo("POST"); - Assertions.assertThat(handler.lastPostBody).isEqualTo("mem,source=ff10 use=87"); - - QueryApi queryApi = client.getQueryApi(); - String qresult = queryApi - .queryRaw("from(bucket: \"my-bucket\") " + - "|> range(start: -1h) " + - "|> filter(fn: (r) => r._field == \"cpu\""); - Assertions.assertThat("OK").isEqualTo(qresult); - Assertions.assertThat(handler.lastUri).isEqualTo("/api/v2/query?org=my-org"); - Assertions.assertThat(handler.lastMethod).isEqualTo("POST"); - Assertions.assertThat(handler.lastPostBody) - .isEqualTo("{\"query\":\"from(bucket: \\\"my-bucket\\\") " + - "|\\u003e range(start: -1h) " + - "|\\u003e filter(fn: (r) " + - "\\u003d\\u003e r._field " + - "\\u003d\\u003d \\\"cpu\\\"\",\"type\":\"flux\",\"params\":{}}"); - - st.server.stop(0); - } - private void queryAndTest(final String expected) throws InterruptedException { RecordedRequest request = takeRequest(); Assertions.assertThat(request).isNotNull(); From 1605677512f982b3da72fdf742397ab24f4ee708 Mon Sep 17 00:00:00 2001 From: karel rehor Date: Thu, 25 Apr 2024 15:02:57 +0200 Subject: [PATCH 20/20] docs: update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b379b0cd744..918bfef7127 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ ### Bug Fixes 1. [#684](https://github.com/influxdata/influxdb-client-java/issues/684): Fix checking for CSV end of table marker when parsing CSV stream to InfluxQLQueryResult, needed for example when parsing the results of a query like "SHOW SERIES". -2. [#662](https://github.com/influxdata/influxdb-client-java/issues/662): Adds to FluxDsl support for the `|> elapsed(unit)` function. +2. [#662](https://github.com/influxdata/influxdb-client-java/issues/662): Adds to FluxDsl support for the `|> elapsed(unit)` function. +3. [#623](https://github.com/influxdata/influxdb-client-java/issues/623): Enables the use of IPv6 addresses. ### Dependencies