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

🎉 Compare versions tool #24421

Merged
merged 4 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
30 changes: 30 additions & 0 deletions tools/internal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,33 @@ This script helps maintain Airbyte's demo instance:
./tools/internal/demo.sh ssh # connects you to the airbyte instance
./tools/internal/demo.sh tunnel # creates a local tunnel so you can access the configurable version of airbyte
```

# `compare_versions.sh`
This script compare records output for two given connector versions

## Usage

```shell
./tools/internal/compare_versions.sh # to run script
```

Config, configured catalog and state files should be saved in `config_files` folder:

config - `/config_files/secrets/config.json`

catalog - `/config_files/configured_catalog.json`

state - `/config_files/state.json` (only if you want start sync with state is required)


- Enter connector name: <conneector-name> [source-twitter]
- Enter first connector version: <first-conneector-version> [0.1.1]
- Enter second connector version: <second-conneector-version> [0.1.2]
- Start sync with state (y/n)? [y/n]
Depend on choose sync will be started with state or without.
State should be present in `/config_files/state.json` to start sync with state.
After 3 wrong tries process will be finished with 1.


If comparing successful and script didn't find difference you get `Records output equal.`
Otherwise you get difference and `Records output not equal.`
49 changes: 49 additions & 0 deletions tools/internal/compare_versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash

# Read input params
read -r -p 'Enter connector name: ' connector
read -r -p 'Enter first connector version: ' version_1
read -r -p 'Enter second connector version: ' version_2

use_state(){
failed=false
for i in $(seq 1 3)
do read -n 1 -r -s -p "Start sync with state (y/n)?" choice
case "$choice" in
y|Y ) failed=false ; return 1 ;;
n|N ) failed=false ; return 0 ;;
* ) printf "\n";;
esac
failed=true
done

if "$failed"; then
echo "Process finished with exit code 1"
exit 1
fi
}

use_state
if [ "$?" -eq 1 ]; then
state_status="with"
state="/config_files/state.json"
else
state_status="without"
state=""
fi

printf "\nStarting comparing connector %s version %s with version %s %s state:\n" "$connector" "$version_1" "$version_2" "$state_status"

run_docker_image()
{
docker run --pull=missing --rm -v $(pwd)/config_files:/config_files airbyte/"$connector":"$1" read --config /config_files/secrets/config.json --catalog /config_files/configured_catalog.json --state "$state"
}

result=$( diff <(run_docker_image "$version_1") <(run_docker_image "$version_2") | grep -E 'RECORD|STATE' | sed '/\"emitted_at\"/,/}/ d')

if [ -n "$result" ]; then
printf "%s\n" "$result"
printf "Records output not equal."
else
printf "Records output equal."
fi