-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: wip: add support to remove database
- Loading branch information
Showing
12 changed files
with
1,183 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Continuous Integration (E2E Testing Checks without metrics database) | ||
|
||
on: | ||
workflow_call: | ||
jobs: | ||
e2e-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout repo from current commit | ||
uses: actions/checkout@v3 | ||
- name: set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: "1.21" | ||
check-latest: true | ||
cache: true | ||
- name: pull pre-built images | ||
run: sudo docker compose -f ci.docker-compose.yml pull | ||
env: | ||
METRIC_DATABASE_ENABLED: "false" | ||
# In this step, this action saves a list of existing images, | ||
# the cache is created without them in the post run. | ||
# It also restores the cache if it exists. | ||
# TODO(yevhenii): this step failed with "No space left on device" error, debug it and enable back | ||
# - name: cache docker images | ||
# uses: satackey/[email protected] | ||
# Ignore the failure of a step and avoid terminating the job. | ||
continue-on-error: true | ||
- name: build and start proxy service and it's dependencies | ||
run: sudo docker compose -f ci.docker-compose.yml up -d --build | ||
- name: wait for proxy service to be running | ||
run: bash ${GITHUB_WORKSPACE}/scripts/wait-for-proxy-service-running.sh | ||
env: | ||
PROXY_CONTAINER_PORT: 7777 | ||
- name: wait for proxy service metric partitions database tables to be created | ||
run: bash ${GITHUB_WORKSPACE}/scripts/wait-for-proxy-service-database-metric-partitions.sh | ||
env: | ||
# needs to be 1 + number of partitions created by /clients/database/migrations/20230523101344_partition_proxied_request_metrics_table.up.sql | ||
MINIMUM_REQUIRED_PARTITIONS: 30 | ||
PROXY_CONTAINER_PORT: 7777 | ||
- name: run e2e tests | ||
run: make e2e-test-no-metrics | ||
- name: print proxy service logs | ||
run: sudo docker compose -f ci.docker-compose.yml logs proxy | ||
# because we especially want the logs if the test(s) fail 😅 | ||
if: always() | ||
# Finally, "Post Run jpribyl/[email protected]", | ||
# which is the process of saving the cache, will be executed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package database | ||
|
||
import ( | ||
"context" | ||
"github.com/stretchr/testify/require" | ||
"github.com/uptrace/bun/migrate" | ||
"testing" | ||
) | ||
|
||
func TestMigrateNoDatabase(t *testing.T) { | ||
migrations, err := Migrate(context.Background(), nil, migrate.Migrations{}, nil) | ||
require.NoError(t, err) | ||
require.Empty(t, migrations) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package database | ||
|
||
import ( | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestDisabledDBCreation(t *testing.T) { | ||
config := PostgresDatabaseConfig{ | ||
DatabaseDisabled: true, | ||
} | ||
db, err := NewPostgresClient(config) | ||
require.NoError(t, err) | ||
require.True(t, db.isDisabled) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package database | ||
|
||
import ( | ||
"context" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestNoDatabaseSave(t *testing.T) { | ||
prm := ProxiedRequestMetric{} | ||
err := prm.Save(context.Background(), nil) | ||
require.NoError(t, err) | ||
} | ||
|
||
func TestNoDatabaseListProxiedRequestMetricsWithPagination(t *testing.T) { | ||
proxiedRequestMetrics, cursor, err := ListProxiedRequestMetricsWithPagination(context.Background(), nil, 0, 0) | ||
require.NoError(t, err) | ||
require.Empty(t, proxiedRequestMetrics) | ||
require.Zero(t, cursor) | ||
} | ||
|
||
func TestNoDatabaseCountAttachedProxiedRequestMetricPartitions(t *testing.T) { | ||
count, err := CountAttachedProxiedRequestMetricPartitions(context.Background(), nil) | ||
require.NoError(t, err) | ||
require.Zero(t, count) | ||
} | ||
|
||
func TestGetLastCreatedAttachedProxiedRequestMetricsPartitionName(t *testing.T) { | ||
partitionName, err := GetLastCreatedAttachedProxiedRequestMetricsPartitionName(context.Background(), nil) | ||
require.NoError(t, err) | ||
require.Empty(t, partitionName) | ||
} | ||
|
||
func TestDeleteProxiedRequestMetricsOlderThanNDays(t *testing.T) { | ||
err := DeleteProxiedRequestMetricsOlderThanNDays(context.Background(), nil, 0) | ||
require.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.