Skip to content

Commit 6515926

Browse files
chore: add Forward Output test case
Signed-off-by: Davide Rossi <[email protected]>
1 parent c30a55e commit 6515926

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Copyright © 2019 Banzai Cloud
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package output_test
16+
17+
import (
18+
"testing"
19+
20+
"github.com/ghodss/yaml"
21+
"github.com/kube-logging/logging-operator/pkg/sdk/logging/model/output"
22+
"github.com/kube-logging/logging-operator/pkg/sdk/logging/model/render"
23+
"github.com/stretchr/testify/require"
24+
)
25+
26+
func TestForward(t *testing.T) {
27+
CONFIG := []byte(`
28+
servers:
29+
- host: 192.168.1.3
30+
name: myserver1
31+
port: 24224
32+
weight: 60
33+
- host: 192.168.1.4
34+
name: myserver2
35+
port: 24223
36+
weight: 40
37+
buffer:
38+
timekey: 1m
39+
timekey_wait: 30s
40+
timekey_use_utc: true
41+
keepalive: true
42+
keepalive_timeout: 20
43+
time_as_integer: true
44+
send_timeout: 60
45+
`)
46+
expected := `
47+
<match **>
48+
@type forward
49+
@id test
50+
keepalive true
51+
keepalive_timeout 20
52+
send_timeout 60
53+
time_as_integer true
54+
<buffer tag,time>
55+
@type file
56+
path /buffers/test.*.buffer
57+
retry_forever true
58+
timekey 1m
59+
timekey_use_utc true
60+
timekey_wait 30s
61+
</buffer>
62+
<server>
63+
host 192.168.1.3
64+
name myserver1
65+
port 24224
66+
weight 60
67+
</server>
68+
<server>
69+
host 192.168.1.4
70+
name myserver2
71+
port 24223
72+
weight 40
73+
</server>
74+
</match>
75+
`
76+
g := &output.ForwardOutput{}
77+
require.NoError(t, yaml.Unmarshal(CONFIG, g))
78+
test := render.NewOutputPluginTest(t, g)
79+
test.DiffResult(expected)
80+
}

0 commit comments

Comments
 (0)