-
Notifications
You must be signed in to change notification settings - Fork 92
144 lines (130 loc) · 7.71 KB
/
pg_dump-restore-test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: pg_dump/restore Test Framework
on: [push, pull_request]
jobs:
generate-dump-restore-tests:
name: Generate Dump/Restore Tests
runs-on: ubuntu-20.04
outputs:
dump-restore-path-list: ${{ steps.generate-dump-restore-path.outputs.dump-restore-path-list }}
steps:
- uses: actions/checkout@v2
- name: "Read and setup dump-restore path list from configuration"
id: generate-dump-restore-path
run: |
config="'$(yq -o=json ${{ github.workspace }}/.github/configuration/dump-restore-test-configuration.yml)'"
config=$(echo $config | sed "s/\"/\\\\\"/g")
DUMP_RESTORE_PATH_LIST=$(node -e "let k = JSON.parse($config); \
let p = k['dump-restore-version'].map((itm, index) => ({ id: index, path: itm.map(i => i.version.toString().replace(/[.]/g, \"_\")), \
title: (itm[itm.length - 1]['database-level'] == false ? 'Instance-level-' : 'Database-level-') + itm.map(i => i.version.toString().replace(/[.]/g, \"_\")).join(\"-\"), \
last_version: itm[itm.length - 1].version.toString().replace(/[.]/g, \"_\"), \
dump_method: itm[itm.length - 1]['dump-data-as'] == 'copy' ? 'COPY' : 'INSERTS', \
dump_format: itm[itm.length - 1]['dump-format'], \
type: itm[itm.length - 1]['type']})); \
console.log(JSON.stringify(p));")
echo "::set-output name=dump-restore-path-list::$DUMP_RESTORE_PATH_LIST"
run-dump-restore-test:
needs: generate-dump-restore-tests
strategy:
fail-fast: false
matrix:
upgrade-path: ${{ fromJson(needs.generate-dump-restore-tests.outputs.dump-restore-path-list) }}
name: Dump Restore Test using ${{ matrix.upgrade-path.dump_method }} for ${{ matrix.upgrade-path.title }} - format=${{ matrix.upgrade-path.dump_format }} - type=${{ matrix.upgrade-path.type }}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Install yq - yaml parser
id: install-yq
if: always()
run: sudo snap install yq
- name: Read Base Version and Final Version
id: read-base-and-final-version
if: always() && steps.install-yq.outcome == 'success'
run: >
echo "::set-output name=base-version::$(
yq '."dump-restore-version"[${{ matrix.upgrade-path.id }}][0].version' ${{ github.workspace }}/.github/configuration/dump-restore-test-configuration.yml
)" &&
echo "::set-output name=final-version::$(
yq '."dump-restore-version"[${{ matrix.upgrade-path.id }}][-1].version' ${{ github.workspace }}/.github/configuration/dump-restore-test-configuration.yml
)"
- name: Find Engine and Extension Branches for Base Version ${{ steps.read-base-and-final-version.outputs.base-version }}
id: find-branch
if: always() && steps.read-base-and-final-version.outcome == 'success'
run: >
echo "::set-output name=base-engine-branch::$(
yq '."${{ steps.read-base-and-final-version.outputs.base-version }}".engine_branch' ${{ github.workspace }}/.github/template/version-branch-template.yml
)" &&
echo "::set-output name=base-extension-branch::$(
yq '."${{ steps.read-base-and-final-version.outputs.base-version }}".extension_branch' ${{ github.workspace }}/.github/template/version-branch-template.yml
)" &&
echo "::set-output name=base-dir::$(echo psql$(awk -F. '{print $1}' <<< ${{ steps.read-base-and-final-version.outputs.base-version }}))"
- name: Setup Base Version ${{ steps.read-base-and-final-version.outputs.base-version }} and Run Preparation Tests
id: setup-base-version
if: always() && steps.find-branch.outcome == 'success'
uses: ./.github/composite-actions/setup-base-version
with:
engine_branch: ${{ steps.find-branch.outputs.base-engine-branch }}
extension_branch: ${{ steps.find-branch.outputs.base-extension-branch }}
install_dir: ${{ steps.find-branch.outputs.base-dir }}
migration_mode: 'multi-db'
dump_restore: 'true'
antlr_version: ${{ (steps.read-base-and-final-version.outputs.base-version == 'source.latest' || fromJSON(steps.read-base-and-final-version.outputs.base-version) >= 16.7 ) && '4.13.2' || '4.9.3' }}
- name: Setup Dump Restore Composite Action
id: setup-dump-restore-ca
if: always() && steps.install-yq.outcome == 'success' && steps.setup-base-version.outcome == 'success'
uses: ./.github/composite-actions/setup-dump-restore-ca
with:
base_version: ${{ steps.read-base-and-final-version.outputs.base-version }}
- name: Dump and restore till final version ${{ steps.read-base-and-final-version.outputs.final-version }} and run verify scripts
id: dump-restore-and-test
if: always() && steps.setup-dump-restore-ca.outcome == 'success'
uses: ./.github/composite-actions/dump-restore
- uses: actions/checkout@v2
# Due to some action/checkout's in previous step the dynamically generated dump-restore composite action isn't available,
# hence to avoid error in post action step recreated the dump-restore composite action
- name: Recreate Dump Restore Composite Action
if: always() && steps.install-yq.outcome == 'success' && steps.setup-base-version.outcome == 'success'
uses: ./.github/composite-actions/setup-dump-restore-ca
with:
base_version: ${{ steps.read-base-and-final-version.outputs.base-version }}
- name: Rename Test Summary Files
id: test-file-rename
if: always() && (steps.setup-base-version.outcome == 'failure' || steps.dump-restore-and-test.outcome == 'failure')
run: |
cd ~/work/babelfish_extensions/babelfish_extensions/
cd test/JDBC/Info
timestamp=`ls -Art | tail -n 1`
cd $timestamp
mkdir -p ~/upgrade
cp $timestamp.diff ~/upgrade/output-diff.diff
cp "$timestamp"_runSummary.log ~/upgrade/run-summary.log
mkdir -p ~/failed-testscript-outputs
# copy output files of failed test scripts
BASE_VERSION=${{ steps.read-base-and-final-version.outputs.base-version }}
BASE_VERSION=${BASE_VERSION/./_}
FINAL_VERSION=${{ steps.read-base-and-final-version.outputs.final-version }}
FINAL_VERSION=${FINAL_VERSION/./_}
if [[ "$BASE_VERSION" == *"latest"* ]]; then
BASE_VERSION="latest"
fi
if [[ "$FINAL_VERSION" == *"latest"* ]]; then
FINAL_VERSION="latest"
fi
for f in $(grep "[A-Za-z_\-]*:[ ]*Failed" $timestamp"_runSummary.log" | cut -d ":" -f 1);
do
if [[ -f ../../output/$f".out" ]]; then
cp ../../output/$f".out" ~/failed-testscript-outputs/$f".out"
elif [[ -f ../../output/$BASE_VERSION"__preparation__"$f".out" ]]; then
cp ../../output/$BASE_VERSION"__preparation__"$f".out" ~/failed-testscript-outputs/$BASE_VERSION"__preparation__"$f".out"
else
cp ../../output/$FINAL_VERSION"__verification_cleanup__"$BASE_VERSION"__"$f".out" ~/failed-testscript-outputs/$FINAL_VERSION"__verification_cleanup__"$BASE_VERSION"__"$f".out"
fi
done
- name: Upload Logs
if: always() && (steps.setup-base-version.outcome == 'failure' || steps.dump-restore-and-test.outcome == 'failure')
uses: actions/upload-artifact@v4
with:
name: dump-restore-logs-${{ matrix.upgrade-path.dump_method }}-${{ matrix.upgrade-path.title }}-${{ matrix.upgrade-path.dump_format }}-${{ matrix.upgrade-path.type }}
path: |
~/upgrade/*
~/psql*/data/logfile
~/failed-testscript-outputs