Skip to content

Commit

Permalink
Merge pull request #231 from dosaboy/fix-bashate
Browse files Browse the repository at this point in the history
Fix bashate tests
  • Loading branch information
dosaboy authored Sep 11, 2024
2 parents 369cc30 + 9a7499a commit a48e1c8
Show file tree
Hide file tree
Showing 15 changed files with 106 additions and 69 deletions.
8 changes: 6 additions & 2 deletions common/generate_bundle_base
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ if ((${#MOD_OVERLAYS[@]})); then
unset subdir
fi
cp $MOD_DIR/overlays/$overlay $bundles_dir/o/${subdir:-""}
((${#overlay_opts[@]}==0)) && overlay_opts+=("") # left padding
if ((${#overlay_opts[@]}==0)); then
overlay_opts+=("") # left padding
fi
overlay_opts+=( --overlay $bundles_dir/o/$overlay )
overlay_list+=( "$bundles_dir/o/$overlay" )
render $bundles_dir/o/$overlay
Expand Down Expand Up @@ -223,7 +225,9 @@ if ${MASTER_OPTS[HYPERCONVERGED_DEPLOYMENT]}; then
xargs -l sed -i -r "/^\s+charm:.+/a$bindings"
fi

((${#overlay_opts[@]})) && overlay_opts+=("") # right padding
if ((${#overlay_opts[@]})); then
overlay_opts+=("") # right padding
fi

echo -e "juju deploy${JUJU_DEPLOY_OPTS} \
${base_bundle}${overlay_opts[@]:- }\n " > ${bundles_dir}/command
Expand Down
7 changes: 3 additions & 4 deletions openstack/tools/allocate_vips.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ net_pre=$(echo $cidr| sed -r 's/([0-9]+\.[0-9]+\.[0-9]+).+/\1/g')

j=1

for i in $(seq ${vip_start_suffix} ${net_end})
do
for i in $(seq ${vip_start_suffix} ${net_end}); do
echo openstack port create --network net_${OS_USERNAME}-psd \
--fixed-ip subnet=subnet_${OS_USERNAME}-psd,ip-address=${net_pre}.$i \
--disable --os-cloud ps6 ps6-vip-ip$( printf "%02d" $j )
((j++))
done
j=$((j+1))
done
45 changes: 22 additions & 23 deletions openstack/tools/charmed_openstack_functest_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,38 +47,37 @@ OPTIONS:
EOF
}

while (($# > 0))
do
while (($# > 0)); do
case "$1" in
--debug)
set -x
;;
set -x
;;
--func-test-target)
FUNC_TEST_TARGET=$2
shift
;;
FUNC_TEST_TARGET=$2
shift
;;
--func-test-pr)
FUNC_TEST_PR=$2
shift
;;
FUNC_TEST_PR=$2
shift
;;
--no-wait)
WAIT_ON_DESTROY=false
;;
WAIT_ON_DESTROY=false
;;
--skip-modify-bundle-constraints)
MODIFY_BUNDLE_CONSTRAINTS=false
;;
MODIFY_BUNDLE_CONSTRAINTS=false
;;
--skip-build)
SKIP_BUILD=true
;;
SKIP_BUILD=true
;;
--help|-h)
usage
exit 0
;;
usage
exit 0
;;
*)
echo "ERROR: invalid input '$1'"
usage
exit 1
;;
echo "ERROR: invalid input '$1'"
usage
exit 1
;;
esac
shift
done
Expand Down
4 changes: 2 additions & 2 deletions openstack/tools/create_ipv4_octavia.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ set -u -e -x
while true; do
[[ `juju status keystone --format json | jq -r '.applications.keystone.units."keystone/0"."workload-status".current'` = active ]] \
&& break
if [[ `juju status keystone --format json | jq -r '.applications.keystone.units."keystone/0"."workload-status".current'` = error ]]
then
if [[ `juju status keystone --format json | \
jq -r '.applications.keystone.units."keystone/0"."workload-status".current'` = error ]]; then
echo "ERROR: Octavia deployment failed"
break
fi
Expand Down
4 changes: 3 additions & 1 deletion openstack/tools/create_nova_az_aggregates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
for az in az1 az2; do
readarray ids<<<"`juju status nova-compute-$az --format=yaml| grep instance-id| awk '{print $2}'`"
machines=()
for id in ${ids[@]}; do machines+=( `source ~/novarc; openstack server show $id| grep " name "| awk '{print $4}'` ); done
for id in ${ids[@]}; do
machines+=( `source ~/novarc; openstack server show $id| grep " name "| awk '{print $4}'` )
done
echo "Creating aggregate ${az^^}"
openstack aggregate show ${az^^} &>/dev/null || openstack aggregate create --zone $az ${az^^};
for m in ${machines[@]}; do
Expand Down
11 changes: 7 additions & 4 deletions openstack/tools/create_octavia_lb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ while (( $# > 0 )); do
echo "missing protocol for healthmonitor"
exit 1
fi
hm_protocol=$2
shift
;;
hm_protocol=$2
shift
;;
-h|--help)
cat <<EOF
Usage:
Expand Down Expand Up @@ -148,7 +148,10 @@ openstack loadbalancer healthmonitor list
# Add vm(s) to pool
if (( ${#member_vm[@]} == 0 )); then
readarray -t member_vm < <(openstack server list --column ID --format value)
(( ${#member_vm[@]} )) || { echo "ERROR: could not find a vm to add to lb pool"; exit 1; }
if ((${#member_vm[@]}==0)); then
echo "ERROR: could not find a vm to add to lb pool"
exit 1
fi
fi

for member in "${member_vm[@]}"; do
Expand Down
5 changes: 2 additions & 3 deletions openstack/tools/create_sg_log.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash -u
openstack network loggable resources list
openstack network log create --resource-type security_group \
--description "Collecting all security events" \
--enable --event ALL Log_Created

--description "Collecting all security events" \
--enable --event ALL Log_Created
9 changes: 6 additions & 3 deletions openstack/tools/delete_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ openstack floating ip list --project $project_name --project-domain $domain -c I

openstack router unset --external-gateway ${project_name}-router &

readarray -t ports<<<`openstack port list --router ${project_name}-router -c id -c device_owner -f value| awk '$2=="network:ha_router_replicated_interface" {print $1}'`
((${#ports[@]})) && [ -n "${ports[0]}" ] || \
readarray -t ports<<<`openstack port list --router ${project_name}-router -c id -c device_owner -f value| awk '$2=="network:router_interface_distributed" {print $1}'`
readarray -t ports<<<`openstack port list --router ${project_name}-router -c id -c device_owner -f value| \
awk '$2=="network:ha_router_replicated_interface" {print $1}'`
if ! ((${#ports[@]})) && [ -n "${ports[0]}" ]; then
readarray -t ports<<<`openstack port list --router ${project_name}-router -c id -c device_owner -f value| \
awk '$2=="network:router_interface_distributed" {print $1}'`
fi
declare -A subnets=()
if ((${#ports[@]})) && [ -n "${ports[0]}" ]; then
Expand Down
10 changes: 5 additions & 5 deletions openstack/tools/enable_samltestid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ juju attach-resource keystone-saml-mellon idp-metadata=./$IDP_XML

status='foo'
while [[ $status != 'active' ]]; do
sleep 3
status=$(juju status keystone-saml-mellon --format json | jq -r '."applications"."keystone-saml-mellon"."application-status"."current"')
sleep 3
status=$(juju status keystone-saml-mellon --format json | jq -r '."applications"."keystone-saml-mellon"."application-status"."current"')
done

juju $JUJU_RUN_CMD --format=json keystone-saml-mellon/0 get-sp-metadata > sp-metadata.json
Expand All @@ -60,14 +60,14 @@ if [ $JUJU_VERSION -eq 2 ]; then
cat sp-metadata.json | jq -r '."unit-keystone-saml-mellon-0".results.output' > sp-metadata.xml
else
cat sp-metadata.json | jq -r '."keystone-saml-mellon/0".results.output' > sp-metadata.xml
fi
fi

juju attach-resource test-saml-idp1 sp-metadata=./sp-metadata.xml

status='foo'
while [[ $status != 'active' ]]; do
sleep 3
status=$(juju status test-saml-idp1 --format json | jq -r '."applications"."test-saml-idp1"."application-status"."current"')
sleep 3
status=$(juju status test-saml-idp1 --format json | jq -r '."applications"."test-saml-idp1"."application-status"."current"')
done

ENTITY_ID=$(egrep -o "entityID=\"(.*)\"" idp-metadata.xml | cut -d "=" -f2 | cut -d '"' -f2)
Expand Down
2 changes: 1 addition & 1 deletion openstack/tools/float_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

echo " + Floating all instances."

function get_ip_f() {
function get_ip_f {
# Get first unallocated floating IP
openstack floating ip list | awk '/None/ { print $4; exit }'
}
Expand Down
12 changes: 6 additions & 6 deletions openstack/tools/install_local_ca.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ if ((`juju status --format=json| jq -r '.applications[]| select(."charm-name"=="
model_ca_cert_path=/tmp/stsstack-bundles.ssl.$model_uuid

if ! validate_or_remove_ca ${model_ca_cert_path}; then
echo "Fetching CA cert from vault" 1>&2
juju $JUJU_RUN_CMD --format=json vault/leader get-root-ca| jq -r .[].results.output > $model_ca_cert_path
if ! validate_or_remove_ca $model_ca_cert_path; then
echo "Didn't get a certificate from vault, check it's status and if necessary use ./tools/vault-unseal-and-authorise.sh" 1>&2
exit 1
fi
echo "Fetching CA cert from vault" 1>&2
juju $JUJU_RUN_CMD --format=json vault/leader get-root-ca| jq -r .[].results.output > $model_ca_cert_path
if ! validate_or_remove_ca $model_ca_cert_path; then
echo "Didn't get a certificate from vault, check it's status and if necessary use ./tools/vault-unseal-and-authorise.sh" 1>&2
exit 1
fi
fi
elif [ -n "`juju config keystone ssl_cert`" ]; then
MOD_DIR=$(dirname $0)/..
Expand Down
4 changes: 2 additions & 2 deletions openstack/tools/instance_launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ done

# Determining flavor to use
if [[ "${image_name}" =~ cirros ]]; then
flavor="m1.cirros"
flavor="m1.cirros"
else
flavor="m1.small"
flavor="m1.small"
fi

# Create instances
Expand Down
4 changes: 3 additions & 1 deletion tools/stack-manager/mark-vms-managed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
. `dirname $0`/common.sh
vms=( $@ )

(("${#vms[@]}")) || { echo "ERROR: no vms provided"; exit 1; }
if (("${#vms[@]}" == 0)); then
echo "ERROR: no vms provided"; exit 1;
fi

openstack object save stack-manager-${OS_PROJECT_NAME} --file $STAGING_DIR/managed_vms.json managed_vms.json
echo "Marking ${#vms[@]} vms as managed=true"
Expand Down
4 changes: 3 additions & 1 deletion tools/stack-manager/mark-vms-unmanaged.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
. `dirname $0`/common.sh
vms=( $@ )

(("${#vms[@]}")) || { echo "ERROR: no vms provided"; exit 1; }
if (("${#vms[@]}" == 0)); then
echo "ERROR: no vms provided"; exit 1;
fi

openstack object save stack-manager-${OS_PROJECT_NAME} --file $STAGING_DIR/managed_vms.json managed_vms.json
echo "Marking ${#vms[@]} vms as managed=false"
Expand Down
46 changes: 35 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,50 @@ pyfiles =
{toxinidir}/tools/juju-bundle-applications.py

bashfiles =
{toxinidir}/common/generate-bundle.sh
{toxinidir}/common/generate_bundle_base
{toxinidir}/openstack/tools/create-microceph-vm.sh
{toxinidir}/tools/juju-lnav
# find tools -name \*.sh
{toxinidir}/tools/vault-unseal-and-authorise.sh
{toxinidir}/tools/model-poweron.sh
{toxinidir}/tools/model-poweroff.sh
{toxinidir}/tools/mongo-access.sh
{toxinidir}/tools/lint-git-messages.sh
{toxinidir}/tools/model-poweron.sh
{toxinidir}/tools/stack-manager/mark-model-vms-unmanaged.sh
{toxinidir}/tools/stack-manager/show-all.sh
{toxinidir}/tools/stack-manager/show-managed.sh
{toxinidir}/tools/stack-manager/mark-vms-managed.sh
{toxinidir}/tools/stack-manager/common.sh
{toxinidir}/tools/stack-manager/show-unmanaged.sh
{toxinidir}/tools/stack-manager/mark-vms-unmanaged.sh
{toxinidir}/tools/stack-manager/mark-vms-managed.sh
{toxinidir}/tools/stack-manager/mark-model-vms-managed.sh
{toxinidir}/tools/stack-manager/show-unmanaged.sh
{toxinidir}/tools/stack-manager/common.sh
{toxinidir}/tools/stack-manager/mark-model-vms-unmanaged.sh
{toxinidir}/tools/mongo-access.sh
{toxinidir}/tools/stack-manager/show-managed.sh
{toxinidir}/tools/model-poweroff.sh

{toxinidir}/common/generate_bundle_base
# find common -name \*.sh
{toxinidir}/common/ch_channel_map/test-channel-map.sh
{toxinidir}/common/ch_channel_map/test-all.sh
{toxinidir}/common/generate-bundle.sh

{toxinidir}/openstack/novarc
# find openstack/tools/ -name \*.sh
{toxinidir}/openstack/tools/create-microceph-vm.sh
{toxinidir}/openstack/tools/float_all.sh
{toxinidir}/openstack/tools/create_nova_az_aggregates.sh
{toxinidir}/openstack/tools/vault-unseal-and-authorise.sh
{toxinidir}/openstack/tools/create_sg_log.sh
{toxinidir}/openstack/tools/enable_samltestid.sh
{toxinidir}/openstack/tools/create_ipv4_octavia.sh
{toxinidir}/openstack/tools/allocate_vips.sh
{toxinidir}/openstack/tools/upload_octavia_amphora_image.sh
{toxinidir}/openstack/tools/install_local_ca.sh
{toxinidir}/openstack/tools/charmed_openstack_functest_runner.sh
{toxinidir}/openstack/tools/instance_launch.sh
{toxinidir}/openstack/tools/setup_tempest.sh
{toxinidir}/openstack/tools/create_octavia_lb.sh
{toxinidir}/openstack/tools/sec_groups.sh
{toxinidir}/openstack/tools/configure_octavia.sh
{toxinidir}/openstack/tools/delete_project.sh
{toxinidir}/openstack/tools/create_project.sh
{toxinidir}/openstack/tools/upload_image.sh

setenv =
PYTHONHASHSEED=0
deps =
Expand Down

0 comments on commit a48e1c8

Please sign in to comment.