forked from neicnordic/sda-pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_integration_test.sh
93 lines (77 loc) · 3.63 KB
/
run_integration_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh
for c in s3cmd jq
do
if ! command -v $c
then
echo "$c could not be found"
exit 1
fi
done
FILE="dummy_data.c4gh"
SHA="5e9c767958cc3f6e8d16512b8b8dcab855ad1e04e05798b86f50ef600e137578"
MD5="b60fa2486b121bed8d566bacec987e0d"
if [ "$1" != "" ]; then
SHA=$(sha256sum "$1" | awk '{print $1;}')
MD5=$(md5sum "$1" | awk '{print $1;}')
FILE="$(realpath "$1")"
fi
file=$(basename "$FILE")
cd "$(dirname "$0")" || exit
s3cmd -c s3cmd.conf put "$FILE" s3://inbox/test/"$file"
curl -u test:test 'localhost:15672/api/exchanges/test/sda/publish' \
-H 'Content-Type: application/json;charset=UTF-8' \
--data-binary '{"vhost":"test","name":"sda","properties":{"delivery_mode":2,"correlation_id":"1","content_encoding":"UTF-8","content_type":"application/json"},"routing_key":"files","payload_encoding":"string","payload":"{\"type\":\"ingest\",\"user\":\"test\",\"filepath\":\"'"$file"'\",\"encrypted_checksums\":[{\"type\":\"sha256\",\"value\":\"'"$SHA"'\",\"type\":\"md5\",\"value\":\"'"$MD5"'\"}]}"}'
RETRY_TIMES=0
until docker logs --since 30s ingest 2>&1 | grep "Mark as archived"
do
echo "waiting for ingestion to complete"
RETRY_TIMES=$((RETRY_TIMES+1));
if [ $RETRY_TIMES -eq 30 ]; then
echo "Ingest failed"
exit 1
fi
sleep 10;
done
RETRY_TIMES=0
until docker logs --since 30s verify 2>&1 | grep "Mark completed"
do
echo "waiting for verification to complete"
RETRY_TIMES=$((RETRY_TIMES+1));
if [ $RETRY_TIMES -eq 30 ]; then
echo "Verification failed"
exit 1
fi
sleep 10;
done
message=$(curl -u test:test 'localhost:15672/api/queues/test/verified/get' \
-H 'Content-Type: application/json;charset=UTF-8' \
-d '{"count":1,"ackmode":"ack_requeue_true","encoding":"auto","truncate":50000}')
decrypted_sha=$(echo "$message" | jq '.[0].payload | fromjson.decrypted_checksums[0].value' | cut -d '"' -f 2)
decrypted_md5=$(echo "$message" | jq '.[0].payload | fromjson.decrypted_checksums[1].value' | cut -d '"' -f 2)
file=$(echo "$message" | jq '.[0].payload | fromjson.filepath' | cut -d '"' -f 2)
curl -u test:test 'localhost:15672/api/exchanges/test/sda/publish' \
-H 'Content-Type: application/json;charset=UTF-8' \
--data-binary '{"vhost":"test","name":"sda","properties":{"delivery_mode":2,"correlation_id":"1","content_encoding":"UTF-8","content_type":"application/json"},"routing_key":"files","payload_encoding":"string","payload":"{\"type\":\"accession\",\"user\":\"test\",\"filepath\":\"'"$file"'\",\"accession_id\":\"EGAF00123456789\",\"decrypted_checksums\":[{\"type\":\"sha256\",\"value\":\"'"$decrypted_sha"'\"},{\"type\":\"md5\",\"value\":\"'"$decrypted_md5"'\"}]}"}'
RETRY_TIMES=0
until docker logs finalize 2>&1 | grep "Mark ready"
do
echo "waiting for finalize to complete"
RETRY_TIMES=$((RETRY_TIMES+1));
if [ $RETRY_TIMES -eq 30 ]; then
echo "Finalize failed"
exit 1
fi
sleep 10;
done
curl -vvv -u test:test 'localhost:15672/api/exchanges/test/sda/publish' \
-H 'Content-Type: application/json;charset=UTF-8' \
--data-binary '{"vhost":"test","name":"sda","properties":{"delivery_mode":2,"correlation_id":"1","content_encoding":"UTF-8","content_type":"application/json"},"routing_key":"files","payload_encoding":"string","payload":"{\"type\":\"mapping\",\"dataset_id\":\"EGAD00123456789\",\"accession_ids\":[\"EGAF00123456789\"]}"}'
dataset=$(docker run --rm --name client --network dev_utils_default \
neicnordic/pg-client:latest postgresql://lega_out:lega_out@db:5432/lega \
-c "SELECT * from local_ega_ebi.file_dataset" | grep EGAD00123456789)
if [ ${#dataset} -eq 0 ]; then
echo "Mappings failed"
exit 1
else
echo "Success"
fi