This is an automated email from the ASF dual-hosted git repository.
wanghailin pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/seatunnel.git
The following commit(s) were added to refs/heads/dev by this push:
new f5867adcaa [improve][Connector-V2][http] improve http e2e test (#5655)
f5867adcaa is described below
commit f5867adcaa2c8c32d378f60faf2c91c6f74a714a
Author: kk <[email protected]>
AuthorDate: Wed Oct 25 11:45:35 2023 +0800
[improve][Connector-V2][http] improve http e2e test (#5655)
---
docs/en/connector-v2/sink/Http.md | 1 -
.../seatunnel/http/sink/HttpSinkFactory.java | 1 -
.../seatunnel/e2e/connector/http/HttpIT.java | 10 +++
.../resources/http_formrequestbody_to_assert.conf | 85 ++++++++++++++++++++++
.../resources/http_jsonrequestbody_to_assert.conf | 85 ++++++++++++++++++++++
.../src/test/resources/mockserver-config.json | 79 ++++++++++++++++++++
6 files changed, 259 insertions(+), 2 deletions(-)
diff --git a/docs/en/connector-v2/sink/Http.md
b/docs/en/connector-v2/sink/Http.md
index 099943ce86..55a69e9333 100644
--- a/docs/en/connector-v2/sink/Http.md
+++ b/docs/en/connector-v2/sink/Http.md
@@ -36,7 +36,6 @@ They can be downloaded via install-plugin.sh or from the
Maven central repositor
|-----------------------------|--------|----------|---------|-----------------------------------------------------------------------------------------------------|
| url | String | Yes | - | Http request url
|
| headers | Map | No | - | Http headers
|
-| params | Map | No | - | Http params
|
| retry | Int | No | - | The max retry
times if request http return to `IOException`
|
| retry_backoff_multiplier_ms | Int | No | 100 | The
retry-backoff times(millis) multiplier if request http failed
|
| retry_backoff_max_ms | Int | No | 10000 | The maximum
retry-backoff times(millis) if request http failed
|
diff --git
a/seatunnel-connectors-v2/connector-http/connector-http-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/http/sink/HttpSinkFactory.java
b/seatunnel-connectors-v2/connector-http/connector-http-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/http/sink/HttpSinkFactory.java
index 0d961f711c..8411001fff 100644
---
a/seatunnel-connectors-v2/connector-http/connector-http-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/http/sink/HttpSinkFactory.java
+++
b/seatunnel-connectors-v2/connector-http/connector-http-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/http/sink/HttpSinkFactory.java
@@ -36,7 +36,6 @@ public class HttpSinkFactory implements TableSinkFactory {
return OptionRule.builder()
.required(HttpConfig.URL)
.optional(HttpConfig.HEADERS)
- .optional(HttpConfig.PARAMS)
.optional(HttpConfig.RETRY)
.optional(HttpConfig.RETRY_BACKOFF_MULTIPLIER_MS)
.optional(HttpConfig.RETRY_BACKOFF_MAX_MS)
diff --git
a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/java/org/apache/seatunnel/e2e/connector/http/HttpIT.java
b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/java/org/apache/seatunnel/e2e/connector/http/HttpIT.java
index 402abd5915..d65617bb55 100644
---
a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/java/org/apache/seatunnel/e2e/connector/http/HttpIT.java
+++
b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/java/org/apache/seatunnel/e2e/connector/http/HttpIT.java
@@ -135,6 +135,16 @@ public class HttpIT extends TestSuiteBase implements
TestResource {
Container.ExecResult execResult12 =
container.executeJob("/http_multilinejson_to_assert.conf");
Assertions.assertEquals(0, execResult12.getExitCode());
+
+ // http httpFormRequestbody
+ Container.ExecResult execResult13 =
+ container.executeJob("/http_formrequestbody_to_assert.conf");
+ Assertions.assertEquals(0, execResult13.getExitCode());
+
+ // http httpJsonRequestBody
+ Container.ExecResult execResult14 =
+ container.executeJob("/http_jsonrequestbody_to_assert.conf");
+ Assertions.assertEquals(0, execResult14.getExitCode());
}
public String getMockServerConfig() {
diff --git
a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/http_formrequestbody_to_assert.conf
b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/http_formrequestbody_to_assert.conf
new file mode 100644
index 0000000000..facebc81ef
--- /dev/null
+++
b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/http_formrequestbody_to_assert.conf
@@ -0,0 +1,85 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+env {
+ execution.parallelism = 1
+ job.mode = "BATCH"
+}
+
+source {
+ Http {
+ result_table_name = "http"
+ url = "http://mockserver:1080/example/formBody"
+ method = "POST"
+ params ={id = 1}
+ format = "json"
+ schema = {
+ fields {
+ name = string
+ age = int
+ }
+ }
+ }
+}
+
+sink {
+ Console {
+ source_table_name = "http"
+ }
+ Assert {
+ source_table_name = "http"
+ rules {
+ row_rules = [
+ {
+ rule_type = MAX_ROW
+ rule_value = 2
+ },
+ {
+ rule_type = MIN_ROW
+ rule_value = 2
+ }
+ ],
+ field_rules = [
+ {
+ field_name = name
+ field_type = string
+ field_value = [
+ {
+ rule_type = NOT_NULL
+ }
+ ]
+ },
+ {
+ field_name = age
+ field_type = int
+ field_value = [
+ {
+ rule_type = NOT_NULL
+ }
+ ]
+ }
+ ]
+ }
+ }
+ Http {
+ source_table_name = "http"
+ url = "http://mockserver:1080/example/webhook"
+ headers {
+ token = "9e32e859ef044462a257e1fc76730066"
+ }
+ }
+}
\ No newline at end of file
diff --git
a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/http_jsonrequestbody_to_assert.conf
b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/http_jsonrequestbody_to_assert.conf
new file mode 100644
index 0000000000..5fde4d4872
--- /dev/null
+++
b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/http_jsonrequestbody_to_assert.conf
@@ -0,0 +1,85 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+env {
+ execution.parallelism = 1
+ job.mode = "BATCH"
+}
+
+source {
+ Http {
+ result_table_name = "http"
+ url = "http://mockserver:1080/example/jsonBody"
+ method = "POST"
+ body="{"id":1}"
+ format = "json"
+ schema = {
+ fields {
+ name = string
+ age = int
+ }
+ }
+ }
+}
+
+sink {
+ Console {
+ source_table_name = "http"
+ }
+ Assert {
+ source_table_name = "http"
+ rules {
+ row_rules = [
+ {
+ rule_type = MAX_ROW
+ rule_value = 2
+ },
+ {
+ rule_type = MIN_ROW
+ rule_value = 2
+ }
+ ],
+ field_rules = [
+ {
+ field_name = name
+ field_type = string
+ field_value = [
+ {
+ rule_type = NOT_NULL
+ }
+ ]
+ },
+ {
+ field_name = age
+ field_type = int
+ field_value = [
+ {
+ rule_type = NOT_NULL
+ }
+ ]
+ }
+ ]
+ }
+ }
+ Http {
+ source_table_name = "http"
+ url = "http://mockserver:1080/example/webhook"
+ headers {
+ token = "9e32e859ef044462a257e1fc76730066"
+ }
+ }
+}
\ No newline at end of file
diff --git
a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/mockserver-config.json
b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/mockserver-config.json
index 622c4a1d9f..2c419277e0 100644
---
a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/mockserver-config.json
+++
b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-http-e2e/src/test/resources/mockserver-config.json
@@ -4447,5 +4447,84 @@
]
}
}
+ },
+ {
+ "httpRequest": {
+ "method" : "POST",
+ "path": "/example/jsonBody",
+ "body": {
+ "type": "JSON",
+ "json": {
+ "id": 1
+ },
+ "matchType": "STRICT"
+ }
+ },
+ "httpResponse": {
+ "body": [
+ {
+ "name": "lzl",
+ "age": 18
+ },
+ {
+ "name": "pizz",
+ "age": 19
+ }
+ ],
+ "headers": {
+ "Content-Type": "application/json"
+ }
+ }
+ },
+ {
+ "httpRequest": {
+ "path": "/example/formBody",
+ "method": "POST",
+ "body": {
+ "type": "PARAMETERS",
+ "parameters": {
+ "id": "1"
+ }
+ }
+ },
+ "httpResponse": {
+ "body": [
+ {
+ "name": "lzl",
+ "age": 18
+ },
+ {
+ "name": "pizz",
+ "age": 19
+ }
+ ],
+ "headers": {
+ "Content-Type": "application/json"
+ }
+ }
+ },
+ {
+ "httpRequest": {
+ "path": "/example/webhook",
+ "method": "POST",
+ "headers": {
+ "token": ["9e32e859ef044462a257e1fc76730066"]
+ }
+ },
+ "httpResponse": {
+ "body": [
+ {
+ "name": "lzl",
+ "age": 18
+ },
+ {
+ "name": "pizz",
+ "age": 19
+ }
+ ],
+ "headers": {
+ "Content-Type": "application/json"
+ }
+ }
}
]