Skip to content

Commit c0eeed6

Browse files
committed
kcl github workflow
1 parent c504d09 commit c0eeed6

10 files changed

Lines changed: 318 additions & 115 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
aws kinesis delete-stream --stream-name $STREAM_NAME || true
4+
5+
# Delete all tables
6+
for i in {1..10}; do
7+
echo "Deleting table $APP_NAME"
8+
aws dynamodb delete-table --table-name $APP_NAME && break ||
9+
echo "Table deletion failed, attempt $i/10. Retrying DynamoDB Table deletion in $((i * 3)) seconds" && sleep $((i * 3))
10+
done
11+
for SUFFIX in "-CoordinatorState" "-WorkerMetricStats"; do
12+
if aws dynamodb describe-table --table-name $APP_NAME$SUFFIX &>/dev/null; then
13+
echo "Deleting table $APP_NAME$SUFFIX"
14+
for i in {1..10}; do
15+
aws dynamodb delete-table --table-name $APP_NAME$SUFFIX && break ||
16+
echo "Table deletion failed, attempt $i/10. Retrying DynamoDB Table deletion in $((i * 3))s" && sleep $((i * 3))
17+
done
18+
fi
19+
done

.github/scripts/create_stream.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -e
3+
4+
for i in {1..10}; do
5+
if aws kinesis create-stream --stream-name $STREAM_NAME --shard-count 1; then
6+
break
7+
else
8+
echo "Stream creation failed, attempt $i/10. Waiting $((i * 3)) seconds..."
9+
sleep $((i * 3))
10+
fi
11+
done
12+
aws kinesis wait stream-exists --stream-name $STREAM_NAME
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Manipulate sample.properties file that the KCL application pulls properties from (ex: streamName, applicationName)
5+
# Depending on the OS, different properties need to be changed
6+
if [[ "$RUNNER_OS" == "macOS" ]]; then
7+
sed -i "" "s/kclpysample/$STREAM_NAME/g" samples/sample.properties
8+
sed -i "" "s/PythonKCLSample/$APP_NAME/g" samples/sample.properties
9+
sed -i "" 's/us-east-5/us-east-1/g' samples/sample.properties
10+
grep -v "idleTimeBetweenReadsInMillis" samples/sample.properties > samples/temp.properties
11+
echo "idleTimeBetweenReadsInMillis = 250" >> samples/temp.properties
12+
mv samples/temp.properties samples/sample.properties
13+
elif [[ "$RUNNER_OS" == "Linux" || "$RUNNER_OS" == "Windows" ]]; then
14+
sed -i "s/kclpysample/$STREAM_NAME/g" samples/sample.properties
15+
sed -i "s/PythonKCLSample/$APP_NAME/g" samples/sample.properties
16+
sed -i 's/us-east-5/us-east-1/g' samples/sample.properties
17+
sed -i "/idleTimeBetweenReadsInMillis/c\idleTimeBetweenReadsInMillis = 250" samples/sample.properties
18+
19+
if [[ "$RUNNER_OS" == "Windows" ]]; then
20+
echo '@echo off' > samples/run_script.bat
21+
echo 'python %~dp0\sample_kclpy_app.py %*' >> samples/run_script.bat
22+
sed -i 's/executableName = sample_kclpy_app.py/executableName = samples\/run_script.bat/' samples/sample.properties
23+
fi
24+
else
25+
echo "Unknown OS: $RUNNER_OS"
26+
exit 1
27+
fi
28+
29+
cat samples/sample.properties
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -e
3+
4+
sample_kinesis_wordputter.py --stream $STREAM_NAME -w cat -w dog -w bird -w lobster -w octopus
5+
6+
# Get records from stream to verify they exist before continuing
7+
SHARD_ITERATOR=$(aws kinesis get-shard-iterator --stream-name $STREAM_NAME --shard-id shardId-000000000000 --shard-iterator-type TRIM_HORIZON --query 'ShardIterator' --output text)
8+
INITIAL_RECORDS=$(aws kinesis get-records --shard-iterator $SHARD_ITERATOR)
9+
RECORD_COUNT_BEFORE=$(echo $INITIAL_RECORDS | jq '.Records | length')
10+
11+
if [ "$RECORD_COUNT_BEFORE" -eq 0 ]; then
12+
echo "No records found in stream. Test cannot proceed."
13+
exit 1
14+
fi
15+
echo "Found $RECORD_COUNT_BEFORE records in stream before KCL start"

.github/scripts/start_kcl.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
set -e
3+
set -o pipefail
4+
5+
chmod +x samples/sample.properties
6+
chmod +x samples/sample_kclpy_app.py
7+
8+
# Get records from stream to verify they exist before continuing
9+
SHARD_ITERATOR=$(aws kinesis get-shard-iterator --stream-name $STREAM_NAME --shard-id shardId-000000000000 --shard-iterator-type TRIM_HORIZON --query 'ShardIterator' --output text)
10+
INITIAL_RECORDS=$(aws kinesis get-records --shard-iterator $SHARD_ITERATOR)
11+
RECORD_COUNT_BEFORE=$(echo $INITIAL_RECORDS | jq '.Records | length')
12+
13+
echo "Found $RECORD_COUNT_BEFORE records in stream before KCL start"
14+
15+
if [[ "$RUNNER_OS" == "macOS" ]]; then
16+
brew install coreutils
17+
KCL_COMMAND=$(amazon_kclpy_helper.py --print_command --java $(which java) --properties samples/sample.properties)
18+
gtimeout $RUN_TIME_SECONDS $KCL_COMMAND 2>&1 | tee kcl_output.log || [ $? -eq 124 ]
19+
elif [[ "$RUNNER_OS" == "Linux" || "$RUNNER_OS" == "Windows" ]]; then
20+
KCL_COMMAND=$(amazon_kclpy_helper.py --print_command --java $(which java) --properties samples/sample.properties)
21+
timeout $RUN_TIME_SECONDS $KCL_COMMAND 2>&1 | tee kcl_output.log || [ $? -eq 124 ]
22+
else
23+
echo "Unknown OS: $RUNNER_OS"
24+
exit 1
25+
fi
26+
27+
echo "==========ERROR LOGS=========="
28+
grep -i error kcl_output.log || echo "No errors found in logs"

.github/scripts/verify_kcl.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
set -e
3+
4+
NUM_LEASES_FOUND=$(aws dynamodb scan --table-name $APP_NAME --select "COUNT" --query "Count" --output text || echo "0")
5+
NUM_CHECKPOINTS_FOUND=$(aws dynamodb scan --table-name $APP_NAME --select "COUNT" --filter-expression "attribute_exists(checkpoint) AND checkpoint <> :trim_horizon" --expression-attribute-values '{":trim_horizon": {"S": "TRIM_HORIZON"}}' --query "Count" --output text || echo "0")
6+
7+
echo "Found $NUM_LEASES_FOUND leases and $NUM_CHECKPOINTS_FOUND non-TRIM-HORIZON checkpoint in DynamoDB"
8+
9+
echo "Printing checkpoint values"
10+
aws dynamodb scan --table-name $APP_NAME --projection-expression "leaseKey,checkpoint" --output json
11+
12+
if [ "$NUM_LEASES_FOUND" -gt 0 ] && [ "$NUM_CHECKPOINTS_FOUND" -gt 0 ]; then
13+
echo "Test passed: Found both leases and non-TRIM_HORIZON checkpoints in DDB (KCL is fully functional)"
14+
exit 0
15+
else
16+
echo "Test failed: KCL not fully functional"
17+
echo "Lease(s) found: $NUM_LEASES_FOUND"
18+
echo "non-TRIM_HORIZON checkpoint(s) found: $NUM_CHECKPOINTS_FOUND"
19+
exit 1
20+
fi

.github/workflows/privileged-run.yml

Lines changed: 0 additions & 112 deletions
This file was deleted.

0 commit comments

Comments
 (0)