Skip to content

Commit

Permalink
Add bc to support ability mathematic operations on floats
Browse files Browse the repository at this point in the history
  • Loading branch information
sigalsax committed Aug 19, 2020
1 parent 9e147b5 commit 884c2ca
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 10 deletions.
13 changes: 8 additions & 5 deletions deploy/test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ RUN mkdir -p ocbin && \
rm -rf ocbin oc.tar.gz

# Install Helm
RUN curl https://baltocdn.com/helm/signing.asc | sudo apt-key add - && \
sudo apt-get install apt-transport-https --yes && \
echo "deb https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list &&\
sudo apt-get update && \
sudo apt-get install helm=3.2.*
RUN curl https://baltocdn.com/helm/signing.asc | apt-key add - && \
apt-get install apt-transport-https --yes && \
echo "deb https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list && \
apt-get update && \
apt-get install helm=3.2.*

# Adds ability to perform mathematical operations with floats for testing
RUN apt-get install -y bc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ $cli_with_timeout wait --for=condition=complete job/$helm_chart_name

deploy_helm_app

# Deployed twice to ensure conjur.pem exists
setup_helm_environment
# Deploy second Secrets Provider Job
pushd ../../
export SECRETS_PROVIDER_ROLE=another-secrets-provider-role
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ popd
helm_chart_name="secrets-provider"
$cli_with_timeout wait --for=condition=complete job/$helm_chart_name

setup_helm_environment
pushd ../../
export SECRETS_PROVIDER_ROLE=another-secrets-provider-role
export SECRETS_PROVIDER_ROLE_BINDING=another-secrets-provider-role-binding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ popd
helm_chart_name="secrets-provider"
$cli_with_timeout wait --for=condition=complete job/$helm_chart_name

setup_helm_environment

pushd ../../
export CREATE_SERVICE_ACCOUNT="false"
export LABELS="app: another-test-helm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ $cli_with_timeout "logs $pod_name | grep 'CSPFK010I Updating Kubernetes Secrets:
duration=$(( SECONDS - start ))
# Since we are testing retry in scripts we must determine an acceptable range that retry should have taken place
# If the duration falls within that range, then we can determine the retry mechanism works as expected
retryIntervalMin=`echo "scale=2; $DEFAULT_RETRY_INTERVAL_SEC/100*80" | bc`
retryIntervalMax=`echo "scale=2; $DEFAULT_RETRY_INTERVAL_SEC/100*120" | bc`
retryIntervalMin=`echo "scale=2; $DEFAULT_RETRY_INTERVAL_SEC/100*80" | bc | cut -d "." -f 1 | cut -d "," -f 1`
retryIntervalMax=`echo "scale=2; $DEFAULT_RETRY_INTERVAL_SEC/100*120" | bc | cut -d "." -f 1 | cut -d "," -f 1`
if (( $duration >= $retryIntervalMin && $duration <= $retryIntervalMax )); then
echo 0
else
echo "Timed retry failed to occur according to detailed retry interval. Timed duration: $duration"
echo 1
fi

Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ $cli_with_timeout "logs $pod_name | grep 'CSPFK010I Updating Kubernetes Secrets:
duration=$(( SECONDS - start ))
# Since we are testing retry in scripts we must determine an acceptable range that retry should take place
# If the duration falls within that range, then we can determine the retry mechanism works as expected
retryIntervalMin=`echo "scale=2; $RETRY_INTERVAL_SEC/100*80" | bc`
retryIntervalMax=`echo "scale=2; $RETRY_INTERVAL_SEC/100*120" | bc`
retryIntervalMin=`echo "scale=2; $RETRY_INTERVAL_SEC/100*80" | bc | cut -d "." -f 1 | cut -d "," -f 1`
retryIntervalMax=`echo "scale=2; $RETRY_INTERVAL_SEC/100*120" | bc | cut -d "." -f 1 | cut -d "," -f 1`
if (( $duration >= $retryIntervalMin && $duration <= $retryIntervalMax )); then
echo 0
else
echo "Timed retry failed to occur according to detailed retry interval. Timed duration: $duration"
echo 1
fi

2 changes: 1 addition & 1 deletion deploy/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ setup_helm_environment() {
ssl_location="../conjur.pem"
fi
# Save cert for later setting in Helm
$cli_with_timeout "exec ${conjur_pod_name} --namespace $CONJUR_NAMESPACE_NAME cat $cert_location" > "$ssl_location"
$cli_with_timeout "exec ${conjur_pod_name} --namespace $CONJUR_NAMESPACE_NAME cat $cert_location" > -f "$ssl_location"

set_namespace $APP_NAMESPACE_NAME
}
Expand Down

0 comments on commit 884c2ca

Please sign in to comment.