Skip to content

Commit

Permalink
chore(deps): bump go-kong to 0.43 (#936)
Browse files Browse the repository at this point in the history
  • Loading branch information
aboudreault authored Jun 7, 2023
1 parent 4f6bd9a commit e57ba6e
Show file tree
Hide file tree
Showing 7 changed files with 425 additions and 14 deletions.
17 changes: 17 additions & 0 deletions file/kong_json_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@
"concurrency": {
"type": "integer"
},
"headers": {
"patternProperties": {
".*": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"healthy": {
"$schema": "http://json-schema.org/draft-04/schema#",
"$ref": "#/definitions/Healthy"
Expand Down Expand Up @@ -1071,6 +1082,9 @@
"$ref": "#/definitions/FTarget"
},
"type": "array"
},
"use_srv_name": {
"type": "boolean"
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -1775,6 +1789,9 @@
"type": "string"
},
"type": "array"
},
"use_srv_name": {
"type": "boolean"
}
},
"additionalProperties": false,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/hashicorp/go-retryablehttp v0.7.2
github.com/hexops/gotextdiff v1.0.3
github.com/imdario/mergo v0.3.16
github.com/kong/go-kong v0.42.0
github.com/kong/go-kong v0.43.0
github.com/mitchellh/go-homedir v1.1.0
github.com/shirou/gopsutil/v3 v3.23.4
github.com/spf13/cobra v1.7.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kong/go-kong v0.42.0 h1:N0Rth32eGq6S5x33Txu+Gv9ZJ3gG5noffDjqezwutfA=
github.com/kong/go-kong v0.42.0/go.mod h1:YUq7A3gcwk+9Z1ajwzVY2HnSyL/IKq/TJHsJDqT8hJM=
github.com/kong/go-kong v0.43.0 h1:+PUA6iMOH4JSOoy9AGBiQnBzWjyBYZwrT/RbKmAD+R4=
github.com/kong/go-kong v0.43.0/go.mod h1:jOLA875EFgEZ1phzwRgmm/p34pWh0gg4p8FTC0QuF6w=
github.com/kong/semver/v4 v4.0.1 h1:DIcNR8W3gfx0KabFBADPalxxsp+q/5COwIFkkhrFQ2Y=
github.com/kong/semver/v4 v4.0.1/go.mod h1:LImQ0oT15pJvSns/hs2laLca2zcYoHu5EsSNY0J6/QA=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
Expand Down
38 changes: 36 additions & 2 deletions tests/integration/dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,41 @@ import (
"github.com/stretchr/testify/assert"
)

func Test_Dump_SelectTags(t *testing.T) {
func Test_Dump_SelectTags_30(t *testing.T) {
tests := []struct {
name string
stateFile string
expectedFile string
}{
{
name: "dump with select-tags",
stateFile: "testdata/dump/001-entities-with-tags/kong.yaml",
expectedFile: "testdata/dump/001-entities-with-tags/expected30.yaml",
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
runWhen(t, "kong", ">=3.0.0 <3.1.0")
teardown := setup(t)
defer teardown(t)

assert.NoError(t, sync(tc.stateFile))

output, err := dump(
"--select-tag", "managed-by-deck",
"--select-tag", "org-unit-42",
"-o", "-",
)
assert.NoError(t, err)

expected, err := readFile(tc.expectedFile)
assert.NoError(t, err)
assert.Equal(t, output, expected)
})
}
}

func Test_Dump_SelectTags_3x(t *testing.T) {
tests := []struct {
name string
stateFile string
Expand All @@ -22,7 +56,7 @@ func Test_Dump_SelectTags(t *testing.T) {
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
runWhen(t, "kong", ">=3.0.0")
runWhen(t, "kong", ">=3.1.0")
teardown := setup(t)
defer teardown(t)

Expand Down
142 changes: 133 additions & 9 deletions tests/integration/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,57 @@ var (
},
}

upstream_pre31 = []*kong.Upstream{
{
Name: kong.String("upstream1"),
Algorithm: kong.String("round-robin"),
Slots: kong.Int(10000),
Healthchecks: &kong.Healthcheck{
Threshold: kong.Float64(0),
Active: &kong.ActiveHealthcheck{
Concurrency: kong.Int(10),
Healthy: &kong.Healthy{
HTTPStatuses: []int{200, 302},
Interval: kong.Int(0),
Successes: kong.Int(0),
},
HTTPPath: kong.String("/"),
Type: kong.String("http"),
Timeout: kong.Int(1),
HTTPSVerifyCertificate: kong.Bool(true),
Unhealthy: &kong.Unhealthy{
HTTPFailures: kong.Int(0),
TCPFailures: kong.Int(0),
Timeouts: kong.Int(0),
Interval: kong.Int(0),
HTTPStatuses: []int{429, 404, 500, 501, 502, 503, 504, 505},
},
},
Passive: &kong.PassiveHealthcheck{
Healthy: &kong.Healthy{
HTTPStatuses: []int{
200, 201, 202, 203, 204, 205,
206, 207, 208, 226, 300, 301, 302, 303, 304, 305,
306, 307, 308,
},
Successes: kong.Int(0),
},
Type: kong.String("http"),
Unhealthy: &kong.Unhealthy{
HTTPFailures: kong.Int(0),
TCPFailures: kong.Int(0),
Timeouts: kong.Int(0),
HTTPStatuses: []int{429, 500, 503},
},
},
},
HashOn: kong.String("none"),
HashFallback: kong.String("none"),
HashOnCookiePath: kong.String("/"),
},
}

// latest
upstream = []*kong.Upstream{
{
Name: kong.String("upstream1"),
Expand Down Expand Up @@ -323,6 +374,7 @@ var (
HashOn: kong.String("none"),
HashFallback: kong.String("none"),
HashOnCookiePath: kong.String("/"),
UseSrvName: kong.Bool(false),
},
}

Expand Down Expand Up @@ -1333,7 +1385,7 @@ func Test_Sync_Upstream_Target_Till_1_5_2(t *testing.T) {
name: "creates an upstream and target",
kongFile: "testdata/sync/004-create-upstream-and-target/kong.yaml",
expectedState: utils.KongRawState{
Upstreams: upstream,
Upstreams: upstream_pre31,
Targets: target,
},
},
Expand Down Expand Up @@ -1384,7 +1436,7 @@ func Test_Sync_Upstream_Target_From_2x(t *testing.T) {
name: "creates an upstream and target",
kongFile: "testdata/sync/004-create-upstream-and-target/kong.yaml",
expectedState: utils.KongRawState{
Upstreams: upstream,
Upstreams: upstream_pre31,
Targets: target,
},
},
Expand All @@ -1402,6 +1454,42 @@ func Test_Sync_Upstream_Target_From_2x(t *testing.T) {
}
}

// test scope:
// - 3.0
func Test_Sync_Upstream_Target_From_30(t *testing.T) {
// setup stage
client, err := getTestClient()
if err != nil {
t.Errorf(err.Error())
}

tests := []struct {
name string
kongFile string
expectedState utils.KongRawState
}{
{
name: "creates an upstream and target",
kongFile: "testdata/sync/004-create-upstream-and-target/kong3x.yaml",
expectedState: utils.KongRawState{
Upstreams: upstream_pre31,
Targets: target,
},
},
}

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
runWhen(t, "kong", ">=3.0.0 <3.1.0")
teardown := setup(t)
defer teardown(t)

sync(tc.kongFile)
testKongState(t, client, false, tc.expectedState, nil)
})
}
}

// test scope:
// - 3.x
func Test_Sync_Upstream_Target_From_3x(t *testing.T) {
Expand All @@ -1428,7 +1516,7 @@ func Test_Sync_Upstream_Target_From_3x(t *testing.T) {

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
runWhenKongOrKonnect(t, ">=3.0.0")
runWhenKongOrKonnect(t, ">=3.1.0")
teardown := setup(t)
defer teardown(t)

Expand Down Expand Up @@ -1500,7 +1588,7 @@ func Test_Sync_Upstreams_Target_ZeroWeight_2x(t *testing.T) {
name: "creates an upstream and target with weight equals to zero",
kongFile: "testdata/sync/005-create-upstream-and-target-weight/kong.yaml",
expectedState: utils.KongRawState{
Upstreams: upstream,
Upstreams: upstream_pre31,
Targets: targetZeroWeight,
},
},
Expand All @@ -1518,6 +1606,42 @@ func Test_Sync_Upstreams_Target_ZeroWeight_2x(t *testing.T) {
}
}

// test scope:
// - 3.0
func Test_Sync_Upstreams_Target_ZeroWeight_30(t *testing.T) {
// setup stage
client, err := getTestClient()
if err != nil {
t.Errorf(err.Error())
}

tests := []struct {
name string
kongFile string
expectedState utils.KongRawState
}{
{
name: "creates an upstream and target with weight equals to zero",
kongFile: "testdata/sync/005-create-upstream-and-target-weight/kong3x.yaml",
expectedState: utils.KongRawState{
Upstreams: upstream_pre31,
Targets: targetZeroWeight,
},
},
}

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
runWhen(t, "kong", ">=3.0.0 <3.1.0")
teardown := setup(t)
defer teardown(t)

sync(tc.kongFile)
testKongState(t, client, false, tc.expectedState, nil)
})
}
}

// test scope:
// - 3.x
func Test_Sync_Upstreams_Target_ZeroWeight_3x(t *testing.T) {
Expand All @@ -1544,7 +1668,7 @@ func Test_Sync_Upstreams_Target_ZeroWeight_3x(t *testing.T) {

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
runWhenKongOrKonnect(t, ">=3.0.0")
runWhenKongOrKonnect(t, ">=3.1.0")
teardown := setup(t)
defer teardown(t)

Expand Down Expand Up @@ -1658,7 +1782,7 @@ func Test_Sync_FillDefaults_Earlier_Than_1_5_1(t *testing.T) {
Routes: route1_151,
Plugins: plugin,
Targets: target,
Upstreams: upstream,
Upstreams: upstream_pre31,
},
},
}
Expand Down Expand Up @@ -1695,7 +1819,7 @@ func Test_Sync_FillDefaults_From_2_0_5_To_2_1_4(t *testing.T) {
expectedState: utils.KongRawState{
Services: svc1,
Routes: route1_205_214,
Upstreams: upstream,
Upstreams: upstream_pre31,
Targets: target,
Plugins: plugin,
},
Expand Down Expand Up @@ -1741,7 +1865,7 @@ func Test_Sync_FillDefaults_From_2_2_1_to_2_6_0(t *testing.T) {
expectedState: utils.KongRawState{
Services: svc1,
Routes: route1_20x,
Upstreams: upstream,
Upstreams: upstream_pre31,
Targets: target,
Plugins: plugin,
},
Expand Down Expand Up @@ -1784,7 +1908,7 @@ func Test_Sync_FillDefaults_From_2_6_9(t *testing.T) {
Routes: route1_20x,
Plugins: plugin,
Targets: target,
Upstreams: upstream,
Upstreams: upstream_pre31,
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,4 @@ upstreams:
weight: 100
- target: 198.51.100.13:80
weight: 100
use_srv_name: false
Loading

0 comments on commit e57ba6e

Please sign in to comment.