Skip to content

Commit 37bed62

Browse files
committed
MEDIUM: stats-socket: implement all param
1 parent cd028b4 commit 37bed62

File tree

14 files changed

+968
-166
lines changed

14 files changed

+968
-166
lines changed

e2e/tests/binds/data/post.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"address": "127.0.0.1",
33
"name": "test_bind",
4-
"port": 80
4+
"port": 80,
5+
"defer_accept": true,
6+
"allow_0rtt": true
57
}

e2e/tests/binds/data/put.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
2-
"address": "127.0.0.1",
2+
"level": "user",
33
"name": "fixture",
4+
"address": "127.0.0.1",
45
"port": 8080
56
}

e2e/tests/binds/replace.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ load 'utils/_helpers'
2929

3030
resource_get "$_BIND_BASE_PATH/fixture" "frontend=test_frontend&force_reload=true"
3131
assert_equal "$SC" 200
32-
assert_equal "$(get_json_path "$BODY" '.data')" "$(get_json_path "$(cat "$BATS_TEST_DIRNAME/data/put.json")" ".")"
32+
assert_equal "$(get_json_path "$BODY" '.data')" "$(cat "$BATS_TEST_DIRNAME/data/put.json")"
3333
}

e2e/tests/global/data/haproxy.cfg

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
global
2+
chroot /var/lib/haproxy
3+
user haproxy
4+
group haproxy
5+
maxconn 4000
6+
pidfile /var/run/haproxy.pid
7+
stats socket /var/lib/haproxy/stats level admin

e2e/tests/global/data/put.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"cpu_maps": null,
3+
"runtime_apis": [
4+
{
5+
"address": "/var/run/haproxy/admin.sock",
6+
"level": "admin",
7+
"mode": "660",
8+
"allow_0rtt": true,
9+
"name": "runtime_api_1"
10+
}
11+
],
12+
"daemon": "enabled",
13+
"lua_loads": null,
14+
"lua_prepend_path": null,
15+
"master-worker": true,
16+
"maxconn": 5000,
17+
"pidfile": "/var/run/haproxy/haproxy.pid"
18+
}

e2e/tests/global/get.bats

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bats
2+
#
3+
# Copyright 2021 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+
24+
load 'utils/_helpers'
25+
26+
@test "global: Return a global configuration" {
27+
resource_get "$_GLOBAL_BASE_PATH"
28+
assert_equal "$SC" 200
29+
assert_equal "$(get_json_path "$BODY" '.data.chroot')" "/var/lib/haproxy"
30+
assert_equal "$(get_json_path "$BODY" '.data.user')" "haproxy"
31+
assert_equal "$(get_json_path "$BODY" '.data.group')" "haproxy"
32+
assert_equal "$(get_json_path "$BODY" '.data.maxconn')" "4000"
33+
assert_equal "$(get_json_path "$BODY" '.data.pidfile')" "/var/run/haproxy.pid"
34+
assert_equal "$(get_json_path "$BODY" '.data.runtime_apis[0].address')" "/var/lib/haproxy/stats"
35+
assert_equal "$(get_json_path "$BODY" '.data.runtime_apis[0].level')" "admin"
36+
}

e2e/tests/global/replace.bats

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bats
2+
#
3+
# Copyright 2021 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+
24+
load 'utils/_helpers'
25+
26+
@test "global: Replace a global configuration" {
27+
resource_put "$_GLOBAL_BASE_PATH" "data/put.json" ""
28+
assert_equal "$SC" 202
29+
30+
resource_get "$_GLOBAL_BASE_PATH" ""
31+
assert_equal "$SC" 200
32+
assert_equal "$(get_json_path "$BODY" '.data.maxconn')" "5000"
33+
assert_equal "$(get_json_path "$BODY" '.data.daemon')" "enabled"
34+
assert_equal "$(get_json_path "$BODY" '.data.pidfile')" "/var/run/haproxy/haproxy.pid"
35+
assert_equal "$(get_json_path "$BODY" '.data.runtime_apis[0].address')" "/var/run/haproxy/admin.sock"
36+
assert_equal "$(get_json_path "$BODY" '.data.runtime_apis[0].level')" "admin"
37+
assert_equal "$(get_json_path "$BODY" '.data.runtime_apis[0].mode')" "660"
38+
assert_equal "$(get_json_path "$BODY" '.data.runtime_apis[0].allow_0rtt')" "true"
39+
assert_equal "$(get_json_path "$BODY" '.data.runtime_apis[0].name')" "runtime_api_1"
40+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright 2021 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+
_GLOBAL_BASE_PATH="/services/haproxy/configuration/global"

e2e/tests/sites/data/post.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
"http_connection_mode": "httpclose",
3131
"listeners": [
3232
{
33-
"address": "127.0.0.1",
3433
"name": "site_listener_1",
34+
"address": "127.0.0.1",
3535
"port": 80
3636
},
3737
{
38-
"address": "127.0.0.1",
3938
"name": "site_listener_2",
39+
"address": "127.0.0.1",
4040
"port": 8081
4141
}
4242
],

e2e/tests/sites/data/put.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
"http_connection_mode": "http-keep-alive",
3131
"listeners": [
3232
{
33-
"address": "127.0.0.1",
3433
"name": "site_listener_1",
34+
"address": "127.0.0.1",
3535
"port": 8081
3636
},
3737
{
38-
"address": "127.0.0.1",
3938
"name": "site_listener_2",
39+
"address": "127.0.0.1",
4040
"port": 8082
4141
}
4242
],

0 commit comments

Comments
 (0)