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

Enable the pg_regress tests on staging for PG17 #9978

Merged
merged 67 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 60 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
6a6c819
Add an initial support for v17
a-masterov Nov 27, 2024
745c2ea
Do not fail fast
a-masterov Nov 27, 2024
409ac69
Fix a stupid error
a-masterov Nov 27, 2024
5104196
The next iteration
a-masterov Nov 28, 2024
4412afb
The next iteration
a-masterov Nov 28, 2024
231b6ba
The next iteration
a-masterov Nov 28, 2024
c6588a8
The next iteration
a-masterov Nov 28, 2024
648e5ec
Merge branch 'refs/heads/amasterov/regress-staging-17' into amasterov…
a-masterov Nov 28, 2024
23a3e3e
Merge branch 'main' into amasterov/regress-staging-17
a-masterov Dec 3, 2024
b50f5f1
Change the approach to branch-based
a-masterov Nov 28, 2024
8ef7957
Configure the new endpoint
a-masterov Dec 3, 2024
a9d45a5
Add debug
a-masterov Dec 3, 2024
2631f43
Move branch instead of configuring it
a-masterov Dec 4, 2024
0b634e3
Disable pooled
a-masterov Dec 4, 2024
05d0866
Move the branch creation from Python to workflow
a-masterov Dec 4, 2024
4fa436c
jq issue
a-masterov Dec 5, 2024
30deaeb
add debug
a-masterov Dec 5, 2024
9a7d1f2
Fix a typo
a-masterov Dec 5, 2024
4339421
Fix a typo
a-masterov Dec 5, 2024
d564a77
Fix a typo
a-masterov Dec 5, 2024
07c6388
Add forgotten inputs.
a-masterov Dec 5, 2024
27a8980
x
a-masterov Dec 5, 2024
8527c75
Fix a bash error
a-masterov Dec 5, 2024
d35e450
Fix
a-masterov Dec 5, 2024
00b60f3
Debug
a-masterov Dec 5, 2024
76fe1d6
Debug
a-masterov Dec 5, 2024
043b5ae
Debug
a-masterov Dec 5, 2024
0a3aa6e
Debug
a-masterov Dec 5, 2024
9e8a4bf
Debug
a-masterov Dec 5, 2024
3ed9c0a
Refactoring
a-masterov Dec 5, 2024
72b497f
fix
a-masterov Dec 5, 2024
b3b2260
fix
a-masterov Dec 5, 2024
0ae13bb
Refactor
a-masterov Dec 5, 2024
bc30dc4
Refactor
a-masterov Dec 5, 2024
9c0c810
Fix
a-masterov Dec 5, 2024
03b904e
Change the order
a-masterov Dec 5, 2024
47cac9d
debug
a-masterov Dec 5, 2024
32c173d
debug
a-masterov Dec 5, 2024
58397c4
Move
a-masterov Dec 5, 2024
590581c
Fix the error in output's name
a-masterov Dec 5, 2024
8dd7c4f
Use pretty-print output
a-masterov Dec 5, 2024
4cc719b
Change the branch to delete
a-masterov Dec 5, 2024
8ed4ae8
Fix the branch id to delete
a-masterov Dec 6, 2024
4640e99
Wait operations to finish
a-masterov Dec 6, 2024
6046c2a
Fix for compatibility with jq 1.6
a-masterov Dec 6, 2024
a98c182
Fix an error
a-masterov Dec 6, 2024
451d502
Fix an error
a-masterov Dec 6, 2024
dbe9145
add a limit
a-masterov Dec 6, 2024
51339f6
Merge branch 'refs/heads/main' into amasterov/use-branches-in-regress…
a-masterov Dec 6, 2024
de6aaa1
Roll back changes to python fixtures
a-masterov Dec 6, 2024
0bdb2b1
Fix ruff warnings
a-masterov Dec 6, 2024
82fd651
Merge branch 'main' into amasterov/regress-staging-17
a-masterov Dec 6, 2024
e34c7fc
Merge yml
a-masterov Dec 6, 2024
cd42cb5
Merge branch 'refs/heads/amasterov/use-branches-in-regression-tests' …
a-masterov Dec 6, 2024
53b2299
Fix name
a-masterov Dec 6, 2024
2c32f6b
Fix project-id
a-masterov Dec 6, 2024
8223f40
Fix project-id
a-masterov Dec 6, 2024
a25ba0a
Fix project-id
a-masterov Dec 6, 2024
387a2c2
Remove redundant matrix elem
a-masterov Dec 6, 2024
e1abc73
Merge branch 'main' into amasterov/regress-staging-17
a-masterov Dec 6, 2024
9c80bb3
Remove project-id from the matrix
a-masterov Dec 6, 2024
fd712e1
Add README.md
a-masterov Dec 9, 2024
61bddc0
Do not reattach the endpoint, use default settings instead
a-masterov Dec 9, 2024
6a6a29b
Add a note about PG_VERSION
a-masterov Dec 9, 2024
7bbd26f
Merge branch 'main' into amasterov/regress-staging-17
a-masterov Dec 9, 2024
73bcfda
Use dsn from the `create-branch` action
a-masterov Dec 9, 2024
427a573
Delete unneeded file
a-masterov Dec 9, 2024
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
2 changes: 2 additions & 0 deletions .github/actionlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ config-variables:
- SLACK_UPCOMING_RELEASE_CHANNEL_ID
- DEV_AWS_OIDC_ROLE_ARN
- BENCHMARK_INGEST_TARGET_PROJECTID
- PGREGRESS_PG16_PROJECT_ID
- PGREGRESS_PG17_PROJECT_ID
53 changes: 53 additions & 0 deletions .github/actions/neon-attach-endpoint-to-branch/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: 'Attach an endpoint to the branch'
description: 'Attach an endpoint to the branch'

inputs:
api_key:
description: 'Neon API key'
required: true
project_id:
description: 'ID of the Project to create Branch in'
required: true
api_host:
description: 'Neon API host'
default: console-stage.neon.build
branch_id:
description: 'Branch ID'
required: true
endpoint_id:
description: 'EndPoint ID'
required: true

runs:
using: "composite"
steps:
- name: Attach an endpoint
shell: bash -euxo pipefail {0}
run: |
data=$(jq -nc "{endpoint:{branch_id: \"${BRANCH_ID}\"}}")
for i in {1 10}; do
res=$(curl -X PATCH \
"https://${API_HOST}/api/v2/projects/${PROJECT_ID}/endpoints/${ENDPOINT_ID}" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${API_KEY}" \
--data ${data})
endpoint_id=$(echo $res | jq -r '.endpoint.id')

if [ -z "${endpoint_id}" ] || [ "${endpoint_id}" == "null" ]; then
sleep 1
continue
fi

break
done
if [ -z "${endpoint_id}" ] || [ "${endpoint_id}" == "null" ]; then
echo Cannot bind endpoint id to branch
exit 1
fi
env:
API_HOST: ${{ inputs.api_host }}
API_KEY: ${{ inputs.api_key }}
PROJECT_ID: ${{ inputs.project_id }}
BRANCH_ID: ${{ inputs.branch_id }}
ENDPOINT_ID: ${{ inputs.endpoint_id }}
25 changes: 14 additions & 11 deletions .github/actions/neon-branch-create/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ inputs:
api_host:
description: 'Neon API host'
default: console-stage.neon.build
add_endpoint:
description: 'Add an endpoint or not'
required: false
type: boolean
default: true
outputs:
dsn:
description: 'Created Branch DSN (for main database)'
Expand All @@ -26,22 +31,18 @@ runs:
id: create-branch
shell: bash -euxo pipefail {0}
run: |
for i in $(seq 1 10); do
branch_name="Created by actions/neon-branch-create; GITHUB_RUN_ID=${GITHUB_RUN_ID} at $(date +%s)"
data=$(jq -nc "{branch:{name: \"$branch_name\"}}")
if [ ${{ inputs.add_endpoint }} == "true" ]; then
data=$(echo $data | jq '{branch,endpoints:[{type: "read_write"}]}')
fi
for i in {1..10}; do
branch=$(curl \
"https://${API_HOST}/api/v2/projects/${PROJECT_ID}/branches" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${API_KEY}" \
--data "{
\"branch\": {
\"name\": \"Created by actions/neon-branch-create; GITHUB_RUN_ID=${GITHUB_RUN_ID} at $(date +%s)\"
},
\"endpoints\": [
{
\"type\": \"read_write\"
}
]
}")
--data "$data")

if [ -z "${branch}" ]; then
sleep 1
Expand Down Expand Up @@ -76,6 +77,7 @@ runs:
id: role-name
shell: bash -euxo pipefail {0}
run: |
test ${{inputs.add_endpoint}} == "true" || exit 0
roles=$(curl \
"https://${API_HOST}/api/v2/projects/${PROJECT_ID}/branches/${BRANCH_ID}/roles" \
--fail \
Expand All @@ -97,6 +99,7 @@ runs:
# A shell without `set -x` to not to expose password/dsn in logs
shell: bash -euo pipefail {0}
run: |
test ${{inputs.add_endpoint}} == "true" || exit 0
for i in $(seq 1 10); do
reset_password=$(curl \
"https://${API_HOST}/api/v2/projects/${PROJECT_ID}/branches/${BRANCH_ID}/roles/${ROLE_NAME}/reset_password" \
Expand Down
85 changes: 85 additions & 0 deletions .github/actions/neon-get-connection-uri/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: 'Get connection URI'
description: 'Get the connection URI from project using API'

inputs:
api_key:
description: 'Neon API key'
required: true
project_id:
description: 'ID of the Project to create Branch in'
required: true
api_host:
description: 'Neon API host'
default: console-stage.neon.build
branch_id:
description: 'The branch ID. Defaults to your projects default branch_id if not specified.'
required: false
endpoint_id:
description: 'The endpoint ID. Defaults to the read-write endpoint_id associated with the branch_id if not specified.'
required: false
database_name:
description: 'The database name'
default: 'neondb'
required: false
role_name:
description: 'The role name'
default: 'neondb_owner'
required: false
pooled:
description: 'Use the connection pooler'
type: boolean
default: false
required: false
outputs:
uri:
description: 'Connect URI'
value: ${{ steps.get-uri.outputs.uri }}

runs:
using: "composite"
steps:
- name: Get Endpoint ID
id: get-uri
shell: bash -euxo pipefail {0}
run: |
params='?'
if [ -n "${BRANCH_ID}" ]; then
params="${params}branch_id=${BRANCH_ID}&"
fi
if [ -n "${ENDPOINT_ID}" ]; then
params="${params}endpoint_id=${ENDPOINT_ID}&"
fi
params="${params}database_name=${DATABASE_NAME}&role_name=${ROLE_NAME}&"
params="${params}pooled=${POOLED}"
for i in {1..10}; do
res=$(curl -X GET \
"https://${API_HOST}/api/v2/projects/${PROJECT_ID}/connection_uri${params}" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${API_KEY}")
uri=$(echo $res | jq -r .uri)

if [ -z "${uri}" ] || [ "${uri}" == "null" ]; then
sleep 1
continue
fi

break
done

if [ -z "${uri}" ] || [ "${uri}" == "null" ]; then
echo >&2 "Failed to get uri after 10 attempts"
exit 1
fi

echo "uri=${uri}" >> ${GITHUB_OUTPUT}

env:
API_HOST: ${{ inputs.api_host }}
API_KEY: ${{ inputs.api_key }}
PROJECT_ID: ${{ inputs.project_id }}
BRANCH_ID: ${{inputs.branch_id}}
ENDPOINT_ID: ${{inputs.endpoint_id}}
DATABASE_NAME: ${{inputs.database_name}}
ROLE_NAME: ${{inputs.role_name}}
POOLED: ${{inputs.pooled}}
59 changes: 59 additions & 0 deletions .github/actions/neon-get-endpoint/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: 'Get Endpoint'
description: 'Get Endpoint ID from project using API'

inputs:
api_key:
description: 'Neon API key'
required: true
project_id:
description: 'ID of the Project to create Branch in'
required: true
api_host:
description: 'Neon API host'
default: console-stage.neon.build
outputs:
id:
description: 'Endpoint ID'
value: ${{ steps.get-endpoint.outputs.id }}
branch_id:
description: 'Branch ID'
value: ${{ steps.get-endpoint.outputs.branch_id }}

runs:
using: "composite"
steps:
- name: Get Endpoint ID
id: get-endpoint
shell: bash -euxo pipefail {0}
run: |
for i in {1..10}; do
res=$(curl \
"https://${API_HOST}/api/v2/projects/${PROJECT_ID}/endpoints" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${API_KEY}")

endpoint_id=$(echo $res | jq -r '.endpoints[0].id')
branch_id=$(echo $res | jq -r '.endpoints[0].branch_id')


if [ -z "${endpoint_id}" ] || [ "${endpoint_id}" == "null" ]; then
sleep 1
continue
fi

break
done

if [ -z "${endpoint_id}" ] || [ "${endpoint_id}" == "null" ]; then
echo >&2 "Failed to get endpoint id after 10 attempts"
exit 1
fi

echo "id=${endpoint_id}" >> ${GITHUB_OUTPUT}
echo "branch_id=${branch_id}" >> ${GITHUB_OUTPUT}

env:
API_HOST: ${{ inputs.api_host }}
API_KEY: ${{ inputs.api_key }}
PROJECT_ID: ${{ inputs.project_id }}
52 changes: 52 additions & 0 deletions .github/actions/neon-wait-operations-to-finish/action.yml
a-masterov marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: 'Wait operations to finish'
description: 'Wait operations to finish'

inputs:
api_key:
description: 'Neon API key'
required: true
project_id:
description: 'ID of the Project to create Branch in'
required: true
api_host:
description: 'Neon API host'
default: console-stage.neon.build
timeout:
description: 'Timeout in seconds to wait'
type: integer
default: 180

runs:
using: "composite"
steps:
- name: Wait for operations complete
shell: bash -euxo pipefail {0}
run: |
end_time=$(( $(date +%s) + ${TIMEOUT} ))
while [ "$(date +%s)" -le ${end_time} ]; do
rc=0
operations=$(curl -X GET \
"https://${API_HOST}/api/v2/projects/${PROJECT_ID}/operations?limit=10" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${API_KEY}" \
--fail) || rc=${?}

ongoing_operations=$(echo ${operations} | jq -c '.operations[] | select(.status as $st | ["cancelling", "scheduling", "running"] |index($st))' )

if [ $rc -ne 0 ] || [ -n "${ongoing_operations}" ]; then
sleep 2
continue
fi

break
done
if [ $(date +%s) -gt ${end_time} ]; then
echo Time is out
exit 1
fi
env:
API_HOST: ${{ inputs.api_host }}
API_KEY: ${{ inputs.api_key }}
PROJECT_ID: ${{ inputs.project_id }}
TIMEOUT: ${{ inputs.timeout }}
Loading
Loading