From 8568c9796cc6cb1f30dcec201deaceceafb3c2d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Nowak?= Date: Fri, 25 Oct 2024 20:07:55 +0200 Subject: [PATCH] fix(diff): clear unmatching deprecated fields When user uses decK configuration and they use only new or the old (deprecated) fields then we don't want to display incorrect diff. We used to try to "fill" those fields but sometimes it's impossible to do that. The reason why we need to fill in these fields is that Kong, in order to be backwards compatible sends, both new and old fields. This commit removes either the deprecated or the new fields from the response from Kong before doing the diff so that there is no false negative difference. KAG-5577 --- pkg/diff/diff.go | 14 +- pkg/types/plugin.go | 4 + tests/integration/diff_test.go | 397 ++++++++++++++++++ tests/integration/sync_test.go | 134 ++++++ .../diff/004-plugin-update/initial-ee.yaml | 61 +++ .../kong-ee-changed-new-fields.yaml | 52 +++ .../kong-ee-changed-old-fields.yaml | 44 ++ .../kong-ee-no-change-new-fields.yaml | 52 +++ .../kong-ee-no-change-old-fields.yaml | 45 ++ .../005-deprecated-fields/kong-initial.yaml | 12 + .../kong-no-change-new-fields.yaml | 10 + .../kong-no-change-old-fields.yaml | 9 + .../kong-update-new-fields.yaml | 10 + .../kong-update-old-fields.yaml | 9 + .../035-deprecated-fields/kong-initial.yaml | 12 + .../kong-no-change-new-fields.yaml | 10 + .../kong-no-change-old-fields.yaml | 9 + .../kong-update-new-fields.yaml | 10 + .../kong-update-old-fields.yaml | 9 + 19 files changed, 899 insertions(+), 4 deletions(-) create mode 100644 tests/integration/testdata/diff/004-plugin-update/initial-ee.yaml create mode 100644 tests/integration/testdata/diff/004-plugin-update/kong-ee-changed-new-fields.yaml create mode 100644 tests/integration/testdata/diff/004-plugin-update/kong-ee-changed-old-fields.yaml create mode 100644 tests/integration/testdata/diff/004-plugin-update/kong-ee-no-change-new-fields.yaml create mode 100644 tests/integration/testdata/diff/004-plugin-update/kong-ee-no-change-old-fields.yaml create mode 100644 tests/integration/testdata/diff/005-deprecated-fields/kong-initial.yaml create mode 100644 tests/integration/testdata/diff/005-deprecated-fields/kong-no-change-new-fields.yaml create mode 100644 tests/integration/testdata/diff/005-deprecated-fields/kong-no-change-old-fields.yaml create mode 100644 tests/integration/testdata/diff/005-deprecated-fields/kong-update-new-fields.yaml create mode 100644 tests/integration/testdata/diff/005-deprecated-fields/kong-update-old-fields.yaml create mode 100644 tests/integration/testdata/sync/035-deprecated-fields/kong-initial.yaml create mode 100644 tests/integration/testdata/sync/035-deprecated-fields/kong-no-change-new-fields.yaml create mode 100644 tests/integration/testdata/sync/035-deprecated-fields/kong-no-change-old-fields.yaml create mode 100644 tests/integration/testdata/sync/035-deprecated-fields/kong-update-new-fields.yaml create mode 100644 tests/integration/testdata/sync/035-deprecated-fields/kong-update-old-fields.yaml diff --git a/pkg/diff/diff.go b/pkg/diff/diff.go index 56ca0bb..d5e2c11 100644 --- a/pkg/diff/diff.go +++ b/pkg/diff/diff.go @@ -612,8 +612,7 @@ func (sc *Syncer) Solve(ctx context.Context, parallelism int, dry bool, isJSONOu pluginCopy := &state.Plugin{Plugin: *plugin.DeepCopy()} e.Obj = pluginCopy - exists, err := utils.WorkspaceExists(ctx, sc.kongClient) - if err == nil && exists { + if exists, _ := utils.WorkspaceExists(ctx, sc.kongClient); exists { var schema map[string]interface{} schema, err = sc.kongClient.Plugins.GetFullSchema(ctx, pluginCopy.Plugin.Name) if err != nil { @@ -621,8 +620,7 @@ func (sc *Syncer) Solve(ctx context.Context, parallelism int, dry bool, isJSONOu } // fill defaults and auto fields for the configuration that will be used for the diff - newPlugin := &pluginCopy.Plugin - if err := kong.FillPluginsDefaults(newPlugin, schema); err != nil { + if err := kong.FillPluginsDefaults(&pluginCopy.Plugin, schema); err != nil { return nil, fmt.Errorf("failed processing auto fields: %w", err) } @@ -635,6 +633,14 @@ func (sc *Syncer) Solve(ctx context.Context, parallelism int, dry bool, isJSONOu }); err != nil { return nil, fmt.Errorf("failed processing auto fields: %w", err) } + + if oldPlugin, ok := e.OldObj.(*state.Plugin); ok { + oldPluginCopy := &state.Plugin{Plugin: *oldPlugin.DeepCopy()} + e.OldObj = oldPluginCopy + if err := kong.ClearUnmatchingDeprecations(&pluginCopy.Plugin, &oldPluginCopy.Plugin, schema); err != nil { + return nil, fmt.Errorf("failed processing auto fields: %w", err) + } + } } } diff --git a/pkg/types/plugin.go b/pkg/types/plugin.go index b416438..b1262ce 100644 --- a/pkg/types/plugin.go +++ b/pkg/types/plugin.go @@ -186,6 +186,10 @@ func (d *pluginDiffer) createUpdatePlugin(plugin *state.Plugin) (*crud.Event, er return nil, fmt.Errorf("failed processing auto fields: %w", err) } + if err := kong.ClearUnmatchingDeprecations(&pluginWithDefaults.Plugin, ¤tPlugin.Plugin, schema); err != nil { + return nil, fmt.Errorf("failed clearing unmatching deprecations fields: %w", err) + } + if !currentPlugin.EqualWithOpts(pluginWithDefaults, false, true, false) { return &crud.Event{ Op: crud.Update, diff --git a/tests/integration/diff_test.go b/tests/integration/diff_test.go index e033c00..53c5fec 100644 --- a/tests/integration/diff_test.go +++ b/tests/integration/diff_test.go @@ -454,6 +454,307 @@ Summary: "errors": [] } +` + expectedOutputPluginUpdateNoChange = `Summary: + Created: 0 + Updated: 0 + Deleted: 0 +` + + expectedOutputPluginUpdateChangedNewFields = `updating plugin rate-limiting-advanced (global) { + "config": { + "consumer_groups": null, + "dictionary_name": "kong_rate_limiting_counters", + "disable_penalty": false, + "enforce_consumer_groups": false, + "error_code": 429, + "error_message": "API rate limit exceeded", + "header_name": null, + "hide_client_headers": false, + "identifier": "consumer", + "limit": [ + 10 + ], + "namespace": "ZEz47TWgUrv01HenyQBQa8io06MWsp0L", + "path": null, + "redis": { + "cluster_max_redirections": 5, + "cluster_nodes": [ + { + "ip": "127.0.1.0", +- "port": 6379 ++ "port": 7379 + }, + { + "ip": "127.0.1.0", +- "port": 6380 ++ "port": 7380 + }, + { + "ip": "127.0.1.0", +- "port": 6381 ++ "port": 7381 + } + ], +- "connect_timeout": 2000, ++ "connect_timeout": 2005, + "connection_is_proxied": false, + "database": 0, + "host": "127.0.0.5", + "keepalive_backlog": null, + "keepalive_pool_size": 256, + "password": null, + "port": 6380, +- "read_timeout": 2000, ++ "read_timeout": 2006, +- "send_timeout": 2000, ++ "send_timeout": 2007, + "sentinel_master": "mymaster", + "sentinel_nodes": [ + { + "host": "127.0.2.0", +- "port": 6379 ++ "port": 8379 + }, + { + "host": "127.0.2.0", +- "port": 6380 ++ "port": 8380 + }, + { + "host": "127.0.2.0", +- "port": 6381 ++ "port": 8381 + } + ], + "sentinel_password": null, + "sentinel_role": "master", + "sentinel_username": null, + "server_name": null, + "ssl": false, + "ssl_verify": false, + "username": null + }, + "retry_after_jitter_max": 0, + "strategy": "redis", + "sync_rate": 10, + "window_size": [ + 60 + ], + "window_type": "sliding" + }, + "enabled": true, + "id": "a1368a28-cb5c-4eee-86d8-03a6bdf94b5e", + "name": "rate-limiting-advanced", + "protocols": [ + "grpc", + "grpcs", + "http", + "https" + ] + } + +Summary: + Created: 0 + Updated: 1 + Deleted: 0 +` + expectedOutputPluginUpdateChangedOldFields = `updating plugin rate-limiting-advanced (global) { + "config": { + "consumer_groups": null, + "dictionary_name": "kong_rate_limiting_counters", + "disable_penalty": false, + "enforce_consumer_groups": false, + "error_code": 429, + "error_message": "API rate limit exceeded", + "header_name": null, + "hide_client_headers": false, + "identifier": "consumer", + "limit": [ + 10 + ], + "namespace": "ZEz47TWgUrv01HenyQBQa8io06MWsp0L", + "path": null, + "redis": { + "cluster_addresses": [ +- "127.0.1.0:6379", ++ "127.0.1.0:7379", +- "127.0.1.0:6380", ++ "127.0.1.0:7380", +- "127.0.1.0:6381" ++ "127.0.1.0:7381" + ], + "cluster_max_redirections": 5, + "connect_timeout": 2000, + "connection_is_proxied": false, + "database": 0, + "host": "127.0.0.5", + "keepalive_backlog": null, + "keepalive_pool_size": 256, + "password": null, + "port": 6380, + "read_timeout": 2000, + "send_timeout": 2000, + "sentinel_addresses": [ +- "127.0.2.0:6379", ++ "127.0.2.0:8379", +- "127.0.2.0:6380", ++ "127.0.2.0:8380", +- "127.0.2.0:6381" ++ "127.0.2.0:8381" + ], + "sentinel_master": "mymaster", + "sentinel_password": null, + "sentinel_role": "master", + "sentinel_username": null, + "server_name": null, + "ssl": false, + "ssl_verify": false, +- "timeout": 2000, ++ "timeout": 2007, + "username": null + }, + "retry_after_jitter_max": 0, + "strategy": "redis", +- "sync_rate": 10, ++ "sync_rate": 11, + "window_size": [ + 60 + ], + "window_type": "sliding" + }, + "enabled": true, + "id": "a1368a28-cb5c-4eee-86d8-03a6bdf94b5e", + "name": "rate-limiting-advanced", + "protocols": [ + "grpc", + "grpcs", + "http", + "https" + ] + } + +Summary: + Created: 0 + Updated: 1 + Deleted: 0 +` + + expectedOutputPluginUpdateChangedNewFields36 = `updating plugin rate-limiting (global) { + "config": { + "day": null, + "error_code": 429, + "error_message": "API rate limit exceeded", + "fault_tolerant": true, + "header_name": null, + "hide_client_headers": false, + "hour": 10000, + "limit_by": "consumer", + "minute": null, + "month": null, + "path": null, + "policy": "redis", + "redis": { +- "database": 0, ++ "database": 3, +- "host": "localhost", ++ "host": "localhost-3", + "password": null, + "port": 6379, + "server_name": null, + "ssl": false, + "ssl_verify": false, + "timeout": 2000, + "username": null + }, +- "redis_database": 0, ++ "redis_database": 3, +- "redis_host": "localhost", ++ "redis_host": "localhost-3", + "redis_password": null, + "redis_port": 6379, + "redis_server_name": null, + "redis_ssl": false, + "redis_ssl_verify": false, + "redis_timeout": 2000, + "redis_username": null, + "second": null, + "sync_rate": -1, + "year": null + }, + "enabled": true, + "id": "2705d985-de4b-4ca8-87fd-2b361e30a3e7", + "name": "rate-limiting", + "protocols": [ + "grpc", + "grpcs", + "http", + "https" + ] + } + +Summary: + Created: 0 + Updated: 1 + Deleted: 0 +` + expectedOutputPluginUpdateChangedOldFields36 = `updating plugin rate-limiting (global) { + "config": { + "day": null, + "error_code": 429, + "error_message": "API rate limit exceeded", + "fault_tolerant": true, + "header_name": null, + "hide_client_headers": false, + "hour": 10000, + "limit_by": "consumer", + "minute": null, + "month": null, + "path": null, + "policy": "redis", + "redis": { +- "database": 0, ++ "database": 2, +- "host": "localhost", ++ "host": "localhost-2", + "password": null, + "port": 6379, + "server_name": null, + "ssl": false, + "ssl_verify": false, + "timeout": 2000, + "username": null + }, +- "redis_database": 0, ++ "redis_database": 2, +- "redis_host": "localhost", ++ "redis_host": "localhost-2", + "redis_password": null, + "redis_port": 6379, + "redis_server_name": null, + "redis_ssl": false, + "redis_ssl_verify": false, + "redis_timeout": 2000, + "redis_username": null, + "second": null, + "sync_rate": -1, + "year": null + }, + "enabled": true, + "id": "2705d985-de4b-4ca8-87fd-2b361e30a3e7", + "name": "rate-limiting", + "protocols": [ + "grpc", + "grpcs", + "http", + "https" + ] + } + +Summary: + Created: 0 + Updated: 1 + Deleted: 0 ` ) @@ -742,3 +1043,99 @@ func Test_Diff_Unmasked_NewerThan3x(t *testing.T) { }) } } + +func Test_Diff_PluginUpdate_NewerThan38x(t *testing.T) { + runWhenEnterpriseOrKonnect(t, ">=3.8.0") + setup(t) + + tests := []struct { + name string + initialStateFile string + stateFile string + expectedDiff string + }{ + { + initialStateFile: "testdata/diff/004-plugin-update/initial-ee.yaml", + stateFile: "testdata/diff/004-plugin-update/initial-ee.yaml", + expectedDiff: expectedOutputPluginUpdateNoChange, + }, + { + initialStateFile: "testdata/diff/004-plugin-update/initial-ee.yaml", + stateFile: "testdata/diff/004-plugin-update/kong-ee-no-change-old-fields.yaml", + expectedDiff: expectedOutputPluginUpdateNoChange, + }, + { + initialStateFile: "testdata/diff/004-plugin-update/initial-ee.yaml", + stateFile: "testdata/diff/004-plugin-update/kong-ee-no-change-new-fields.yaml", + expectedDiff: expectedOutputPluginUpdateNoChange, + }, + { + initialStateFile: "testdata/diff/004-plugin-update/initial-ee.yaml", + stateFile: "testdata/diff/004-plugin-update/kong-ee-changed-new-fields.yaml", + expectedDiff: expectedOutputPluginUpdateChangedNewFields, + }, + { + initialStateFile: "testdata/diff/004-plugin-update/initial-ee.yaml", + stateFile: "testdata/diff/004-plugin-update/kong-ee-changed-old-fields.yaml", + expectedDiff: expectedOutputPluginUpdateChangedOldFields, + }, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + // initialize state + assert.NoError(t, sync(tc.initialStateFile)) + + out, err := diff(tc.stateFile) + assert.NoError(t, err) + assert.Equal(t, tc.expectedDiff, out) + }) + } +} + +func Test_Diff_PluginUpdate_OlderThan38x(t *testing.T) { + runWhen(t, "kong", ">=3.6.0 <3.8.0") + setup(t) + + tests := []struct { + name string + initialStateFile string + stateFile string + expectedDiff string + }{ + { + initialStateFile: "testdata/diff/005-deprecated-fields/kong-initial.yaml", + stateFile: "testdata/diff/005-deprecated-fields/kong-initial.yaml", + expectedDiff: expectedOutputPluginUpdateNoChange, + }, + { + initialStateFile: "testdata/diff/005-deprecated-fields/kong-initial.yaml", + stateFile: "testdata/diff/005-deprecated-fields/kong-no-change-old-fields.yaml", + expectedDiff: expectedOutputPluginUpdateNoChange, + }, + { + initialStateFile: "testdata/diff/005-deprecated-fields/kong-initial.yaml", + stateFile: "testdata/diff/005-deprecated-fields/kong-no-change-new-fields.yaml", + expectedDiff: expectedOutputPluginUpdateNoChange, + }, + { + initialStateFile: "testdata/diff/005-deprecated-fields/kong-initial.yaml", + stateFile: "testdata/diff/005-deprecated-fields/kong-update-new-fields.yaml", + expectedDiff: expectedOutputPluginUpdateChangedNewFields36, + }, + { + initialStateFile: "testdata/diff/005-deprecated-fields/kong-initial.yaml", + stateFile: "testdata/diff/005-deprecated-fields/kong-update-old-fields.yaml", + expectedDiff: expectedOutputPluginUpdateChangedOldFields36, + }, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + // initialize state + assert.NoError(t, sync(tc.initialStateFile)) + + out, err := diff(tc.stateFile) + assert.NoError(t, err) + assert.Equal(t, tc.expectedDiff, out) + }) + } +} diff --git a/tests/integration/sync_test.go b/tests/integration/sync_test.go index ad00e60..8e380ad 100644 --- a/tests/integration/sync_test.go +++ b/tests/integration/sync_test.go @@ -5753,3 +5753,137 @@ func Test_Sync_MoreThanOneConsumerGroupForOneConsumer_2_8(t *testing.T) { require.NoError(t, sync("testdata/sync/xxx-more-than-one-consumer-group-with-a-consumer/kong.yaml")) testKongState(t, client, false, expectedState, nil) } + +func Test_Sync_PluginDeprecatedFields36x(t *testing.T) { + runWhen(t, "kong", ">=3.6.0 <3.8.0") + + client, err := getTestClient() + require.NoError(t, err) + + rateLimitingConfigurationInitial := kong.Configuration{ + "day": nil, + "error_code": float64(429), + "error_message": "API rate limit exceeded", + "fault_tolerant": true, + "header_name": nil, + "hide_client_headers": false, + "hour": float64(10000), + "limit_by": string("consumer"), + "minute": nil, + "month": nil, + "path": nil, + "policy": string("redis"), + "redis": map[string]any{ + "database": float64(0), + "host": string("localhost"), + "password": nil, + "port": float64(6379), + "server_name": nil, + "ssl": bool(false), + "ssl_verify": bool(false), + "timeout": float64(2000), + "username": nil, + }, + "redis_database": float64(0), + "redis_host": "localhost", + "redis_password": nil, + "redis_port": float64(6379), + "redis_server_name": nil, + "redis_ssl_verify": bool(false), + "redis_ssl": bool(false), + "redis_timeout": float64(2000), + "redis_username": nil, + "second": nil, + "sync_rate": float64(-1), + "year": nil, + } + + expectedInitialState := utils.KongRawState{ + Plugins: []*kong.Plugin{ + { + ID: kong.String("2705d985-de4b-4ca8-87fd-2b361e30a3e7"), + Name: kong.String("rate-limiting"), + Enabled: kong.Bool(true), + Protocols: []*string{kong.String("grpc"), kong.String("grpcs"), kong.String("http"), kong.String("https")}, + Config: rateLimitingConfigurationInitial, + }, + }, + } + + rateLimitingConfigurationUpdatedOldFields := rateLimitingConfigurationInitial.DeepCopy() + rateLimitingConfigurationUpdatedOldFields["redis_host"] = string("localhost-2") + rateLimitingConfigurationUpdatedOldFields["redis_database"] = float64(2) + rateLimitingConfigurationUpdatedOldFields["redis"].(map[string]interface{})["host"] = string("localhost-2") + rateLimitingConfigurationUpdatedOldFields["redis"].(map[string]interface{})["database"] = float64(2) + + expectedStateAfterChangeUsingOldFields := utils.KongRawState{ + Plugins: []*kong.Plugin{ + { + ID: kong.String("2705d985-de4b-4ca8-87fd-2b361e30a3e7"), + Name: kong.String("rate-limiting"), + Enabled: kong.Bool(true), + Protocols: []*string{kong.String("grpc"), kong.String("grpcs"), kong.String("http"), kong.String("https")}, + Config: rateLimitingConfigurationUpdatedOldFields, + }, + }, + } + + rateLimitingConfigurationUpdatedNewFields := rateLimitingConfigurationInitial.DeepCopy() + rateLimitingConfigurationUpdatedNewFields["redis_host"] = string("localhost-3") + rateLimitingConfigurationUpdatedNewFields["redis_database"] = float64(3) + rateLimitingConfigurationUpdatedNewFields["redis"].(map[string]interface{})["host"] = string("localhost-3") + rateLimitingConfigurationUpdatedNewFields["redis"].(map[string]interface{})["database"] = float64(3) + + expectedStateAfterChangeUsingNewFields := utils.KongRawState{ + Plugins: []*kong.Plugin{ + { + ID: kong.String("2705d985-de4b-4ca8-87fd-2b361e30a3e7"), + Name: kong.String("rate-limiting"), + Enabled: kong.Bool(true), + Protocols: []*string{kong.String("grpc"), kong.String("grpcs"), kong.String("http"), kong.String("https")}, + Config: rateLimitingConfigurationUpdatedNewFields, + }, + }, + } + + tests := []struct { + name string + stateFile string + expectedState utils.KongRawState + }{ + { + name: "initial sync", + stateFile: "testdata/sync/035-deprecated-fields/kong-initial.yaml", + expectedState: expectedInitialState, + }, + { + name: "syncing but not update - using only old (deprecated) fields", + stateFile: "testdata/sync/035-deprecated-fields/kong-no-change-old-fields.yaml", + expectedState: expectedInitialState, + }, + { + name: "syncing but not update - using only new (not deprecated) fields", + stateFile: "testdata/sync/035-deprecated-fields/kong-no-change-new-fields.yaml", + expectedState: expectedInitialState, + }, + { + name: "syncing but with update - using only old (deprecated) fields", + stateFile: "testdata/sync/035-deprecated-fields/kong-update-old-fields.yaml", + expectedState: expectedStateAfterChangeUsingOldFields, + }, + { + name: "syncing but with update - using only new (not deprecated) fields", + stateFile: "testdata/sync/035-deprecated-fields/kong-update-new-fields.yaml", + expectedState: expectedStateAfterChangeUsingNewFields, + }, + } + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + // initialize state + require.NoError(t, sync(tc.stateFile)) + + // test + testKongState(t, client, false, tc.expectedState, nil) + }) + } +} diff --git a/tests/integration/testdata/diff/004-plugin-update/initial-ee.yaml b/tests/integration/testdata/diff/004-plugin-update/initial-ee.yaml new file mode 100644 index 0000000..747ac1b --- /dev/null +++ b/tests/integration/testdata/diff/004-plugin-update/initial-ee.yaml @@ -0,0 +1,61 @@ +_format_version: "3.0" +services: + - name: svc1 + id: 9ecf5708-f2f4-444e-a4c7-fcd3a57f9a6d + host: mockbin.org + tags: + - test +plugins: +- id: a1368a28-cb5c-4eee-86d8-03a6bdf94b5e + enabled: true + name: rate-limiting-advanced + config: + consumer_groups: null + dictionary_name: kong_rate_limiting_counters + disable_penalty: false + enforce_consumer_groups: false + error_code: 429 + error_message: API rate limit exceeded + header_name: null + hide_client_headers: false + identifier: consumer + limit: + - 10 + namespace: ZEz47TWgUrv01HenyQBQa8io06MWsp0L + path: null + redis: + host: 127.0.0.5 + port: 6380 + cluster_addresses: + - 127.0.1.0:6379 + - 127.0.1.0:6380 + - 127.0.1.0:6381 + cluster_nodes: + - ip: 127.0.1.0 + port: 6379 + - ip: 127.0.1.0 + port: 6380 + - ip: 127.0.1.0 + port: 6381 + timeout: 2000 + connect_timeout: 2000 + read_timeout: 2000 + send_timeout: 2000 + sentinel_addresses: + - 127.0.2.0:6379 + - 127.0.2.0:6380 + - 127.0.2.0:6381 + sentinel_master: mymaster + sentinel_nodes: + - host: 127.0.2.0 + port: 6379 + - host: 127.0.2.0 + port: 6380 + - host: 127.0.2.0 + port: 6381 + sentinel_role: master + strategy: redis + sync_rate: 10 + window_size: + - 60 + window_type: sliding diff --git a/tests/integration/testdata/diff/004-plugin-update/kong-ee-changed-new-fields.yaml b/tests/integration/testdata/diff/004-plugin-update/kong-ee-changed-new-fields.yaml new file mode 100644 index 0000000..1d18789 --- /dev/null +++ b/tests/integration/testdata/diff/004-plugin-update/kong-ee-changed-new-fields.yaml @@ -0,0 +1,52 @@ +_format_version: "3.0" +services: + - name: svc1 + id: 9ecf5708-f2f4-444e-a4c7-fcd3a57f9a6d + host: mockbin.org + tags: + - test +plugins: +- id: a1368a28-cb5c-4eee-86d8-03a6bdf94b5e + enabled: true + name: rate-limiting-advanced + config: + consumer_groups: null + dictionary_name: kong_rate_limiting_counters + disable_penalty: false + enforce_consumer_groups: false + error_code: 429 + error_message: API rate limit exceeded + header_name: null + hide_client_headers: false + identifier: consumer + limit: + - 10 + namespace: ZEz47TWgUrv01HenyQBQa8io06MWsp0L + path: null + redis: + host: 127.0.0.5 + port: 6380 + cluster_nodes: + - ip: 127.0.1.0 + port: 7379 + - ip: 127.0.1.0 + port: 7380 + - ip: 127.0.1.0 + port: 7381 + connect_timeout: 2005 + read_timeout: 2006 + send_timeout: 2007 + sentinel_master: mymaster + sentinel_nodes: + - host: 127.0.2.0 + port: 8379 + - host: 127.0.2.0 + port: 8380 + - host: 127.0.2.0 + port: 8381 + sentinel_role: master + strategy: redis + sync_rate: 10 + window_size: + - 60 + window_type: sliding diff --git a/tests/integration/testdata/diff/004-plugin-update/kong-ee-changed-old-fields.yaml b/tests/integration/testdata/diff/004-plugin-update/kong-ee-changed-old-fields.yaml new file mode 100644 index 0000000..8cfced8 --- /dev/null +++ b/tests/integration/testdata/diff/004-plugin-update/kong-ee-changed-old-fields.yaml @@ -0,0 +1,44 @@ +_format_version: "3.0" +services: + - name: svc1 + id: 9ecf5708-f2f4-444e-a4c7-fcd3a57f9a6d + host: mockbin.org + tags: + - test +plugins: +- id: a1368a28-cb5c-4eee-86d8-03a6bdf94b5e + enabled: true + name: rate-limiting-advanced + config: + consumer_groups: null + dictionary_name: kong_rate_limiting_counters + disable_penalty: false + enforce_consumer_groups: false + error_code: 429 + error_message: API rate limit exceeded + header_name: null + hide_client_headers: false + identifier: consumer + limit: + - 10 + namespace: ZEz47TWgUrv01HenyQBQa8io06MWsp0L + path: null + redis: + host: 127.0.0.5 + port: 6380 + cluster_addresses: + - 127.0.1.0:7379 + - 127.0.1.0:7380 + - 127.0.1.0:7381 + timeout: 2007 + sentinel_addresses: + - 127.0.2.0:8379 + - 127.0.2.0:8380 + - 127.0.2.0:8381 + sentinel_master: mymaster + sentinel_role: master + strategy: redis + sync_rate: 11 + window_size: + - 60 + window_type: sliding diff --git a/tests/integration/testdata/diff/004-plugin-update/kong-ee-no-change-new-fields.yaml b/tests/integration/testdata/diff/004-plugin-update/kong-ee-no-change-new-fields.yaml new file mode 100644 index 0000000..77c77aa --- /dev/null +++ b/tests/integration/testdata/diff/004-plugin-update/kong-ee-no-change-new-fields.yaml @@ -0,0 +1,52 @@ +_format_version: "3.0" +services: + - name: svc1 + id: 9ecf5708-f2f4-444e-a4c7-fcd3a57f9a6d + host: mockbin.org + tags: + - test +plugins: +- id: a1368a28-cb5c-4eee-86d8-03a6bdf94b5e + enabled: true + name: rate-limiting-advanced + config: + consumer_groups: null + dictionary_name: kong_rate_limiting_counters + disable_penalty: false + enforce_consumer_groups: false + error_code: 429 + error_message: API rate limit exceeded + header_name: null + hide_client_headers: false + identifier: consumer + limit: + - 10 + namespace: ZEz47TWgUrv01HenyQBQa8io06MWsp0L + path: null + redis: + host: 127.0.0.5 + port: 6380 + cluster_nodes: + - ip: 127.0.1.0 + port: 6379 + - ip: 127.0.1.0 + port: 6380 + - ip: 127.0.1.0 + port: 6381 + connect_timeout: 2000 + read_timeout: 2000 + send_timeout: 2000 + sentinel_master: mymaster + sentinel_nodes: + - host: 127.0.2.0 + port: 6379 + - host: 127.0.2.0 + port: 6380 + - host: 127.0.2.0 + port: 6381 + sentinel_role: master + strategy: redis + sync_rate: 10 + window_size: + - 60 + window_type: sliding diff --git a/tests/integration/testdata/diff/004-plugin-update/kong-ee-no-change-old-fields.yaml b/tests/integration/testdata/diff/004-plugin-update/kong-ee-no-change-old-fields.yaml new file mode 100644 index 0000000..c79aea8 --- /dev/null +++ b/tests/integration/testdata/diff/004-plugin-update/kong-ee-no-change-old-fields.yaml @@ -0,0 +1,45 @@ +_format_version: "3.0" +services: + - name: svc1 + id: 9ecf5708-f2f4-444e-a4c7-fcd3a57f9a6d + host: mockbin.org + tags: + - test +plugins: +- id: a1368a28-cb5c-4eee-86d8-03a6bdf94b5e + enabled: true + name: rate-limiting-advanced + config: + consumer_groups: null + dictionary_name: kong_rate_limiting_counters + disable_penalty: false + enforce_consumer_groups: false + error_code: 429 + error_message: API rate limit exceeded + header_name: null + hide_client_headers: false + identifier: consumer + limit: + - 10 + namespace: ZEz47TWgUrv01HenyQBQa8io06MWsp0L + path: null + redis: + host: 127.0.0.5 + port: 6380 + cluster_addresses: + - 127.0.1.0:6379 + - 127.0.1.0:6380 + - 127.0.1.0:6381 + timeout: 2000 + sentinel_addresses: + - 127.0.2.0:6379 + - 127.0.2.0:6380 + - 127.0.2.0:6381 + sentinel_master: mymaster + sentinel_role: master + strategy: redis + sync_rate: 10 + window_size: + - 60 + window_type: sliding + diff --git a/tests/integration/testdata/diff/005-deprecated-fields/kong-initial.yaml b/tests/integration/testdata/diff/005-deprecated-fields/kong-initial.yaml new file mode 100644 index 0000000..ca2e8df --- /dev/null +++ b/tests/integration/testdata/diff/005-deprecated-fields/kong-initial.yaml @@ -0,0 +1,12 @@ +_format_version: "3.0" +plugins: +- id: 2705d985-de4b-4ca8-87fd-2b361e30a3e7 + name: rate-limiting + config: + hour: 10000 + policy: redis + redis_database: 0 + redis_host: localhost + redis: + database: 0 + host: localhost \ No newline at end of file diff --git a/tests/integration/testdata/diff/005-deprecated-fields/kong-no-change-new-fields.yaml b/tests/integration/testdata/diff/005-deprecated-fields/kong-no-change-new-fields.yaml new file mode 100644 index 0000000..0e3e864 --- /dev/null +++ b/tests/integration/testdata/diff/005-deprecated-fields/kong-no-change-new-fields.yaml @@ -0,0 +1,10 @@ +_format_version: "3.0" +plugins: +- id: 2705d985-de4b-4ca8-87fd-2b361e30a3e7 + name: rate-limiting + config: + hour: 10000 + policy: redis + redis: + database: 0 + host: localhost \ No newline at end of file diff --git a/tests/integration/testdata/diff/005-deprecated-fields/kong-no-change-old-fields.yaml b/tests/integration/testdata/diff/005-deprecated-fields/kong-no-change-old-fields.yaml new file mode 100644 index 0000000..c823a47 --- /dev/null +++ b/tests/integration/testdata/diff/005-deprecated-fields/kong-no-change-old-fields.yaml @@ -0,0 +1,9 @@ +_format_version: "3.0" +plugins: +- id: 2705d985-de4b-4ca8-87fd-2b361e30a3e7 + name: rate-limiting + config: + hour: 10000 + policy: redis + redis_database: 0 + redis_host: localhost diff --git a/tests/integration/testdata/diff/005-deprecated-fields/kong-update-new-fields.yaml b/tests/integration/testdata/diff/005-deprecated-fields/kong-update-new-fields.yaml new file mode 100644 index 0000000..143486b --- /dev/null +++ b/tests/integration/testdata/diff/005-deprecated-fields/kong-update-new-fields.yaml @@ -0,0 +1,10 @@ +_format_version: "3.0" +plugins: +- id: 2705d985-de4b-4ca8-87fd-2b361e30a3e7 + name: rate-limiting + config: + hour: 10000 + policy: redis + redis: + database: 3 + host: localhost-3 \ No newline at end of file diff --git a/tests/integration/testdata/diff/005-deprecated-fields/kong-update-old-fields.yaml b/tests/integration/testdata/diff/005-deprecated-fields/kong-update-old-fields.yaml new file mode 100644 index 0000000..c0b33e7 --- /dev/null +++ b/tests/integration/testdata/diff/005-deprecated-fields/kong-update-old-fields.yaml @@ -0,0 +1,9 @@ +_format_version: "3.0" +plugins: +- id: 2705d985-de4b-4ca8-87fd-2b361e30a3e7 + name: rate-limiting + config: + hour: 10000 + policy: redis + redis_database: 2 + redis_host: localhost-2 diff --git a/tests/integration/testdata/sync/035-deprecated-fields/kong-initial.yaml b/tests/integration/testdata/sync/035-deprecated-fields/kong-initial.yaml new file mode 100644 index 0000000..ca2e8df --- /dev/null +++ b/tests/integration/testdata/sync/035-deprecated-fields/kong-initial.yaml @@ -0,0 +1,12 @@ +_format_version: "3.0" +plugins: +- id: 2705d985-de4b-4ca8-87fd-2b361e30a3e7 + name: rate-limiting + config: + hour: 10000 + policy: redis + redis_database: 0 + redis_host: localhost + redis: + database: 0 + host: localhost \ No newline at end of file diff --git a/tests/integration/testdata/sync/035-deprecated-fields/kong-no-change-new-fields.yaml b/tests/integration/testdata/sync/035-deprecated-fields/kong-no-change-new-fields.yaml new file mode 100644 index 0000000..0e3e864 --- /dev/null +++ b/tests/integration/testdata/sync/035-deprecated-fields/kong-no-change-new-fields.yaml @@ -0,0 +1,10 @@ +_format_version: "3.0" +plugins: +- id: 2705d985-de4b-4ca8-87fd-2b361e30a3e7 + name: rate-limiting + config: + hour: 10000 + policy: redis + redis: + database: 0 + host: localhost \ No newline at end of file diff --git a/tests/integration/testdata/sync/035-deprecated-fields/kong-no-change-old-fields.yaml b/tests/integration/testdata/sync/035-deprecated-fields/kong-no-change-old-fields.yaml new file mode 100644 index 0000000..c823a47 --- /dev/null +++ b/tests/integration/testdata/sync/035-deprecated-fields/kong-no-change-old-fields.yaml @@ -0,0 +1,9 @@ +_format_version: "3.0" +plugins: +- id: 2705d985-de4b-4ca8-87fd-2b361e30a3e7 + name: rate-limiting + config: + hour: 10000 + policy: redis + redis_database: 0 + redis_host: localhost diff --git a/tests/integration/testdata/sync/035-deprecated-fields/kong-update-new-fields.yaml b/tests/integration/testdata/sync/035-deprecated-fields/kong-update-new-fields.yaml new file mode 100644 index 0000000..143486b --- /dev/null +++ b/tests/integration/testdata/sync/035-deprecated-fields/kong-update-new-fields.yaml @@ -0,0 +1,10 @@ +_format_version: "3.0" +plugins: +- id: 2705d985-de4b-4ca8-87fd-2b361e30a3e7 + name: rate-limiting + config: + hour: 10000 + policy: redis + redis: + database: 3 + host: localhost-3 \ No newline at end of file diff --git a/tests/integration/testdata/sync/035-deprecated-fields/kong-update-old-fields.yaml b/tests/integration/testdata/sync/035-deprecated-fields/kong-update-old-fields.yaml new file mode 100644 index 0000000..c0b33e7 --- /dev/null +++ b/tests/integration/testdata/sync/035-deprecated-fields/kong-update-old-fields.yaml @@ -0,0 +1,9 @@ +_format_version: "3.0" +plugins: +- id: 2705d985-de4b-4ca8-87fd-2b361e30a3e7 + name: rate-limiting + config: + hour: 10000 + policy: redis + redis_database: 2 + redis_host: localhost-2