Skip to content

Commit

Permalink
tests: add tests for upstream consumer-groups relationships feature
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Thijs Schreijer <thijs@thijsschreijer.nl>
  • Loading branch information
GGabriele and Tieske committed Feb 8, 2024
1 parent 3ced75c commit 7b5fefb
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 9 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Table of Contents

- [v1.34.0](#v1340)
- [v1.33.0](#v1330)
- [v1.32.1](#v1321)
- [v1.32.0](#v1320)
Expand Down Expand Up @@ -77,6 +78,19 @@
- [v0.2.0](#v020)
- [v0.1.0](#v010)

## [v1.34.0]

> Release date: 2024/02/08
### Fixes

- Correct consumer_groups -> consumers reference and allow importing their relationships
from upstream using `default_lookup_tags`.
[#1212](https://github.com/Kong/deck/pull/1212)
[go-database-reconciler #57](https://github.com/Kong/go-database-reconciler/pull/57)
- CLI fix: error out if `deck file addplugins` gets a `--selector` but no `--config`.
[#1211](https://github.com/Kong/deck/pull/1211)

## [v1.33.0]

> Release date: 2024/02/01
Expand Down Expand Up @@ -1569,6 +1583,7 @@ No breaking changes have been introduced in this release.

Debut release of decK

[v1.34.0]: https://github.com/kong/deck/compare/v1.33.0...v1.34.0
[v1.33.0]: https://github.com/kong/deck/compare/v1.32.1...v1.33.0
[v1.32.1]: https://github.com/kong/deck/compare/v1.32.0...v1.32.1
[v1.32.0]: https://github.com/kong/deck/compare/v1.31.1...v1.32.0
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/fatih/color v1.15.0
github.com/google/go-cmp v0.6.0
github.com/kong/go-apiops v0.1.29
github.com/kong/go-database-reconciler v1.5.0
github.com/kong/go-database-reconciler v1.7.0
github.com/kong/go-kong v0.51.1-0.20240125175037-0c077f5b9ac7
github.com/mitchellh/go-homedir v1.1.0
github.com/spf13/cobra v1.8.0
Expand Down Expand Up @@ -115,8 +115,8 @@ require (
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/term v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.16.1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
Expand Down
11 changes: 6 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ github.com/klauspost/cpuid/v2 v2.2.3 h1:sxCkb+qR91z4vsqw4vGGZlDgPz3G7gjaLyK3V8y7
github.com/klauspost/cpuid/v2 v2.2.3/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
github.com/kong/go-apiops v0.1.29 h1:c+AB8MmGIr+K01Afm4GB2xaOmJnD/8KWMJQkr9qssnc=
github.com/kong/go-apiops v0.1.29/go.mod h1:ZNdiTZyVrAssB4wjEYWV7BfpcV9UME9LxnDDZhMPuNU=
github.com/kong/go-database-reconciler v1.5.0 h1:OHUmFFse5nUqcO7FvChITBK9PoXEhZdw95dE4arlhxs=
github.com/kong/go-database-reconciler v1.5.0/go.mod h1:KtstdZjxNI7+jZJRT896iDsS0Yte1x1sX4B2TaaASgk=
github.com/kong/go-database-reconciler v1.7.0 h1:Nztq15nVwwstqstQYveK+zEgVfA2bSaQh7fdfvlO4fo=
github.com/kong/go-database-reconciler v1.7.0/go.mod h1:A45z0CFwPRMuBfJUlgdfLQw32svOkkjnQfZBNXTiU28=
github.com/kong/go-kong v0.51.1-0.20240125175037-0c077f5b9ac7 h1:/iV93Gwv410lIeJx8VCfCA4fpuvSuTw2LqZpDXsIE9Q=
github.com/kong/go-kong v0.51.1-0.20240125175037-0c077f5b9ac7/go.mod h1:YNkLvjxfOqS+BZ1J2YWOy/83wc26JM5QJbAukoeg1sY=
github.com/kong/go-slugify v1.0.0 h1:vCFAyf2sdoSlBtLcrmDWUFn0ohlpKiKvQfXZkO5vSKY=
Expand Down Expand Up @@ -420,15 +420,16 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE=
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
Expand Down
52 changes: 52 additions & 0 deletions tests/integration/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4863,3 +4863,55 @@ func Test_Sync_LookupRoutesTags(t *testing.T) {
require.Error(t, sync(pluginsLookupStateFile))
require.EqualError(t, err, "building state: route foo for plugin rate-limiting-advanced: entity not found")
}

// test scope:
// - 3.5.0+
// - konnect
func Test_Sync_ConsumerGroupConsumerFromUpstream(t *testing.T) {
t.Setenv("DECK_KONNECT_CONTROL_PLANE_NAME", "default")
runWhenEnterpriseOrKonnect(t, ">=3.4.0")
setup(t)

client, err := getTestClient()
if err != nil {
t.Fatalf(err.Error())
}

expectedState := utils.KongRawState{
ConsumerGroups: []*kong.ConsumerGroupObject{
{
ConsumerGroup: &kong.ConsumerGroup{
ID: kong.String("c0f6c818-470c-4df7-8515-c8e904765fcc"),
Name: kong.String("group-1"),
Tags: kong.StringSlice("project:the-project", "managed-by:deck"),
},
Consumers: []*kong.Consumer{
{
ID: kong.String("97cab250-1b0a-4119-aa2e-0756e8931034"),
Username: kong.String("consumer-1"),
Tags: kong.StringSlice("project:the-project", "managed-by:the-background-process"),
},
},
},
},
Consumers: []*kong.Consumer{
{
ID: kong.String("97cab250-1b0a-4119-aa2e-0756e8931034"),
Username: kong.String("consumer-1"),
Tags: kong.StringSlice("project:the-project", "managed-by:the-background-process"),
},
},
}

// simulate the following scenario:
// - a consumer-group defined with a set of tags, ideally managed by decK
// - a consumer defined with another set of tags, ideally managed by an external process
// - the consumer -> consumer-group relationship, ideally managed by an external process
require.NoError(t, sync("testdata/sync/031-consumer-group-consumers-from-upstream/initial.yaml"))
testKongState(t, client, false, expectedState, nil)

// referencing the relationship in a file without the consumer would still work
// if default_lookup_tags are defined to pull consumers from upstream.
require.NoError(t, sync("testdata/sync/031-consumer-group-consumers-from-upstream/consumer-groups.yaml"))
testKongState(t, client, false, expectedState, nil)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ consumer_groups:
name: silver
consumers:
- username: bar
- username: baz
plugins:
- name: rate-limiting-advanced
config:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
_format_version: "3.0"
_info:
defaults: {}
select_tags:
- project:the-project
- managed-by:deck
default_lookup_tags:
consumers:
- managed-by:the-background-process
- project:the-project
consumer_groups:
- name: group-1
consumers:
- username: consumer-1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
_format_version: "3.0"
consumer_groups:
- id: c0f6c818-470c-4df7-8515-c8e904765fcc
name: group-1
tags:
- project:the-project
- managed-by:deck
consumers:
- id: 97cab250-1b0a-4119-aa2e-0756e8931034
username: consumer-1
groups:
- id: c0f6c818-470c-4df7-8515-c8e904765fcc
name: group-1
tags:
- project:the-project
- managed-by:the-background-process

0 comments on commit 7b5fefb

Please sign in to comment.