Skip to content

Commit

Permalink
improve http e2e test apache#5446
Browse files Browse the repository at this point in the history
  • Loading branch information
q3356564 committed Oct 18, 2023
1 parent d31e947 commit 3caa56c
Show file tree
Hide file tree
Showing 4 changed files with 221 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,16 @@ public void testSourceToAssertSink(TestContainer container)
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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#
# 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 = 3
},
{
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
}
]
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#
# 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
}
]
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4447,5 +4447,60 @@
]
}
}
},
{
"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"
}
}
}
]

0 comments on commit 3caa56c

Please sign in to comment.