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

IT GitHub workflow update #872

Merged
merged 6 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Integration tests

on:
# #merge_group:
# push:
# branches: [ "main" ]
push:
branches: [ "main" ]
workflow_dispatch:
inputs:
GIT_REF:
Expand Down Expand Up @@ -44,9 +43,34 @@ jobs:
- name: Set environment variable
run: echo "EXECUTING_ON_GITHUB_CI=true" >> $GITHUB_ENV

- name: Get last commit author
id: get_author
run: echo "::set-output name=author::$(git log -1 --pretty=format:'%an <%ae> sha1={%H}')"

- name: Run integration tests
working-directory: ci/it
# env:
# EXECUTING_ON_GITHUB_CI: true
run: go test -v

- name: Send Slack notification on failure
if: failure()
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
slack-message: |
:exclamation: *Integration tests failed.* :exclamation: @channel
Last commit by: ${{ steps.get_author.outputs.author }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

- name: Send Slack notification on success
if: success()
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
slack-message: |
:white_check_mark: *Integration tests passed.* Good job team!
Last commit by: ${{ steps.get_author.outputs.author }}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}


21 changes: 14 additions & 7 deletions ci/it/testcases/test_reading_clickhouse_tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,39 @@ func (a *ReadingClickHouseTablesIntegrationTestcase) SetupContainers(ctx context
}

func (a *ReadingClickHouseTablesIntegrationTestcase) RunTests(ctx context.Context, t *testing.T) error {
a.testBasicRequest(ctx, t)
a.testRandomThing(ctx, t)
return nil
}

func (a *ReadingClickHouseTablesIntegrationTestcase) testBasicRequest(ctx context.Context, t *testing.T) {
resp, err := a.RequestToQuesma(ctx, "GET", "/", nil)
if err != nil {
t.Fatalf("Failed to make GET request: %s", err)
}
defer resp.Body.Close()
assert.Equal(t, 200, resp.StatusCode)
/*--------*/
}

func (a *ReadingClickHouseTablesIntegrationTestcase) testRandomThing(ctx context.Context, t *testing.T) {
createTableQuery := "CREATE TABLE IF NOT EXISTS test_table (id UInt32, name String) ENGINE = Memory"
if _, err = a.ExecuteClickHouseStatement(ctx, createTableQuery); err != nil {
return err
if _, err := a.ExecuteClickHouseStatement(ctx, createTableQuery); err != nil {
t.Fatalf("Failed to create table: %s", err)
}

insertRowsQuery := "INSERT INTO test_table (id, name) VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie')"
if _, err := a.ExecuteClickHouseStatement(ctx, insertRowsQuery); err != nil {
return err
t.Fatalf("Failed to insert rows: %s", err)
}

// This returns 500 Internal Server Error, but will be tackled in separate PR.
// (The table has not yet been discovered by Quesma )
// ERR quesma/quesma/quesma.go:198 > quesma request failed: Q2002: Missing table. Table: test_table: can't load test_table table opaque_id= path=/test_table/_search reason="Missing table." request_id=01926654-b214-7e1d-944a-a7545cd7d419
resp, err = a.RequestToQuesma(ctx, "GET", "/test_table/_search", []byte(`{"query": {"match_all": {}}}`))
resp, err := a.RequestToQuesma(ctx, "GET", "/test_table/_search", []byte(`{"query": {"match_all": {}}}`))
if err != nil {
t.Fatalf("Failed to make GET request: %s", err)
}
defer resp.Body.Close()
assert.Equal(t, "Clickhouse", resp.Header.Get("X-Quesma-Source"))
//assert.Equal(t, 200, resp.StatusCode)
return nil
assert.Equal(t, 200, resp.StatusCode) // TODO INTENTIONAL FAILURE
}
24 changes: 17 additions & 7 deletions ci/it/testcases/test_transparent_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,23 @@ func (a *TransparentProxyIntegrationTestcase) SetupContainers(ctx context.Contex
}

func (a *TransparentProxyIntegrationTestcase) RunTests(ctx context.Context, t *testing.T) error {
a.testBasicRequest(ctx, t)
a.testIfCatHealthRequestReachesElasticsearch(ctx, t)
a.testIfIndexCreationWorks(ctx, t)
return nil
}

func (a *TransparentProxyIntegrationTestcase) testBasicRequest(ctx context.Context, t *testing.T) {
resp, err := a.RequestToQuesma(ctx, "GET", "/", nil)
if err != nil {
t.Fatalf("Failed to make GET request: %s", err)
}
defer resp.Body.Close()
assert.Equal(t, 200, resp.StatusCode)
/* --------------------------- */
resp, err = a.RequestToQuesma(ctx, "GET", "/_cat/health", nil)
}

func (a *TransparentProxyIntegrationTestcase) testIfCatHealthRequestReachesElasticsearch(ctx context.Context, t *testing.T) {
resp, err := a.RequestToQuesma(ctx, "GET", "/_cat/health", nil)
if err != nil {
t.Fatalf("Failed to make GET request: %s", err)
}
Expand All @@ -48,20 +57,21 @@ func (a *TransparentProxyIntegrationTestcase) RunTests(ctx context.Context, t *t
assert.Equal(t, 200, resp.StatusCode)
assert.Equal(t, "Elasticsearch", resp.Header.Get("X-elastic-product"))
assert.Contains(t, string(bodyBytes), "green")
/* --------------------------- */
_, err = a.RequestToQuesma(ctx, "PUT", "/index_1", nil)
}

func (a *TransparentProxyIntegrationTestcase) testIfIndexCreationWorks(ctx context.Context, t *testing.T) {
_, err := a.RequestToQuesma(ctx, "PUT", "/index_1", nil)
_, err = a.RequestToQuesma(ctx, "PUT", "/index_2", nil)

resp, err = a.RequestToElasticsearch(ctx, "GET", "/_cat/indices", nil)
resp, err := a.RequestToElasticsearch(ctx, "GET", "/_cat/indices", nil)
if err != nil {
t.Fatalf("Failed to make GET request: %s", err)
}
defer resp.Body.Close()
bodyBytes, err = io.ReadAll(resp.Body)
bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
t.Fatalf("Failed to read response body: %s", err)
}
assert.Contains(t, string(bodyBytes), "index_1")
assert.Contains(t, string(bodyBytes), "index_2")
return nil
}
Loading