Skip to content

Commit 359f079

Browse files
committed
MEDIUM: ring: implement ring section
1 parent be61642 commit 359f079

29 files changed

+5003
-378
lines changed

configure_data_plane.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,13 @@ func configureAPI(api *operations.DataPlaneAPI) http.Handler {
345345
api.BackendGetBackendsHandler = &handlers.GetBackendsHandlerImpl{Client: client}
346346
api.BackendReplaceBackendHandler = &handlers.ReplaceBackendHandlerImpl{Client: client, ReloadAgent: ra}
347347

348+
// setup ring handlers
349+
api.RingCreateRingHandler = &handlers.CreateRingHandlerImpl{Client: client, ReloadAgent: ra}
350+
api.RingDeleteRingHandler = &handlers.DeleteRingHandlerImpl{Client: client, ReloadAgent: ra}
351+
api.RingGetRingHandler = &handlers.GetRingHandlerImpl{Client: client}
352+
api.RingGetRingsHandler = &handlers.GetRingsHandlerImpl{Client: client}
353+
api.RingReplaceRingHandler = &handlers.ReplaceRingHandlerImpl{Client: client, ReloadAgent: ra}
354+
348355
// setup frontend handlers
349356
api.FrontendCreateFrontendHandler = &handlers.CreateFrontendHandlerImpl{Client: client, ReloadAgent: ra}
350357
api.FrontendDeleteFrontendHandler = &handlers.DeleteFrontendHandlerImpl{Client: client, ReloadAgent: ra}

e2e/tests/rings/data/post.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"description": "My local buffer",
3+
"format": "rfc3164",
4+
"maxlen": 1200,
5+
"name": "test_ring",
6+
"size": 32764,
7+
"timeout_connect": 5,
8+
"timeout_server": 10
9+
}

e2e/tests/rings/data/put.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"description": "My local buffer update",
3+
"format": "iso",
4+
"maxlen": 1400,
5+
"name": "myring2",
6+
"size": 32740,
7+
"timeout_connect": 15,
8+
"timeout_server": 20
9+
}

e2e/tests/rings/test.bats

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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/resource_client'
21+
load '../../libs/version'
22+
23+
load 'utils/_helpers'
24+
25+
@test "rings: Add a ring" {
26+
if haproxy_version_ge "2.1"
27+
then
28+
resource_post "$_RING_BASE_PATH" "data/post.json" "force_reload=true"
29+
assert_equal "$SC" "201"
30+
fi
31+
}
32+
33+
@test "rings: Return a ring" {
34+
if haproxy_version_ge "2.1"
35+
then
36+
resource_get "$_RING_BASE_PATH/test_ring"
37+
assert_equal "$SC" 200
38+
assert_equal "test_ring" "$(get_json_path "$BODY" '.data.name')"
39+
fi
40+
}
41+
42+
@test "rings: Replace a ring" {
43+
if haproxy_version_ge "2.1"
44+
then
45+
resource_put "$_RING_BASE_PATH/test_ring" "data/put.json" "force_reload=true"
46+
assert_equal "$SC" 200
47+
fi
48+
}
49+
50+
@test "rings: Return an array of rings" {
51+
if haproxy_version_ge "2.1"
52+
then
53+
resource_get "$_RING_BASE_PATH"
54+
assert_equal "$SC" 200
55+
assert_equal "test_ring" "$(get_json_path "$BODY" '.data[0].name')"
56+
fi
57+
}
58+
59+
@test "rings: Delete a ring" {
60+
if haproxy_version_ge "2.1"
61+
then
62+
resource_delete "$_RING_BASE_PATH/test_ring" "force_reload=true"
63+
assert_equal "$SC" 204
64+
fi
65+
}
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+
_RING_BASE_PATH="/services/haproxy/configuration/rings"

0 commit comments

Comments
 (0)