test admin api key

This commit is contained in:
BodoBolero
2025-01-14 11:33:13 +01:00
parent 306017ebc7
commit 6638abda65
2 changed files with 25 additions and 8 deletions

View File

@@ -17,10 +17,14 @@ inputs:
compute_units:
description: '[Min, Max] compute units'
default: '[1, 1]'
# settings below only needed if you want the project to be sharded from the beginning
shard-split-project:
description: 'by default new projects are not shard-split, specify true to shard-split'
required: false
default: 'false'
admin-api-key:
description: 'Admin API Key needed for shard-splitting. Must be specified if shard-split-project is true'
required: false
shard-count:
description: 'Number of shards to split the project into, only applies if shard-split-project is true'
required: false
@@ -29,6 +33,14 @@ inputs:
description: 'Stripe size, optional, in 8kiB pages. e.g. set 2048 for 16MB stripes. Default is 128 MiB, only applies if shard-split-project is true'
required: false
default: '32768'
psql-path:
description: 'Path to psql binary - it is caller responsibility to provision the psql binary'
required: false
default: '/tmp/neon/pg_install/v16/bin/psql'
libpq-lib-path:
description: 'Path to directory containing libpq library - it is caller responsibility to provision the libpq library'
required: false
default: '/tmp/neon/pg_install/v16/lib'
outputs:
@@ -78,21 +90,24 @@ runs:
echo "Project ${project_id} has been created"
if [ "${SHARD_SPLIT_PROJECT}" = "true" ]; then
# sleep a while
sleep 20
# we need an ADMIN API KEY to invoke storage controller API for shard splitting
if [[ -z "${ADMIN_API_KEY:-}" ]]; then
echo "::error::ADMIN_API_KEY is not set or is empty but shard splitting was requested"
false # Fail the step
fi
# determine tenant ID
TENANT_ID=`${PSQL} ${dsn} -t -A -c "SHOW neon.tenant_id"`
echo "Splitting project ${project_id} with tenant_id ${TENANT_ID} into $((SHARD_COUNT)) shards with stripe size $((STRIPE_SIZE))"
echo "curl -X PUT https://${API_HOST}/regions/${REGION_ID}/api/v1/admin/storage/proxy/control/v1/tenant/${TENANT_ID}/shard_split with body {\"new_shard_count\": $((SHARD_COUNT)), \"new_stripe_size\": $((STRIPE_SIZE))}"
echo "Sending PUT request to https://${API_HOST}/regions/${REGION_ID}/api/v1/admin/storage/proxy/control/v1/tenant/${TENANT_ID}/shard_split"
echo "with body {\"new_shard_count\": $((SHARD_COUNT)), \"new_stripe_size\": $((STRIPE_SIZE))}"
curl -X PUT \
"https://${API_HOST}/regions/${REGION_ID}/api/v1/admin/storage/proxy/control/v1/tenant/${TENANT_ID}/shard_split" \
-H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer ${API_KEY}" \
-H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer ${ADMIN_API_KEY}" \
-d "{\"new_shard_count\": $SHARD_COUNT, \"new_stripe_size\": $STRIPE_SIZE}"
fi
env:
@@ -103,7 +118,8 @@ runs:
MIN_CU: ${{ fromJSON(inputs.compute_units)[0] }}
MAX_CU: ${{ fromJSON(inputs.compute_units)[1] }}
SHARD_SPLIT_PROJECT: ${{ inputs.shard-split-project }}
ADMIN_API_KEY: ${{ inputs.admin_api_key }}
SHARD_COUNT: ${{ inputs.shard-count }}
STRIPE_SIZE: ${{ inputs.stripe-size }}
PSQL: /tmp/neon/pg_install/v16/bin/psql
LD_LIBRARY_PATH: /tmp/neon/pg_install/v16/lib
PSQL: ${{ inputs.psql-path }}
LD_LIBRARY_PATH: ${{ inputs.libpq-lib-path }}

View File

@@ -76,6 +76,7 @@ jobs:
compute_units: '[7, 7]' # we want to test large compute here to avoid compute-side bottleneck
api_key: ${{ secrets.NEON_STAGING_API_KEY }}
shard-split-project: true
admin-api-key: ${{ secrets.NEON_STAGING_ADMIN_API_KEY }}
shard-count: 8
stripe-size: 512