Skip to content

More robust sample testing python #300

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

skyero-aws
Copy link
Contributor

Issue #, if available:

Description of changes:
Added more robust checks for kcl functionality.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@skyero-aws skyero-aws changed the title More robust sample testing More robust sample testing python Jul 2, 2025
}' \
--return-values NONE

# Delete all tables
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we delete commented out code?

if aws kinesis create-stream --stream-name $STREAM_NAME --shard-count 1; then
break
else
echo "Stream creation failed, attempt $i/10. Waiting $((i * 3)) seconds..."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we scale like this for sleeping?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A simple retry wasn't thorough enough but an exponential backoff was a bit overkill, I found that linear backoff was a good in-between point

#!/bin/bash
set -e

LEASE_EXISTS=$(aws dynamodb scan --table-name $APP_NAME --select "COUNT" --query "Count" --output text || echo "0")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: NUM_LEASES_FOUND

set -e

LEASE_EXISTS=$(aws dynamodb scan --table-name $APP_NAME --select "COUNT" --query "Count" --output text || echo "0")
CHECKPOINT_EXISTS=$(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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: NUM_CHECKPOINTS_FOUND

PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

# # update permissions to 'contents: write' when enabled
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets remove unused code if its not planned to be in use.

APP_NAME: ${{ env.APP_NAME }}

# Clean up all existing Streams and DDB tables
- name: Clean up Kinesis Stream and DynamoDB table
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a scenario where this may not run or the job fails out before this point?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, even if the job fails out before this point the if:always() makes sure this step always runs

pelaezryan
pelaezryan previously approved these changes Jul 3, 2025
@pelaezryan pelaezryan dismissed their stale review July 11, 2025 18:39

Noticed some DRYing of the code.

#!/bin/bash
set -e

# Manipulate sample.properties file that the KCL application pulls properties from (ex: streamName, applicationName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Manipulate sample.properties file that the KCL application pulls properties from (ex: streamName, applicationName)
sed -i "" "s/kclpysample/$STREAM_NAME/g" samples/sample.properties
sed -i "" "s/PythonKCLSample/$APP_NAME/g" samples/sample.properties
sed -i "" 's/us-east-5/us-east-1/g' samples/sample.properties
# Depending on the OS, different properties need to be changed
if [[ "$RUNNER_OS" == "macOS" ]]; then
  grep -v "idleTimeBetweenReadsInMillis" samples/sample.properties > samples/temp.properties
  echo "idleTimeBetweenReadsInMillis = 250" >> samples/temp.properties
  mv samples/temp.properties samples/sample.properties
elif [[ "$RUNNER_OS" == "Linux" || "$RUNNER_OS" == "Windows" ]]; then
  sed -i "/idleTimeBetweenReadsInMillis/c\idleTimeBetweenReadsInMillis = 250" samples/sample.properties
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants