Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): update Kong versions in CI #432

Merged
merged 3 commits into from
Apr 3, 2024
Merged

Conversation

pmalek
Copy link
Member

@pmalek pmalek commented Apr 3, 2024

Update CI with most recent versions of Kong.

This also changes the

  • Kong version requirements in https://github.com/Kong/go-kong/blob/da7d97002cc92a764a80f13d5bcfe134a2924bac/kong/developer_role_service_test.go and https://github.com/Kong/go-kong/blob/da7d97002cc92a764a80f13d5bcfe134a2924bac/kong/developer_service_test.go from <3.7 to <3.5 as developer portal has been removed in that version.

  • Kong version requirements in

    func TestFillPluginDefaults(T *testing.T) {
    // TODO https://github.com/Kong/go-kong/issues/214 this should only skip Enterprise 3.x (with a separate test)
    // not all Enterprise versions.
    SkipWhenEnterprise(T)
    RunWhenKong(T, ">=2.3.0")
    client, err := NewTestClient(nil, nil)
    require.NoError(T, err)
    require.NotNil(T, client)
    tests := []struct {
    name string
    plugin *Plugin
    expected *Plugin
    version string
    }{
    {
    name: "no config no protocols",
    version: ">=3.6.0",
    plugin: &Plugin{
    Name: String("basic-auth"),
    RunOn: String("test"),
    },
    expected: &Plugin{
    Name: String("basic-auth"),
    RunOn: String("test"),
    Config: Configuration{
    "anonymous": nil,
    "hide_credentials": false,
    // NOTE: realm has been introduced in 3.6 basic auth schema
    // https://docs.konghq.com/hub/kong-inc/basic-auth/changelog/#kong-gateway-36x
    "realm": "service",
    },
    Protocols: []*string{String("grpc"), String("grpcs"), String("http"), String("https")},
    Enabled: Bool(true),
    },
    },
    {
    name: "no config no protocols",
    version: "<3.6.0",
    plugin: &Plugin{
    Name: String("basic-auth"),
    RunOn: String("test"),
    },
    expected: &Plugin{
    Name: String("basic-auth"),
    RunOn: String("test"),
    Config: Configuration{
    "anonymous": nil,
    "hide_credentials": false,
    },
    Protocols: []*string{String("grpc"), String("grpcs"), String("http"), String("https")},
    Enabled: Bool(true),
    },
    },
    {
    name: "partial config no protocols",
    version: ">=3.6.0",
    plugin: &Plugin{
    Name: String("basic-auth"),
    Consumer: &Consumer{
    ID: String("3bb9a73c-a467-11ec-b909-0242ac120002"),
    },
    Config: Configuration{
    "hide_credentials": true,
    },
    },
    expected: &Plugin{
    Name: String("basic-auth"),
    Consumer: &Consumer{
    ID: String("3bb9a73c-a467-11ec-b909-0242ac120002"),
    },
    Config: Configuration{
    "anonymous": nil,
    "hide_credentials": true,
    // NOTE: realm has been introduced in 3.6 basic auth schema
    // https://docs.konghq.com/hub/kong-inc/basic-auth/changelog/#kong-gateway-36x
    "realm": "service",
    },
    Protocols: []*string{String("grpc"), String("grpcs"), String("http"), String("https")},
    Enabled: Bool(true),
    },
    },
    {
    name: "partial config no protocols",
    version: "<3.6.0",
    plugin: &Plugin{
    Name: String("basic-auth"),
    Consumer: &Consumer{
    ID: String("3bb9a73c-a467-11ec-b909-0242ac120002"),
    },
    Config: Configuration{
    "hide_credentials": true,
    },
    },
    expected: &Plugin{
    Name: String("basic-auth"),
    Consumer: &Consumer{
    ID: String("3bb9a73c-a467-11ec-b909-0242ac120002"),
    },
    Config: Configuration{
    "anonymous": nil,
    "hide_credentials": true,
    },
    Protocols: []*string{String("grpc"), String("grpcs"), String("http"), String("https")},
    Enabled: Bool(true),
    },
    },
    {
    name: "nested config partial protocols",
    plugin: &Plugin{
    Name: String("request-transformer"),
    Config: Configuration{
    "add": map[string]interface{}{
    "body": []interface{}{},
    "headers": "x-new-header:value",
    "querystring": []interface{}{},
    },
    "append": map[string]interface{}{
    "headers": "x-append-header:value",
    },
    "remove": map[string]interface{}{
    "body": []interface{}{},
    "querystring": "?query=val",
    },
    },
    Enabled: Bool(false),
    Protocols: []*string{String("grpc"), String("grpcs")},
    },
    expected: &Plugin{
    Name: String("request-transformer"),
    Config: Configuration{
    "http_method": nil,
    "add": map[string]interface{}{
    "body": []interface{}{},
    "headers": "x-new-header:value",
    "querystring": []interface{}{},
    },
    "append": map[string]interface{}{
    "body": []interface{}{},
    "headers": "x-append-header:value",
    "querystring": []interface{}{},
    },
    "remove": map[string]interface{}{
    "body": []interface{}{},
    "headers": []interface{}{},
    "querystring": "?query=val",
    },
    "rename": map[string]interface{}{
    "body": []interface{}{},
    "headers": []interface{}{},
    "querystring": []interface{}{},
    },
    "replace": map[string]interface{}{
    "body": []interface{}{},
    "headers": []interface{}{},
    "querystring": []interface{}{},
    "uri": nil,
    },
    },
    Protocols: []*string{String("grpc"), String("grpcs")},
    Enabled: Bool(false),
    },
    },
    }
    for _, tc := range tests {
    name := tc.name
    if tc.version != "" {
    name = fmt.Sprintf("%s (kong %s)", name, tc.version)
    }
    T.Run(name, func(t *testing.T) {
    if tc.version != "" {
    RunWhenKong(t, tc.version)
    }
    p := tc.plugin
    fullSchema, err := client.Plugins.GetFullSchema(defaultCtx, p.Name)
    require.NoError(t, err)
    require.NotNil(t, fullSchema)
    require.NoError(t, FillPluginsDefaults(p, fullSchema))
    if diff := cmp.Diff(p, tc.expected); diff != "" {
    t.Errorf(diff)
    }
    })
    }
    }
    in several subtests. The reason for this change is that realm plugin config field for basic-auth has been introduced in 3.6 and not in 3.7. Re: https://docs.konghq.com/hub/kong-inc/basic-auth/changelog/#kong-gateway-36x

@pmalek pmalek added area/maintenance Cleanup, refactoring, and other maintenance improvements that don't change functionality. area/ci labels Apr 3, 2024
@pmalek pmalek self-assigned this Apr 3, 2024
@pmalek pmalek requested a review from a team as a code owner April 3, 2024 10:57
@pmalek pmalek requested a review from a team April 3, 2024 10:57
@pmalek
Copy link
Member Author

pmalek commented Apr 3, 2024

@GGabriele Any clue why the CI is failing on developer role creation in 3.5 and 3.6 ?

=== RUN   TestDeveloperRoleService
    developer_role_service_test.go:28: 
        	Error Trace:	/home/runner/work/go-kong/go-kong/kong/developer_role_service_test.go:28
        	Error:      	Received unexpected error:
        	            	HTTP status 404 (message: "Not Found")
        	Test:       	TestDeveloperRoleService
    developer_role_service_test.go:29: 
        	Error Trace:	/home/runner/work/go-kong/go-kong/kong/developer_role_service_test.go:29
        	Error:      	Expected value not to be nil.
        	Test:       	TestDeveloperRoleService

@pmalek
Copy link
Member Author

pmalek commented Apr 3, 2024

@flrgh Re this: 8f4d15c

Apparently the dev portal tests should be disabled for <3.5 and not <3.7.


Even with the change that accommodates the above we still have the TestFillPluginDefaults test:

=== RUN   TestFillPluginDefaults/no_config_no_protocols_(kong_<3.7.0)
    plugin_service_test.go:729:   &kong.Plugin{
          	... // 6 identical fields
          	Consumer:      nil,
          	ConsumerGroup: nil,
          	Config: kong.Configuration{
          		"anonymous":        nil,
          		"hide_credentials": bool(false),
        - 		"realm":            string("service"),
          	},
          	Enabled: &true,
          	RunOn:   &"test",
          	... // 3 identical fields
          }
=== RUN   TestFillPluginDefaults/partial_config_no_protocols_(kong_>=3.7.0)
    plugin_service_test.go:719: kong version 3.6.1 not in range >=3.7.0
=== RUN   TestFillPluginDefaults/partial_config_no_protocols_(kong_<3.7.0)
    plugin_service_test.go:729:   &kong.Plugin{
          	... // 6 identical fields
          	Consumer:      &{ID: &"3bb9a73c-a467-11ec-b909-0242ac120002"},
          	ConsumerGroup: nil,
          	Config: kong.Configuration{
          		"anonymous":        nil,
          		"hide_credentials": bool(true),
        - 		"realm":            string("service"),
          	},
          	Enabled: &true,
          	RunOn:   nil,
          	... // 3 identical fields
          }

I wonder where is the default for realm (service) specified.

"realm": "service",

https://github.com/Kong/kong-ee/blame/master/kong/plugins/key-auth/schema.lua#L31 doesn't say anything about it.

@codecov-commenter
Copy link

codecov-commenter commented Apr 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.36%. Comparing base (8f4d15c) to head (67f71c4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #432      +/-   ##
==========================================
+ Coverage   59.34%   59.36%   +0.02%     
==========================================
  Files          71       71              
  Lines        4378     4378              
==========================================
+ Hits         2598     2599       +1     
+ Misses       1170     1168       -2     
- Partials      610      611       +1     
Flag Coverage Δ
2.1 35.60% <ø> (ø)
2.2 48.21% <ø> (ø)
2.3 48.85% <ø> (ø)
2.4 48.90% <ø> (ø)
2.5 48.90% <ø> (ø)
2.6 48.90% <ø> (ø)
2.7 50.61% <ø> (ø)
2.8 50.61% <ø> (ø)
3.0 54.56% <ø> (ø)
3.1 56.21% <ø> (ø)
3.2 56.25% <ø> (ø)
3.3 56.25% <ø> (ø)
3.4 58.65% <ø> (ø)
3.5 56.44% <ø> (?)
3.6 56.44% <ø> (?)
community 43.30% <ø> (ø)
enterprise 57.97% <ø> (+0.02%) ⬆️
integration 59.36% <ø> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pmalek
Copy link
Member Author

pmalek commented Apr 3, 2024

@GGabriele I've updated the description and tests Kong version requirements. PTAL

cc: @flrgh

Copy link
Collaborator

@GGabriele GGabriele left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@pmalek pmalek merged commit a563c04 into main Apr 3, 2024
79 checks passed
@pmalek pmalek deleted the update-ci-kong-versions branch April 3, 2024 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ci area/maintenance Cleanup, refactoring, and other maintenance improvements that don't change functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants