Skip to content

Commit 199a774

Browse files
committed
Address review comments
1 parent 0a3b41b commit 199a774

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

turbinia/e2e/run-e2e-gke.sh

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
# Turbinia GKE e2e tests
33
# The e2e test will test Turbinia googleclouddisk processing
44
# Requirements:
5-
# - have 'kubectl', 'jq' packages installed
6-
# - have the Turbinia Helm chart deployed and are authenticated to the GKE cluster
5+
# TODO: Have seperate checks for each of the requirements
6+
# - have 'kubectl', 'jq', and 'uuid-runtime' packages installed
77
# - have the 'turbinia-client' CLI installed
8+
# - have authenticated to your GKE cluster via `gcloud container clusters get-credentials [clustername] --zone [zone] --project [project_name]`
9+
# - have the Turbinia Helm chart deployed and the Helm release name matching the $RELEASE variable
10+
# - have a GCP disk created that matches the $DISK variable name
811

912
set -o posix
1013
set -e
@@ -36,8 +39,8 @@ then
3639
fi
3740

3841
# Replace Turbinia config with test config
39-
echo "Writing turbinia config to $HOME/.turbinia_api_config.json..."
40-
cat > $HOME/.turbinia_api_config.json <<EOL
42+
echo "Writing turbinia config to ~/.turbinia_api_config.json..."
43+
cat > ~/.turbinia_api_config.json <<EOL
4144
{
4245
"default": {
4346
"description": "Turbinia client test config",
@@ -50,8 +53,8 @@ cat > $HOME/.turbinia_api_config.json <<EOL
5053
}
5154
EOL
5255

53-
# Turbinia e2e test
54-
echo "Starting e2e test for Turbinia..."
56+
# Turbinia GKE e2e test
57+
echo "Starting GKE e2e test for Turbinia..."
5558

5659
# Forward k8s services
5760
echo "Forwarding Turbinia API k8s $RELEASE service"
@@ -66,42 +69,39 @@ turbinia-client config list
6669
# Run Turbinia googleclouddisk processing
6770
echo "Running Turbinia: turbinia-client submit googleclouddisk --project $GCP_PROJECT --zone $GCP_ZONE --disk_name $DISK --request_id $REQUEST_ID"
6871
turbinia-client submit googleclouddisk --project $GCP_PROJECT --zone $GCP_ZONE --disk_name $DISK --request_id $REQUEST_ID
69-
# Give time for Tasks to populate
70-
sleep 5
7172

7273
# Wait until request is complete
73-
req_complete=0
74-
while [ $req_complete -eq 0 ]
74+
sleep 5
75+
req_status=$(turbinia-client status request $REQUEST_ID -j | jq -r '.status')
76+
while [ $req_status = "running" ]
7577
do
7678
req_status=$(turbinia-client status request $REQUEST_ID -j | jq -r '.status')
77-
if [[ $req_status != "running" ]]
79+
if [[ $req_status = "running" ]]
7880
then
79-
req_complete=1
80-
else
8181
echo "Turbinia request $REQUEST_ID is still running. Sleeping for 10 seconds..."
8282
sleep 10
8383
fi
8484
done
8585

8686
# Grab all Tasks where successful = false
87-
echo "Checking the status of Turbinia request: $REQUEST_ID"
87+
echo "Request $REQUEST_ID complete. Checking the results for failed tasks..."
8888
status=$(turbinia-client status request $REQUEST_ID -j)
8989
task_status=$(echo $status | jq '[.tasks[]] | map({name: .name, id: .id, successful: .successful, worker_name: .worker_name}) | map(select(.successful==false))')
9090
length=$(echo $task_status | jq '. | length')
9191

9292
# Check if there is a failed Turbinia Task
9393
if [[ $length > 0 ]]
9494
then
95-
echo "A failed Task for Turbinia Request $req has been detected."
96-
echo "Listing failed Tasks..."
95+
echo "A failed Task for Turbinia Request $req has been detected."
96+
echo "Listing failed Tasks..."
9797
# Grab the Task ID
9898
tasks=$(echo $task_status | jq -r '.[] | .id')
99-
FAILED=1
100-
for t in $tasks
99+
FAILED=1
100+
for t in $tasks
101101
do
102-
echo "Failed Task ID: $t"
103-
turbinia-client status task $t
104-
done
102+
echo "Failed Task ID: $t"
103+
turbinia-client status task $t
104+
done
105105
# Grab Turbinia worker logs from the server pod
106106
server=$(kubectl get pods -o name | grep turbinia-server)
107107
workers=$(echo $task_status | jq -r '.[] | .worker_name')
@@ -119,6 +119,13 @@ else
119119
echo "No failed Tasks detected for Turbinia request $req"
120120
fi
121121

122+
# Restore previous Turbinia config
123+
if [ -f ~/.turbinia_api_config.json.$DATE ]
124+
then
125+
echo "Restoring previous Turbinia config from ~/.turbinia_api_config.json.$DATE"
126+
mv ~/.turbinia_api_config.json.$DATE ~/.turbinia_api_config.json
127+
fi
128+
122129
# If there was a failed Task
123130
if [ "$FAILED" != "0" ]
124131
then

0 commit comments

Comments
 (0)