Skip to content

Commit e7a3a04

Browse files
committed
TEST/MINOR: fcgi-app: e2e coverage for CRUD operations
1 parent d64a0fc commit e7a3a04

File tree

10 files changed

+261
-0
lines changed

10 files changed

+261
-0
lines changed

e2e/tests/fcgi_app/create.bats

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bats
2+
#
3+
# Copyright 2022 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 "fcgi-app: Create one new app" {
27+
resource_post "$_FCGIAPP_BASE_PATH" "data/app.json" "force_reload=true"
28+
assert_equal "$SC" 201
29+
30+
resource_get "$_FCGIAPP_BASE_PATH/app_created"
31+
assert_equal "$SC" 200
32+
assert_equal "app_created" "$(get_json_path "$BODY" ".data.name")"
33+
assert_equal "/path/to/chroot" "$(get_json_path "$BODY" ".data.docroot")"
34+
}
35+
36+
@test "fcgi-app: Fail creating app with same name" {
37+
resource_post "$_FCGIAPP_BASE_PATH" "data/app_duplicated.json" "force_reload=true"
38+
assert_equal "$SC" 409
39+
}
40+
41+
@test "fcgi-app: Fail creating app that isn't valid" {
42+
resource_post "$_FCGIAPP_BASE_PATH" "data/app_unvalid.json" "force_reload=true"
43+
assert_equal "$SC" 422
44+
}

e2e/tests/fcgi_app/data/app.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "app_created",
3+
"docroot": "/path/to/chroot",
4+
"index": "index.php",
5+
"log_stderrs": [
6+
{
7+
"global": true
8+
}
9+
]
10+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "test_1",
3+
"docroot": "/path/to/chroot",
4+
"index": "index.php"
5+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "app_created",
3+
"index": "index.php"
4+
}

e2e/tests/fcgi_app/data/haproxy.cfg

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# _version=42
2+
3+
global
4+
log 127.0.0.1 local2
5+
chroot /var/lib/haproxy
6+
pidfile /var/run/haproxy.pid
7+
maxconn 4000
8+
user haproxy
9+
group haproxy
10+
stats socket /var/lib/haproxy/stats level admin
11+
12+
defaults
13+
mode http
14+
log global
15+
option httplog
16+
option dontlognull
17+
option http-server-close
18+
option forwardfor except 127.0.0.0/8
19+
option redispatch
20+
retries 3
21+
timeout http-request 10s
22+
timeout queue 1m
23+
timeout connect 10s
24+
timeout client 1m
25+
timeout server 1m
26+
timeout http-keep-alive 10s
27+
timeout check 10s
28+
maxconn 3000
29+
30+
fcgi-app test_1
31+
docroot /path/to/chroot
32+
index index.php
33+
log-stderr global
34+
35+
fcgi-app test_2
36+
docroot /path/to/chroot
37+
index index.php
38+
log-stderr global

e2e/tests/fcgi_app/delete.bats

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bats
2+
#
3+
# Copyright 2022 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 "fcgi-app: Delete one app by name" {
27+
resource_delete "$_FCGIAPP_BASE_PATH/test_1" "force_reload=true"
28+
assert_equal "$SC" 204
29+
30+
resource_get "$_FCGIAPP_BASE_PATH/test_1"
31+
assert_equal "$SC" 404
32+
}
33+
34+
@test "fcgi-app: Fail deleting app that doesn't exist" {
35+
resource_delete "$_FCGIAPP_BASE_PATH/i_am_not_here" "force_reload=true"
36+
assert_equal "$SC" 404
37+
}

e2e/tests/fcgi_app/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 2022 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 "fcgi-app: Return one app by name" {
27+
resource_get "$_FCGIAPP_BASE_PATH/test_1"
28+
assert_equal "$SC" 200
29+
assert_equal "test_1" "$(get_json_path "$BODY" ".data.name")"
30+
assert_equal "index.php" "$(get_json_path "$BODY" ".data.index")"
31+
}
32+
33+
@test "fcgi-app: Fail returning app that doesn't exist" {
34+
resource_get "$_FCGIAPP_BASE_PATH/i_am_not_here"
35+
assert_equal "$SC" 404
36+
}

e2e/tests/fcgi_app/list.bats

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bats
2+
#
3+
# Copyright 2022 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 "fcgi-app: Return an array of caches" {
27+
resource_get "$_FCGIAPP_BASE_PATH"
28+
assert_equal "$SC" 200
29+
assert_equal 2 "$(get_json_path "$BODY" ".data | length")"
30+
}

e2e/tests/fcgi_app/replace.bats

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bats
2+
#
3+
# Copyright 2022 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 "fcgi-app: Replace one cache" {
27+
resource_put "$_FCGIAPP_BASE_PATH/test_1" "data/app_duplicated.json" "force_reload=true"
28+
assert_equal "$SC" 200
29+
30+
resource_get "$_FCGIAPP_BASE_PATH/test_1"
31+
assert_equal "$SC" 200
32+
assert_equal "test_1" "$(get_json_path "$BODY" ".data.name")"
33+
assert_equal "$(get_json_path "${BODY}" ".data.log_stder | length")" 0
34+
}
35+
36+
@test "fcgi-app: Fail replacing cache that doesn't exist" {
37+
resource_put "$_FCGIAPP_BASE_PATH/i_am_not_here" "data/app_duplicated.json" "force_reload=true"
38+
assert_equal "$SC" 409
39+
}
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 2022 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+
_FCGIAPP_BASE_PATH="/services/haproxy/configuration/fcgi_apps"

0 commit comments

Comments
 (0)