2
2
# Turbinia GKE e2e tests
3
3
# The e2e test will test Turbinia googleclouddisk processing
4
4
# 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
7
7
# - 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
8
11
9
12
set -o posix
10
13
set -e
36
39
fi
37
40
38
41
# 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
41
44
{
42
45
"default": {
43
46
"description": "Turbinia client test config",
@@ -50,8 +53,8 @@ cat > $HOME/.turbinia_api_config.json <<EOL
50
53
}
51
54
EOL
52
55
53
- # Turbinia e2e test
54
- echo " Starting e2e test for Turbinia..."
56
+ # Turbinia GKE e2e test
57
+ echo " Starting GKE e2e test for Turbinia..."
55
58
56
59
# Forward k8s services
57
60
echo " Forwarding Turbinia API k8s $RELEASE service"
@@ -66,42 +69,39 @@ turbinia-client config list
66
69
# Run Turbinia googleclouddisk processing
67
70
echo " Running Turbinia: turbinia-client submit googleclouddisk --project $GCP_PROJECT --zone $GCP_ZONE --disk_name $DISK --request_id $REQUEST_ID "
68
71
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
71
72
72
73
# 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" ]
75
77
do
76
78
req_status=$( turbinia-client status request $REQUEST_ID -j | jq -r ' .status' )
77
- if [[ $req_status ! = " running" ]]
79
+ if [[ $req_status = " running" ]]
78
80
then
79
- req_complete=1
80
- else
81
81
echo " Turbinia request $REQUEST_ID is still running. Sleeping for 10 seconds..."
82
82
sleep 10
83
83
fi
84
84
done
85
85
86
86
# 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... "
88
88
status=$( turbinia-client status request $REQUEST_ID -j)
89
89
task_status=$( echo $status | jq ' [.tasks[]] | map({name: .name, id: .id, successful: .successful, worker_name: .worker_name}) | map(select(.successful==false))' )
90
90
length=$( echo $task_status | jq ' . | length' )
91
91
92
92
# Check if there is a failed Turbinia Task
93
93
if [[ $length > 0 ]]
94
94
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..."
97
97
# Grab the Task ID
98
98
tasks=$( echo $task_status | jq -r ' .[] | .id' )
99
- FAILED=1
100
- for t in $tasks
99
+ FAILED=1
100
+ for t in $tasks
101
101
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
105
105
# Grab Turbinia worker logs from the server pod
106
106
server=$( kubectl get pods -o name | grep turbinia-server)
107
107
workers=$( echo $task_status | jq -r ' .[] | .worker_name' )
@@ -119,6 +119,13 @@ else
119
119
echo " No failed Tasks detected for Turbinia request $req "
120
120
fi
121
121
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
+
122
129
# If there was a failed Task
123
130
if [ " $FAILED " != " 0" ]
124
131
then
0 commit comments