File tree 7 files changed +106
-19
lines changed
7 files changed +106
-19
lines changed Original file line number Diff line number Diff line change @@ -29,9 +29,21 @@ setup() {
29
29
skip
30
30
fi
31
31
32
+ local haproxy_cfg_file=" ${BATS_TEST_DIRNAME} /data/haproxy_*.cfg"
33
+ local haproxy_file_version=" "
34
+
35
+ if ls $haproxy_cfg_file 1> /dev/null 2>&1 ; then
36
+ haproxy_file_version=$( echo $haproxy_cfg_file | sed ' s/.*_\([0-9]\+\.[0-9]\+\)\.cfg/\1/' )
37
+ fi
38
+
39
+ major_file_version=$( echo $haproxy_file_version | cut -d ' .' -f 1)
40
+ minor_file_version=$( echo $haproxy_file_version | cut -d ' .' -f 2)
41
+ major_cfg_version=$( echo $HAPROXY_VERSION | cut -d ' .' -f 1)
42
+ minor_cfg_version=$( echo $HAPROXY_VERSION | cut -d ' .' -f 2)
43
+
32
44
# replace the default haproxy config file
33
- if [ $HAPROXY_VERSION = 2.8 ] && [ -f " ${BATS_TEST_DIRNAME} /data/haproxy_${HAPROXY_VERSION } .cfg" ]; then
34
- run docker cp " ${BATS_TEST_DIRNAME} /data/haproxy_${HAPROXY_VERSION } .cfg" " ${DOCKER_CONTAINER_NAME} :/etc/haproxy/haproxy.cfg"
45
+ if [[ $major_cfg_version -ge $major_file_version && $minor_cfg_version -ge $minor_file_version ]] && [ -f " ${BATS_TEST_DIRNAME} /data/haproxy_${haproxy_file_version } .cfg" ]; then
46
+ run docker cp " ${BATS_TEST_DIRNAME} /data/haproxy_${haproxy_file_version } .cfg" " ${DOCKER_CONTAINER_NAME} :/etc/haproxy/haproxy.cfg"
35
47
elif [ -f " ${BATS_TEST_DIRNAME} /data/haproxy.cfg" ]; then
36
48
run docker cp " ${BATS_TEST_DIRNAME} /data/haproxy.cfg" " ${DOCKER_CONTAINER_NAME} :/etc/haproxy/haproxy.cfg"
37
49
else
Original file line number Diff line number Diff line change 16
16
#
17
17
18
18
load ' ../../libs/dataplaneapi'
19
- load ' ../../libs/get_json_path'
20
- load ' ../../libs/haproxy_config_setup'
19
+ load " ../../libs/get_json_path"
21
20
load ' ../../libs/resource_client'
22
21
load ' ../../libs/version'
22
+ load ' ../../libs/haproxy_config_setup'
23
+ load ' ../../libs/haproxy_version'
23
24
24
25
load ' utils/_helpers'
25
26
26
27
@test " binds: Add a new bind" {
27
- resource_post " $_BIND_BASE_PATH " " data/post.json" " frontend=test_frontend&force_reload=true"
28
- assert_equal " $SC " 201
28
+ if haproxy_version_ge " 2.5"
29
+ then
30
+ resource_post " $_BIND_BASE_PATH " " data/post_2.5.json" " frontend=test_frontend&force_reload=true"
31
+ else
32
+ resource_post " $_BIND_BASE_PATH " " data/post.json" " frontend=test_frontend&force_reload=true"
33
+ fi
34
+ assert_equal " $SC " 201
35
+ if haproxy_version_ge " 2.5"
36
+ then
37
+ resource_get " $_BIND_BASE_PATH /test_bind" " frontend=test_frontend&force_reload=true"
38
+ assert_equal " $SC " 200
39
+ assert_equal " $( get_json_path " $BODY " ' .data.name' ) " " test_bind"
40
+ assert_equal " 1/all" " $( get_json_path " $BODY " " .data.thread" ) "
41
+ fi
29
42
}
Original file line number Diff line number Diff line change
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
8
+ log 127.0.0.1 local2
9
+
10
+ defaults
11
+ mode http
12
+ maxconn 3000
13
+ log global
14
+ option httplog
15
+ option redispatch
16
+ option dontlognull
17
+ option http-server-close
18
+ option forwardfor except 127.0.0.0 /8
19
+ timeout http-request 10s
20
+ timeout check 10s
21
+ timeout connect 10s
22
+ timeout client 1m
23
+ timeout queue 1m
24
+ timeout server 1m
25
+ timeout http-keep-alive 10s
26
+ retries 3
27
+
28
+ frontend test_frontend
29
+ mode tcp
30
+ maxconn 1000
31
+ bind localhost:9000 name fixture thread all
32
+ bind localhost:9090 name loopback thread 1 /1
33
+ bind localhost:9091 name loopback1 thread 1 /1 -1
34
+ option httpclose
35
+
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change 16
16
#
17
17
18
18
load ' ../../libs/dataplaneapi'
19
- load ' ../../libs/get_json_path'
20
- load ' ../../libs/haproxy_config_setup'
19
+ load " ../../libs/get_json_path"
21
20
load ' ../../libs/resource_client'
22
21
load ' ../../libs/version'
22
+ load ' ../../libs/haproxy_config_setup'
23
+ load ' ../../libs/haproxy_version'
23
24
24
25
load ' utils/_helpers'
25
26
26
27
@test " binds: Delete a bind" {
27
28
resource_delete " $_BIND_BASE_PATH /fixture" " frontend=test_frontend&force_reload=true"
28
- assert_equal " $SC " 204
29
+ assert_equal " $SC " 204
29
30
30
- resource_delete " $_BIND_BASE_PATH /loopback" " frontend=test_frontend&force_reload=true"
31
- assert_equal " $SC " 204
31
+ resource_delete " $_BIND_BASE_PATH /loopback" " frontend=test_frontend&force_reload=true"
32
+ assert_equal " $SC " 204
32
33
}
Original file line number Diff line number Diff line change 16
16
#
17
17
18
18
load ' ../../libs/dataplaneapi'
19
- load ' ../../libs/get_json_path'
20
- load ' ../../libs/haproxy_config_setup'
19
+ load " ../../libs/get_json_path"
21
20
load ' ../../libs/resource_client'
22
21
load ' ../../libs/version'
22
+ load ' ../../libs/haproxy_config_setup'
23
+ load ' ../../libs/haproxy_version'
23
24
24
25
load ' utils/_helpers'
25
26
26
27
@test " binds: Return one bind" {
27
- resource_get " $_BIND_BASE_PATH /fixture" " frontend=test_frontend&force_reload=true"
28
- assert_equal " $SC " 200
28
+ resource_get " $_BIND_BASE_PATH /fixture" " frontend=test_frontend&force_reload=true"
29
+ assert_equal " $SC " 200
29
30
assert_equal " $( get_json_path " $BODY " ' .data.name' ) " " fixture"
31
+ if haproxy_version_ge " 2.5"
32
+ then
33
+ assert_equal " all" " $( get_json_path " $BODY " " .data.thread" ) "
34
+ fi
30
35
}
Original file line number Diff line number Diff line change 16
16
#
17
17
18
18
load ' ../../libs/dataplaneapi'
19
- load ' ../../libs/get_json_path'
20
- load ' ../../libs/haproxy_config_setup'
19
+ load " ../../libs/get_json_path"
21
20
load ' ../../libs/resource_client'
22
21
load ' ../../libs/version'
22
+ load ' ../../libs/haproxy_config_setup'
23
+ load ' ../../libs/haproxy_version'
23
24
24
25
load ' utils/_helpers'
25
26
26
27
@test " binds: Return an array of binds" {
27
28
resource_get " $_BIND_BASE_PATH " " frontend=test_frontend"
28
- assert_equal " $SC " 200
29
+ assert_equal " $SC " 200
29
30
30
- assert_equal 2 " $( get_json_path " $BODY " " .data | length" ) "
31
+ if haproxy_version_ge " 2.5"
32
+ then
33
+ assert_equal 3 " $( get_json_path " $BODY " " .data | length" ) "
34
+ else
35
+ assert_equal 2 " $( get_json_path " $BODY " " .data | length" ) "
36
+ fi
31
37
assert_equal " fixture" " $( get_json_path " $BODY " " .data[0].name" ) "
32
38
assert_equal " loopback" " $( get_json_path " $BODY " " .data[1].name" ) "
39
+ if haproxy_version_ge " 2.5"
40
+ then
41
+ assert_equal " all" " $( get_json_path " $BODY " " .data[0].thread" ) "
42
+ assert_equal " 1/1" " $( get_json_path " $BODY " " .data[1].thread" ) "
43
+ assert_equal " loopback1" " $( get_json_path " $BODY " " .data[2].name" ) "
44
+ assert_equal " 1/1-1" " $( get_json_path " $BODY " " .data[2].thread" ) "
45
+ fi
33
46
}
You can’t perform that action at this time.
0 commit comments