@@ -31,8 +31,8 @@ import (
31
31
)
32
32
33
33
var _ = Describe ("Get and Delete with Manager" , func () {
34
- Context ("get /bin/md5sum task" , func () {
35
- It ("get task should be ok" , func () {
34
+ Context ("get and delete /bin/md5sum task" , func () {
35
+ It ("get and delete task should be ok" , func () {
36
36
// Create preheat job
37
37
managerPod , err := util .ManagerExec (0 )
38
38
fmt .Println (err )
@@ -60,6 +60,69 @@ var _ = Describe("Get and Delete with Manager", func() {
60
60
61
61
done := waitForDone (job , managerPod )
62
62
Expect (done ).Should (BeTrue ())
63
+
64
+ fileMetadata := util.FileMetadata {
65
+ ID : "6ba5a8781902368d2b07eb8b6d6044a96f49d5008feace1ea8e3ebfc0b96d0a1" ,
66
+ Sha256 : "80f1d8cd843a98b23b30e90e7e43a14e05935351f354d678bc465f7be66ef3dd" ,
67
+ }
68
+
69
+ seedClientPods := make ([]* util.PodExec , 3 )
70
+ for i := 0 ; i < 3 ; i ++ {
71
+ seedClientPods [i ], err = util .SeedClientExec (i )
72
+ fmt .Println (err )
73
+ Expect (err ).NotTo (HaveOccurred ())
74
+ }
75
+
76
+ // Check the file is downloaded successfully
77
+ sha256sum , err := util .CalculateSha256ByTaskID (seedClientPods , fileMetadata .ID )
78
+ Expect (err ).NotTo (HaveOccurred ())
79
+ Expect (fileMetadata .Sha256 ).To (Equal (sha256sum ))
80
+
81
+ // Get task
82
+ req , err = structure .StructToMap (types.CreateGetTaskJobRequest {
83
+ Type : internaljob .GetTaskJob ,
84
+ Args : types.GetTaskArgs {
85
+ TaskID : fileMetadata .ID ,
86
+ },
87
+ })
88
+ Expect (err ).NotTo (HaveOccurred ())
89
+ out , err = managerPod .CurlCommand ("POST" , map [string ]string {"Content-Type" : "application/json" }, req ,
90
+ "http://127.0.0.1:8080/api/v1/jobs" ).CombinedOutput ()
91
+ fmt .Println (err )
92
+ Expect (err ).NotTo (HaveOccurred ())
93
+ fmt .Println (string (out ))
94
+
95
+ job = & models.Job {}
96
+ err = json .Unmarshal (out , job )
97
+ fmt .Println (err )
98
+ Expect (err ).NotTo (HaveOccurred ())
99
+ // Check get task response is not null
100
+ Expect (job .Result ).NotTo (BeNil ())
101
+
102
+ // Delete task
103
+ req , err = structure .StructToMap (types.CreateDeleteTaskJobRequest {
104
+ Type : internaljob .DeleteTaskJob ,
105
+ Args : types.DeleteTaskArgs {
106
+ TaskID : fileMetadata .ID ,
107
+ },
108
+ })
109
+ Expect (err ).NotTo (HaveOccurred ())
110
+ out , err = managerPod .CurlCommand ("POST" , map [string ]string {"Content-Type" : "application/json" }, req ,
111
+ "http://127.0.0.1:8080/api/v1/jobs" ).CombinedOutput ()
112
+ fmt .Println (err )
113
+ Expect (err ).NotTo (HaveOccurred ())
114
+ fmt .Println (string (out ))
115
+
116
+ job = & models.Job {}
117
+ err = json .Unmarshal (out , job )
118
+ fmt .Println (err )
119
+ Expect (err ).NotTo (HaveOccurred ())
120
+ // Check delete task response is not null
121
+ Expect (job .Result ).NotTo (BeNil ())
122
+
123
+ // Check file is deleted successfully
124
+ _ , err = util .CalculateSha256ByTaskID (seedClientPods , fileMetadata .ID )
125
+ Expect (err ).To (HaveOccurred ())
63
126
})
64
127
})
65
128
})
0 commit comments