Skip to content

Commit c02f830

Browse files
fix: add buffer max size and chunk size (#25)
* add buffer max size and chunk size to config files * update testing workflows to be more reusable by moving logic to python
1 parent 20345eb commit c02f830

File tree

7 files changed

+290
-328
lines changed

7 files changed

+290
-328
lines changed

.github/workflows/AWS-EC2-Tests.yaml

Lines changed: 56 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ on:
2626
options:
2727
- false
2828
- true
29-
push:
30-
branches:
31-
- 'test/**'
29+
# push:
30+
# branches:
31+
# - 'test/**'
3232
pull_request:
3333

3434
schedule:
@@ -51,12 +51,11 @@ jobs:
5151
pull-requests: write
5252
issues: read
5353
checks: write
54-
env: # Or as an environment variable
55-
TF_VAR_OBSERVE_CUSTOMER_ID: ${{ secrets.TF_VAR_OBSERVE_CUSTOMER_ID }}
56-
TF_VAR_OBSERVE_DATASTREAM_TOKEN: ${{ secrets.TF_VAR_OBSERVE_DATASTREAM_TOKEN }}
54+
env:
5755
TF_VAR_PUBLIC_KEY: ${{ secrets.TF_VAR_PUBLIC_KEY }}
5856
TF_VAR_REGION: "us-west-2"
5957
TF_VAR_USE_BRANCH_NAME: main
58+
6059
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
6160
ARM_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
6261
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
@@ -68,86 +67,54 @@ jobs:
6867
FAIL_FIRST_TEST: false
6968
FAIL_SECOND_TEST: false
7069
WORK_DIR: test_code
71-
72-
70+
CLOUD: aws
71+
MODULE: aws_machines
7372
# TF_LOG: DEBUG
73+
7474
steps:
75-
- name: Value of inputs
76-
run: |
77-
echo "install_script_branch=${{ github.event.inputs.install_script_branch }}"
78-
echo "this_repo_branch=${{ github.event.inputs.this_repo_branch }}"
79-
echo "terraform_run_destroy=${{ github.event.inputs.terraform_run_destroy }}"
80-
echo "fail_first_test=${{ github.event.inputs.fail_first_test }}"
81-
echo "fail_second_test=${{ github.event.inputs.fail_second_test }}"
75+
# AWS Login - orig role - has to occur before checkout
76+
- name: Configure AWS Credentials
77+
uses: aws-actions/configure-aws-credentials@v1
78+
with:
79+
role-to-assume: ${{ secrets.THUNDERDOME_AWS_ROLE }}
80+
aws-region: ${{ env.TF_VAR_REGION }}
8281

83-
- name: Set variables based on inputs
84-
if: github.event.inputs.terraform_run_destroy != ''
82+
- name: Set code repo
8583
run: |
86-
87-
echo "TF_VAR_USE_BRANCH_NAME=${{ github.event.inputs.install_script_branch }}" >> $GITHUB_ENV
88-
89-
echo "THIS_REPO_BRANCH=refs/heads/${{ github.event.inputs.this_repo_branch }}" >> $GITHUB_ENV
90-
91-
echo "TERRAFORM_RUN_DESTROY=${{ github.event.inputs.terraform_run_destroy }}" >> $GITHUB_ENV
92-
93-
echo "FAIL_FIRST_TEST=${{ github.event.inputs.fail_first_test }}" >> $GITHUB_ENV
84+
if ${{ github.event.inputs.this_repo_branch != '' }}; then
85+
echo "THIS_REPO_BRANCH=refs/heads/${{ github.event.inputs.this_repo_branch }}" >> $GITHUB_ENV
86+
else
87+
echo "THIS_REPO_BRANCH=refs/heads/${{ github.head_ref }}" >> $GITHUB_ENV
88+
fi
9489
95-
echo "FAIL_SECOND_TEST=${{ github.event.inputs.fail_second_test }}" >> $GITHUB_ENV
90+
- name: Check out repository code
91+
uses: actions/checkout@v3
92+
with:
93+
ref: ${{ env.THIS_REPO_BRANCH }}
9694

97-
- name: Set Custom Environment Variables
95+
- name: Set contexts
9896
run: |
99-
# if pull request don't destroy resources
100-
if ${{ github.event_name == 'pull_request' }}; then
101-
echo "TERRAFORM_RUN_DESTROY=false" >> $GITHUB_ENV
102-
echo "THIS_REPO_BRANCH=${{ github.ref }}" >> $GITHUB_ENV
103-
fi
104-
105-
# value for resource names
106-
echo "TF_VAR_WORKFLOW_MATRIX_VALUE=${{ matrix.test_groups }}" >> $GITHUB_ENV
107-
108-
# This variable tells code it running on CI server
109-
echo "TF_VAR_CI=$CI" >> $GITHUB_ENV
110-
111-
# This variable gets just the branch name without url stuff
112-
echo "GIT_HUB_SHORT_BRANCH_NAME=${GITHUB_BRANCH##*/}" >> $GITHUB_ENV
113-
114-
# Create directory for keys and set permissions
115-
mkdir "$HOME/.ssh"
116-
chmod 700 "$HOME/.ssh"
117-
# variable for private key which is required for CI server to login to machines
118-
echo "TF_VAR_PRIVATE_KEY_PATH=$HOME/.ssh/github_actions" >> $GITHUB_ENV
119-
env:
120-
GITHUB_BRANCH: ${{ github.ref }}
97+
mkdir context
98+
echo '${{ toJSON(github) }}' > context/github_context.json
99+
echo '${{ toJSON(matrix) }}' > context/matrix_context.json
100+
echo '${{ secrets.PRIVATE_KEY }}' > context/private_key
101+
102+
working-directory: "${{ env.WORK_DIR }}/python_scripts"
121103

122-
- name: Set SSH Key
104+
- name: workflow helper
123105
run: |
124-
# variable for path to private key
125-
echo "${{ secrets.PRIVATE_KEY }}" > "$TF_VAR_PRIVATE_KEY_PATH"
126-
# set permissions for key file
127-
chmod 600 "$TF_VAR_PRIVATE_KEY_PATH"
128-
# display for troubleshooting
129-
cat "$TF_VAR_PRIVATE_KEY_PATH"
106+
python3 -c "from workflow_tasks import set_custom_vars; set_custom_vars(context_dir='context')"
130107
131-
- name: Print Environment Variables - troubleshooting
132-
run: |
133-
env | sort -f
108+
python3 -c "from workflow_tasks import tf_override_file; tf_override_file(cloud=\"${{ env.CLOUD }}\", test_group=\"${{ matrix.test_groups }}\")"
134109
135-
- name: Check out repository code
136-
uses: actions/checkout@v3
137-
with:
138-
ref: ${{ env.THIS_REPO_BRANCH }}
110+
# !!! vvvvv THIS OVERWRITES MAIN.TF FILE for specific cloud module vvvvv !!!
111+
python3 -c "from workflow_tasks import tf_main_file; tf_main_file(module=\"${{ env.MODULE }}\")"
139112
140-
- name: Setup Terraform
141-
uses: hashicorp/setup-terraform@v2
142-
with:
143-
terraform_wrapper: false
113+
python3 -c "from workflow_tasks import tf_output_file; tf_output_file(module=\"${{ env.MODULE }}\")"
144114
145-
# AWS Login - orig role
146-
- name: Configure AWS Credentials
147-
uses: aws-actions/configure-aws-credentials@v1
148-
with:
149-
role-to-assume: ${{ secrets.THUNDERDOME_AWS_ROLE }}
150-
aws-region: ${{ env.TF_VAR_REGION }}
115+
python3 -c "from workflow_tasks import config_ini; config_ini(custid=\"${{ secrets.STAGE_CUSTOMER_ID }}\", domain=\"${{ secrets.STAGE_DOMAIN }}\", token=\"${{ secrets.STAGE_DATASTREAM_TOKEN }}\")"
116+
117+
working-directory: "${{ env.WORK_DIR }}/python_scripts"
151118

152119
# GCP Login
153120
# This is key generated in GCP console for service account
@@ -161,33 +128,21 @@ jobs:
161128
with:
162129
project_id: ${{ secrets.GCP_PROJECT_ID }}
163130

164-
- name: 'Test gcloud CLI'
165-
run: 'gcloud info'
166-
167-
- name: terraform and config files
131+
- name: Print Environment Variables - troubleshooting
168132
run: |
169-
python3 -c "from workflow_tasks import tf_override_file; tf_override_file(cloud=\"aws\", test_group=\"${{ matrix.test_groups }}\")"
170-
171-
python3 -c "from workflow_tasks import tf_main_file; tf_main_file(module=\"aws_machines\")"
172-
173-
python3 -c "from workflow_tasks import tf_output_file; tf_output_file(module=\"aws_machines\")"
174-
175-
python3 -c "from workflow_tasks import config_ini; config_ini(custid=\"${{ secrets.STAGE_CUSTOMER_ID }}\", domain=\"${{ secrets.STAGE_DOMAIN }}\", token=\"${{ secrets.STAGE_DATASTREAM_TOKEN }}\")"
133+
env | sort -f
176134
177-
working-directory: "${{ env.WORK_DIR }}/python_scripts"
135+
- name: Setup Terraform
136+
uses: hashicorp/setup-terraform@v2
137+
with:
138+
terraform_wrapper: false
178139

179-
- name: terraform version
140+
- name: terraform tasks
180141
run: |
181142
terraform version
182-
working-directory: "${{ env.WORK_DIR }}"
183143
184-
- name: terraform init
185-
run: |
186144
terraform init
187-
working-directory: "${{ env.WORK_DIR }}"
188145
189-
- name: terraform validate
190-
run: |
191146
terraform validate
192147
working-directory: "${{ env.WORK_DIR }}"
193148

@@ -197,7 +152,7 @@ jobs:
197152
working-directory: "${{ env.WORK_DIR }}"
198153

199154
# Run tests
200-
- name: python script
155+
- name: run fabric tests python script
201156
run: |
202157
# create output directory for archive files
203158
mkdir file_outputs
@@ -207,34 +162,27 @@ jobs:
207162
pip3 install -r requirements.txt
208163
209164
# run tests
210-
fab test -a ${{ env.FAIL_FIRST_TEST }} -b ${{ env.THIS_REPO_BRANCH }}
165+
fab test -a ${{ env.FAIL_FIRST_TEST }} -b ${{ env.THIS_REPO_BRANCH }} -o "1: run fabric tests python script"
211166
working-directory: "${{ env.WORK_DIR }}/python_scripts"
212167

213168
- name: Retry tests
214169
if: ${{ env.TEST_RESULT == 'FAIL' }}
215170
run: |
216171
# run tests
217-
fab test -a ${{ env.FAIL_SECOND_TEST }} -o 2 -b ${{ env.THIS_REPO_BRANCH }}
172+
fab test -a ${{ env.FAIL_SECOND_TEST }} -o "2: Retry tests" -b ${{ env.THIS_REPO_BRANCH }}
218173
219174
working-directory: "${{ env.WORK_DIR }}/python_scripts"
220175

221-
- name: delete ini
176+
- name: cleanup
222177
if: always()
223178
run: |
224-
rm config.ini
225-
working-directory: "${{ env.WORK_DIR }}/python_scripts"
179+
rm -f python_scripts/config.ini
226180
227-
- name: clean_output
228-
if: always()
229-
run: |
230-
sed -i 's/${{ secrets.STAGE_DATASTREAM_TOKEN }}/******/g' ./*
231-
working-directory: "${{ env.WORK_DIR }}/python_scripts/file_outputs"
181+
sed -i 's/${{ secrets.STAGE_DATASTREAM_TOKEN }}/******/g' ./python_scripts/file_outputs/*
232182
233-
- name: clean_logs
234-
if: always()
235-
run: |
236-
sed -i 's/${{ secrets.STAGE_DATASTREAM_TOKEN }}/******/g' ./*
237-
working-directory: "${{ env.WORK_DIR }}/python_scripts/log_outputs"
183+
sed -i 's/${{ secrets.STAGE_DATASTREAM_TOKEN }}/******/g' ./python_scripts/log_outputs/*
184+
185+
working-directory: "${{ env.WORK_DIR }}"
238186

239187
- name: Archive test results
240188
uses: actions/upload-artifact@v3

0 commit comments

Comments
 (0)