Skip to content

Commit

Permalink
Integration tests for enterprise, deletion of unused env variables in…
Browse files Browse the repository at this point in the history
… community edition integration tests
  • Loading branch information
mmorel-35 committed Apr 26, 2021
1 parent 72405b3 commit cc50af7
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 16 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/integration-test-enterprise.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "Integration Test : Enterprise"

on: [push, pull_request]

jobs:
test:
continue-on-error: true
strategy:
matrix:
kong_version:
- "enterprise-1.3.0.2"
- "enterprise-1.5.0.9"
- "enterprise-2.1.4.4"
- "enterprise-2.2.1.0"
- "enterprise-2.3.2.0"
env:
KONG_VERSION: ${{ matrix.kong_version }}
KONG_ENTERPRISE_REPO_USERNAME: ${{ secrets.KONG_ENTERPRISE_REPO_USERNAME }}
KONG_ENTERPRISE_REPO_PASSSWORD: ${{ secrets.KONG_ENTERPRISE_REPO_PASSSWORD }}
KONG_LICENSE_DATA: ${{ secrets.KONG_LICENSE_DATA }}
KONG_ANONYMOUS_REPORTS: "off"
KONG_ADMIN_TOKEN: kong
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11.6-alpine
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Setup go
uses: actions/setup-go@v2
with:
go-version: "^1.16"
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Postgres
run: |
psql -c 'create database kong;' -U postgres -h 127.0.0.1 -p 5432
psql -c 'create user kong;' -U postgres -h 127.0.0.1 -p 5432
psql -c 'GRANT ALL PRIVILEGES ON DATABASE "kong" to kong;' -U postgres -h 127.0.0.1 -p 5432
- name: Setup Kong
run: make setup-kong
- name: Run tests
run: make integration-test-coverage
- name: Upload Code Coverage
uses: codecov/codecov-action@v1
with:
name: codecov-${{ matrix.kong_version }}
flags: ${{ matrix.kong_version }},integration,enterprise
fail_ci_if_error: true
2 changes: 0 additions & 2 deletions .github/workflows/integration-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ jobs:
- "2.3.0"
env:
KONG_VERSION: ${{ matrix.kong_version }}
KONG_ENTERPRISE_REPO_USERNAME: ${{ secrets.KONG_ENTERPRISE_REPO_USERNAME }}
KONG_ENTERPRISE_REPO_PASSSWORD: ${{ secrets.KONG_ENTERPRISE_REPO_PASSSWORD }}
KONG_LICENSE_DATA: ${{ secrets.KONG_LICENSE_DATA }}
KONG_ANONYMOUS_REPORTS: "off"
runs-on: ubuntu-latest
Expand Down
45 changes: 31 additions & 14 deletions cmd/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ var (
defaultCtx = context.Background()
)

func Test_kongVersion(T *testing.T) {
func Test_kongVersion_Community(T *testing.T) {
kongVersionEnv, _ := os.LookupEnv("KONG_VERSION")
if strings.Contains(kongVersionEnv, "enterprise") {
T.Skip()
}
var expectedVersion = semver.MustParse(kongVersionEnv)
var config = NewTestClientConfig("")
version, err := kongVersion(defaultCtx, config)
Expand All @@ -27,21 +30,35 @@ func Test_kongVersion(T *testing.T) {
assert.NotNil(version)
assert.Equal(version.Major, expectedVersion.Major, "The two version should have the same major")
assert.Equal(version.Minor, expectedVersion.Minor, "The two version should have the same minor")
}

if strings.Contains(kongVersionEnv, "enterprise") {
T.Log("Enterprise test Kong")
client, err := utils.GetKongClient(config)
ws := &kong.Workspace{
Name: kong.String("test"),
}
client.Workspaces.Create(defaultCtx, ws)
config = NewTestClientConfig(*ws.Name)
workspaceversion, err := kongVersion(defaultCtx, config)
assert.Nil(err)
assert.NotNil(workspaceversion)
assert.Equal(workspaceversion.Major, expectedVersion.Major, "The two version should have the same major")
assert.Equal(workspaceversion.Minor, expectedVersion.Minor, "The two version should have the same minor")
func Test_kongVersion_Enterprise(T *testing.T) {
kongVersionEnv, _ := os.LookupEnv("KONG_VERSION")
if !strings.Contains(kongVersionEnv, "enterprise") {
T.Skip()
}
kongVersionEnv = strings.Replace(kongVersionEnv, "enterprise-", "", 1)
var expectedVersion = semver.MustParse(kongVersionEnv)
var config = NewTestClientConfig("")
version, err := kongVersion(defaultCtx, config)
assert := assert.New(T)
assert.Nil(err)
assert.NotNil(version)
assert.Equal(version.Major, expectedVersion.Major, "The two version should have the same major")
assert.Equal(version.Minor, expectedVersion.Minor, "The two version should have the same minor")

client, err := utils.GetKongClient(config)
ws := &kong.Workspace{
Name: kong.String("test"),
}
client.Workspaces.Create(defaultCtx, ws)
config = NewTestClientConfig(*ws.Name)
workspaceversion, err := kongVersion(defaultCtx, config)
assert.Nil(err)
assert.NotNil(workspaceversion)
assert.Equal(workspaceversion.Major, expectedVersion.Major, "The two version should have the same major")
assert.Equal(workspaceversion.Minor, expectedVersion.Minor, "The two version should have the same minor")

}

func NewTestClientConfig(workspace string) utils.KongClientConfig {
Expand Down

0 comments on commit cc50af7

Please sign in to comment.