Skip to content
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

Script to generate different sized knife ec backup #6855

Merged
merged 11 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .studio/infra-proxy-service
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,66 @@ EOF
done
log_line "Sample data loaded of $records users for server with server name '$server_prefix' and server id '$server_id'"
}

document "infra_service_load_knife_ec_backup_file" <<DOC
Creates the sample knife ec backup file
Before running this command make sure either run 'start_infra_proxy_service' or 'start_all_services'
and also make sure that there is no any backup directory and backup.zip in /src/

-O No of Orgs default: 2
-U No of Users default: 200

Example:
-----------------------------
infra_service_load_knife_ec_backup_file -O 2 -U 200
DOC
function infra_service_load_knife_ec_backup_file() {
install_if_missing core/jq-static jq
install_if_missing core/grpcurl grpcurl

local OPTIND opt
local orgs=2
local users=200


while getopts ":O:U:" opt; do
case $opt in
O) orgs="$OPTARG"
;;
U) users="$OPTARG"
;;
\?) echo "Invalid option -$OPTARG" >&2
;;
: )
echo "Invalid option: $OPTARG requires an argument" 1>&2
;;
esac
done
shift $((OPTIND -1))

log_line "Total number of orgs: $orgs"
log_line "Total number of users: $users"

# Create knife ec backup file
local user_prefix="user"

kalroy marked this conversation as resolved.
Show resolved Hide resolved
for i in $(seq 1 ${orgs}); do
timestamp=$(date +%s%N)
local org_id="org-${timestamp}-id"
local number_of_users=$((users/orgs))

chef-automate dev grpcurl infra-proxy-service -- -d \
"$(cat << EOF
{"org_id": "${org_id}", "number_of_users": "${number_of_users}"}
EOF
)" chef.automate.domain.infra_proxy.migrations.service.MigrationDataService.CreateBackup >/dev/null

log_line "For org_id '${org_id}', the numbers of users are ${number_of_users}"
done

install_if_missing core/zip zip
zip -r backup.zip backup
rm -rf backup

log_line "Sample back up zip created at path '/src/backup.zip'"
}
Loading