Skip to content

Commit d0bc060

Browse files
hdurand0710mjuraga
authored andcommitted
TEST/MINOR: e2e: add tune.h2 and bind e2e tests
1 parent c334dd7 commit d0bc060

File tree

8 files changed

+164
-1
lines changed

8 files changed

+164
-1
lines changed

e2e/tests/binds/add_2.8.bats

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bats
2+
#
3+
# Copyright 2023 HAProxy Technologies
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http:#www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
load '../../libs/dataplaneapi'
19+
load "../../libs/get_json_path"
20+
load '../../libs/resource_client'
21+
load '../../libs/version'
22+
load '../../libs/haproxy_config_setup'
23+
load '../../libs/haproxy_version'
24+
25+
load 'utils/_helpers'
26+
27+
@test "binds: Add a new bind (>=2.8)" {
28+
if haproxy_version_ge "2.8"
29+
then
30+
resource_post "$_BIND_BASE_PATH" "data/post_2.8.json" "frontend=test_frontend&force_reload=true"
31+
assert_equal "$SC" 201
32+
33+
resource_get "$_BIND_BASE_PATH/test_bind" "frontend=test_frontend&force_reload=true"
34+
assert_equal "$SC" 200
35+
assert_equal "$(get_json_path "$BODY" '.data.name')" "test_bind"
36+
assert_equal "$(get_json_path "$BODY" ".data.no_alpn")" "true"
37+
fi
38+
}

e2e/tests/binds/data/post_2.8.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"address": "127.0.0.2",
3+
"name": "test_bind",
4+
"port": 10000,
5+
"defer_accept": true,
6+
"allow_0rtt": true,
7+
"thread": "1/all",
8+
"no_alpn": true
9+
}

e2e/tests/binds/data/put_2.8.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"level": "user",
3+
"name": "fixture",
4+
"no_alpn": true,
5+
"address": "127.0.0.1",
6+
"port": 10001
7+
}

e2e/tests/binds/replace_2.8.bats

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bats
2+
#
3+
# Copyright 2023 HAProxy Technologies
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http:#www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
19+
load '../../libs/dataplaneapi'
20+
load '../../libs/get_json_path'
21+
load '../../libs/haproxy_config_setup'
22+
load '../../libs/resource_client'
23+
load '../../libs/version'
24+
25+
load 'utils/_helpers'
26+
27+
@test "binds: Replace a bind (>=2.8)" {
28+
if haproxy_version_ge "2.8"
29+
then
30+
PUT_FILE="/data/put_2.8.son"
31+
resource_put "$_BIND_BASE_PATH/fixture" "$PUT_FILE" "frontend=test_frontend&force_reload=true"
32+
assert_equal "$SC" 200
33+
34+
resource_get "$_BIND_BASE_PATH/fixture" "frontend=test_frontend&force_reload=true"
35+
assert_equal "$SC" 200
36+
assert_equal "$(get_json_path "$BODY" '.data')" "$(cat "$BATS_TEST_DIRNAME/$PUT_FILE")"
37+
fi
38+
}

e2e/tests/global/data/haproxy_2.8.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ global
77
stats socket /var/lib/haproxy/stats level admin
88
tune.ssl.ocsp-update.mindelay 10
99
tune.stick-counters 50
10+
tune.h2.be.initial-window-size 10
11+
tune.h2.be.max-concurrent-streams 11
12+
tune.h2.fe.initial-window-size 12
13+
tune.h2.fe.max-concurrent-streams 13

e2e/tests/global/data/put_2.8.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"runtime_apis": [
3+
{
4+
"address": "/var/lib/haproxy/stats",
5+
"level": "admin"
6+
}
7+
],
8+
"tune_options": {
9+
"h2_be_initial_window_size": 20,
10+
"h2_be_max_concurrent_streams": 21,
11+
"h2_fe_initial_window_size": 22,
12+
"h2_fe_max_concurrent_streams": 23
13+
},
14+
"daemon": "enabled",
15+
"master-worker": true,
16+
"maxconn": 5000,
17+
"pidfile": "/var/run/haproxy.pid"
18+
}

e2e/tests/global/get.bats

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ load 'utils/_helpers'
3333
assert_equal "$(get_json_path "$BODY" '.data.pidfile')" "/var/run/haproxy.pid"
3434
assert_equal "$(get_json_path "$BODY" '.data.runtime_apis[0].address')" "/var/lib/haproxy/stats"
3535
assert_equal "$(get_json_path "$BODY" '.data.runtime_apis[0].level')" "admin"
36-
if [[ "$HAPROXY_VERSION" == "2.8" ]]; then
36+
if haproxy_version_ge "2.8"; then
3737
assert_equal "$(get_json_path "$BODY" '.data.tune_options.ssl_ocsp_update_min_delay')" "10"
3838
assert_equal "$(get_json_path "$BODY" '.data.tune_options.stick_counters')" "50"
39+
assert_equal "$(get_json_path "$BODY" '.data.tune_options.h2_be_initial_window_size')" "10"
40+
assert_equal "$(get_json_path "$BODY" '.data.tune_options.h2_be_max_concurrent_streams')" "11"
41+
assert_equal "$(get_json_path "$BODY" '.data.tune_options.h2_fe_initial_window_size')" "12"
42+
assert_equal "$(get_json_path "$BODY" '.data.tune_options.h2_fe_max_concurrent_streams')" "13"
3943
fi
4044
}

e2e/tests/global/replace_2.8.bats

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bats
2+
#
3+
# Copyright 2023 HAProxy Technologies
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http:#www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
load '../../libs/dataplaneapi'
19+
load '../../libs/get_json_path'
20+
load '../../libs/haproxy_config_setup'
21+
load '../../libs/resource_client'
22+
load '../../libs/version'
23+
load '../../libs/haproxy_version'
24+
25+
load 'utils/_helpers'
26+
27+
@test "global: Replace a global configuration (>=2.8)" {
28+
if haproxy_version_ge "2.8"
29+
then
30+
resource_put "$_GLOBAL_BASE_PATH" "data/put_2.8.json" ""
31+
assert_equal "$SC" 202
32+
33+
resource_get "$_GLOBAL_BASE_PATH" ""
34+
assert_equal "$SC" 200
35+
assert_equal "$(get_json_path "$BODY" '.data.maxconn')" "5000"
36+
assert_equal "$(get_json_path "$BODY" '.data.daemon')" "enabled"
37+
assert_equal "$(get_json_path "$BODY" '.data.pidfile')" "/var/run/haproxy.pid"
38+
assert_equal "$(get_json_path "$BODY" '.data.runtime_apis[0].address')" "/var/lib/haproxy/stats"
39+
assert_equal "$(get_json_path "$BODY" '.data.runtime_apis[0].level')" "admin"
40+
assert_equal "$(get_json_path "$BODY" '.data.tune_options.h2_be_initial_window_size')" "20"
41+
assert_equal "$(get_json_path "$BODY" '.data.tune_options.h2_be_max_concurrent_streams')" "21"
42+
assert_equal "$(get_json_path "$BODY" '.data.tune_options.h2_fe_initial_window_size')" "22"
43+
assert_equal "$(get_json_path "$BODY" '.data.tune_options.h2_fe_max_concurrent_streams')" "23"
44+
fi
45+
}

0 commit comments

Comments
 (0)