Skip to content

Commit

Permalink
feat: test no metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
boodyvo committed Sep 12, 2024
1 parent afa086d commit 6ac2ee2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-e2e-no-metrics-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: pull pre-built images
run: sudo docker compose -f ci.docker-compose.yml pull
- name: build and start proxy service and it's dependencies
run: METRIC_DATABASE_ENABLED=false sudo docker compose -f ci.docker-compose.yml up -d --build proxy redis
run: echo "METRIC_DATABASE_ENABLED=$METRIC_DATABASE_ENABLED" && METRIC_DATABASE_ENABLED=false sudo docker compose -f ci.docker-compose.yml up -d --build proxy redis
env:
METRIC_DATABASE_ENABLED: false
- name: wait for proxy service to be running
Expand Down
2 changes: 1 addition & 1 deletion ci.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
dockerfile: ci.Dockerfile
env_file: .env
environment:
METRIC_DATABASE_ENABLED: "${METRIC_DATABASE_ENABLED:-true}"
PROXY_HEIGHT_BASED_ROUTING_ENABLED: "true"
PROXY_SHARDED_ROUTING_ENABLED: "true"
# use public testnet as backend origin server to avoid having
Expand All @@ -32,7 +33,6 @@ services:
# fake the shards by defining shards with existing backends
PROXY_SHARD_BACKEND_HOST_URL_MAP: localhost:7777>10|https://evmrpcdata.internal.testnet.proxy.kava.io|20|https://evmrpcdata.internal.testnet.proxy.kava.io
EVM_QUERY_SERVICE_URL: https://evmrpc.internal.testnet.proxy.kava.io
METRIC_DATABASE_ENABLED: "false"
ports:
- "${PROXY_HOST_PORT}:${PROXY_CONTAINER_PORT}"
- "${TEST_UNCONFIGURED_PROXY_PORT}:${PROXY_CONTAINER_PORT}"
Expand Down
4 changes: 4 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1217,6 +1217,10 @@ func cleanUpRedis(t *testing.T, redisClient *redis.Client) {
}

func cleanMetricsDb(t *testing.T, db database.PostgresClient) {
if shouldSkipMetrics() {
return
}

_, err := db.Exec("TRUNCATE proxied_request_metrics;")
require.NoError(t, err)
}
Expand Down
9 changes: 9 additions & 0 deletions routines/metric_partitioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ var (
)

func TestE2ETestMetricPartitioningRoutinePrefillsExpectedPartitionsAfterStartupDelay(t *testing.T) {
if shouldSkipMetrics() {
t.Skip("Skipping test because environment variable SKIP_METRICS is set to true")
}

// prepare
time.Sleep(time.Duration(MetricPartitioningRoutineDelayFirstRunSeconds) * time.Second)

Expand Down Expand Up @@ -93,3 +97,8 @@ func TestUnitTestpartitionsForPeriodReturnsExpectedNumPartitionsWhenPrefillPerio
assert.Nil(t, err)
assert.Equal(t, daysToPrefill, len(actualPartitionsForPeriod))
}

func shouldSkipMetrics() bool {
// Check if the environment variable SKIP_METRICS is set to "true"
return os.Getenv("SKIP_METRICS") == "true"
}

0 comments on commit 6ac2ee2

Please sign in to comment.