Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
addressing more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
GGabriele committed Aug 3, 2022
1 parent 780d9a0 commit 9bf70ef
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 11 deletions.
4 changes: 2 additions & 2 deletions internal/server/kong/ws/config/compat/compatibility_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ var ConfigTableUpdates = map[uint64][]config.ConfigTableUpdates{
},
},
{
Name: "services",
Type: config.CoreService,
Name: config.Service.String(),
Type: config.Service,
RemoveFields: []string{
"enabled",
},
Expand Down
6 changes: 3 additions & 3 deletions internal/server/kong/ws/config/version_compatibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ type UpdateType uint8

const (
Plugin UpdateType = iota
CoreService
Service
)

func (u UpdateType) String() string {
return [...]string{"plugin", "services"}[u]
return [...]string{"plugins", "services"}[u]
}

//nolint: revive
Expand Down Expand Up @@ -228,7 +228,7 @@ func (vc *WSVersionCompatibility) processConfigTableUpdates(uncompressedPayload
case Plugin:
processedPayload = vc.processPluginUpdates(processedPayload,
configTableUpdate, dataPlaneVersion)
case CoreService:
case Service:
processedPayload = vc.processCoreEntityUpdates(processedPayload,
configTableUpdate, dataPlaneVersion)
default:
Expand Down
12 changes: 8 additions & 4 deletions internal/server/kong/ws/config/version_compatibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2223,7 +2223,8 @@ func TestVersionCompatibility_ProcessConfigTableUpdates(t *testing.T) {
configTableUpdates: map[uint64][]ConfigTableUpdates{
3000000000: {
{
Type: CoreService,
Name: Service.String(),
Type: Service,
RemoveFields: []string{
"service_field_1",
},
Expand Down Expand Up @@ -2258,7 +2259,8 @@ func TestVersionCompatibility_ProcessConfigTableUpdates(t *testing.T) {
configTableUpdates: map[uint64][]ConfigTableUpdates{
3000000000: {
{
Type: CoreService,
Name: Service.String(),
Type: Service,
RemoveFields: []string{
"service_field_1",
"service_field_2",
Expand Down Expand Up @@ -2295,7 +2297,8 @@ func TestVersionCompatibility_ProcessConfigTableUpdates(t *testing.T) {
configTableUpdates: map[uint64][]ConfigTableUpdates{
3000000000: {
{
Type: CoreService,
Name: Service.String(),
Type: Service,
RemoveFields: []string{
"service_field_1",
"service_field_2",
Expand Down Expand Up @@ -2343,7 +2346,8 @@ func TestVersionCompatibility_ProcessConfigTableUpdates(t *testing.T) {
configTableUpdates: map[uint64][]ConfigTableUpdates{
3000000000: {
{
Type: CoreService,
Name: Service.String(),
Type: Service,
RemoveFields: []string{
"service_field_1",
"service_field_2",
Expand Down
39 changes: 37 additions & 2 deletions internal/test/e2e/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,14 +615,14 @@ func TestServiceSync(t *testing.T) {

disabledService := disabledService()
disabled, err := json.ProtoJSONMarshal(disabledService)
require.Nil(t, err)
require.NoError(t, err)
res = c.POST("/v1/services").WithBytes(disabled).Expect()
res.Status(http.StatusCreated)

dpCleanup := run.KongDP(kong.GetKongConfForShared())
defer dpCleanup()

require.Nil(t, util.WaitForKongPort(t, 8001))
require.NoError(t, util.WaitForKongPort(t, 8001))

expectedConfig := &v1.TestingConfig{
Services: []*v1.Service{enabledService, {
Expand All @@ -638,6 +638,41 @@ func TestServiceSync(t *testing.T) {
})
}

func TestServiceWithEnabledFieldSync(t *testing.T) {
// ensure that services can be synced to Kong gateway
// and make sure the 'enabled' field is correctly set
kongClient.RunWhenKong(t, ">= 2.7.0")
cleanup := run.Koko(t)
defer cleanup()

enabledService := goodService()
enabledService.Enabled = wrapperspb.Bool(true)
c := httpexpect.New(t, "http://localhost:3000")
res := c.POST("/v1/services").WithJSON(enabledService).Expect()
res.Status(http.StatusCreated)

disabledService := disabledService()
enabledService.Enabled = wrapperspb.Bool(false)
disabled, err := json.ProtoJSONMarshal(disabledService)
require.NoError(t, err)
res = c.POST("/v1/services").WithBytes(disabled).Expect()
res.Status(http.StatusCreated)

dpCleanup := run.KongDP(kong.GetKongConfForShared())
defer dpCleanup()

require.NoError(t, util.WaitForKongPort(t, 8001))

expectedConfig := &v1.TestingConfig{
Services: []*v1.Service{enabledService, disabledService},
}
util.WaitFunc(t, func() error {
err := util.EnsureConfig(expectedConfig)
t.Log("configuration mismatch", err)
return err
})
}

func TestRouteHeader(t *testing.T) {
// ensure that routes with headers can be synced to Kong gateway
// this is done because the data-structures for headers in Koko and Kong
Expand Down

0 comments on commit 9bf70ef

Please sign in to comment.