目录
1.1 http://localhost:8083/v1/sessions
2.3 执行没有job的语句接口run_non_job_statement
前言:
必须要有flink环境,启动gateway服务;
默认指定的缓存文件在,e2e-tests/data 里面这样。
1. 测试脚本的启动过程
还有点问题,不过能看到启动的过程了;
因为服务已经挂在到服务器,使用远程debug就行,看看具体细节。
$ ./run-tests.sh
Preparing test data...
No HDFS address provided. Putting test data into /tmp directory...
Reading Flink config...
Starting rest endpoint...
Rest endpoint started.
/Users/bjhl/Documents/github/flink-sql-gateway/e2e-tests/test-commons.sh: line 102: jq: command not found
Request to http://localhost:8083/v1/info returns an error.
Request Method: GET
Request Body:
/Users/bjhl/Documents/github/flink-sql-gateway/e2e-tests/test-commons.sh: line 108: jq: command not found
/Users/bjhl/Documents/github/flink-sql-gateway/e2e-tests/test-commons.sh: line 109: jq: command not found
./run-tests.sh: line 80: jq: command not found
Product Name:
./run-tests.sh: line 81: jq: command not found
Version:
################################################################################
# Running tests in batch mode
################################################################################
/Users/bjhl/Documents/github/flink-sql-gateway/e2e-tests/test-commons.sh: line 102: jq: command not found
Request to http://localhost:8083/v1/sessions returns an error.
Request Method: POST
Request Body: {
"planner": "blink",
"execution_type": "batch"
}
/Users/bjhl/Documents/github/flink-sql-gateway/e2e-tests/test-commons.sh: line 108: jq: command not found
/Users/bjhl/Documents/github/flink-sql-gateway/e2e-tests/test-commons.sh: line 109: jq: command not found
/Users/bjhl/Documents/github/flink-sql-gateway/e2e-tests/test-commons.sh: line 102: jq: command not found
Request to http://localhost:8083/v1/sessions//heartbeat returns an error.
Request Method: POST
Request Body:
/Users/bjhl/Documents/github/flink-sql-gateway/e2e-tests/test-commons.sh: line 108: jq: command not found
/Users/bjhl/Documents/github/flink-sql-gateway/e2e-tests/test-commons.sh: line 109: jq: command not found
1.1 http://localhost:8083/v1/sessions
请求:
{
"planner": "blink",
"execution_type": "batch"
}
返回:
{
"session_id": "4a9b0f0c52bbcd1e656a931d3c53ac0b"
}
1.2 发送heartbeat
看代码test-commons中:
function send_heartbeat() {
send_request "POST" "" "http://$HOST:$PORT/$API_VERSION/sessions/$1/heartbeat" > /dev/null
}
http://localhost:8083/v1/sessions/4a9b0f0c52bbcd1e656a931d3c53ac0b/heartbeat
返回空;
2. 其他的api
2.1 get_info
function get_info() {
send_request "GET" "" "http://$HOST:$PORT/$API_VERSION/info"
}
http://localhost:8083/v1/info
返回:
{
"product_name": "Apache Flink",
"version": "1.11.2"
}
2.2 删除session
看来是restful风格的,使用delete请求就好
function delete_session() {
response=`send_request "DELETE" "" "http://$HOST:$PORT/$API_VERSION/sessions/$1"`
if [[ "$?" -ne 0 ]]
then
exit 1
fi
}
2.3 执行没有job的语句接口run_non_job_statement
function run_non_job_statement() {
json=`cat <<EOF
{
"statement": "$2"
}
EOF`
response=`send_request "POST" "$json" "http://$HOST:$PORT/$API_VERSION/sessions/$1/statements"`
if [[ "$?" -ne 0 ]]
then
exit 1
fi
type=`get_json_element "$response" ".statement_types[0]"`
assert_equals "$3" "$type"
make_array_from_json "`get_json_element "$response" ".results[0].data"`"
}
请求地址:
http://host:8083/v1/sessions/4a9b0f0c52bbcd1e656a931d3c53ac0b/statements
请求入参:
{
"statement":"create table nation (n_nationkey bigint not null, n_name varchar not null, n_regionkey bigint not null, n_comment varchar not null ) WITH ('connector.type'='filesystem', 'connector.path'='hdfs://flinknameservice1/tmp/flink_sql_gateway_test/nation.tbl', 'format.type' = 'csv','format.derive-schema' = 'true','format.field-delimiter' = '|')"
}
返回:
{
"results": [
{
"result_kind": "SUCCESS",
"columns": [
{
&#