@@ -36,13 +36,7 @@ func TestMarshalingFunctionComposition(t *testing.T) {
36
36
}
37
37
38
38
func TestUnmarshalFunctionCompositionResult (t * testing.T ) {
39
- composition := "{\n \t \" Reports\" : {\n \t \t \" End_9TUZZdXNwgroNYp4akDKQ6\" : {\n \t \t \t \" Result\" : \" end\" ,\n \t \t \t \" ResponseTime\" : 0,\n \t \t \t \" IsWarmStart\" : false,\n \t \t \t \" InitTime\" : 0,\n \t \t \t \" OffloadLatency\" : 0,\n \t \t \t \" Duration\" : 0,\n \t \t \t \" SchedAction\" : \" \" \n \t \t },\n \t \t \" Simple_JyzhDkLuBzUVSmPEUiEWVm\" : {\n \t \t \t \" Result\" : \" 3\" ,\n \t \t \t \" ResponseTime\" : 0.00283594,\n \t \t \t \" IsWarmStart\" : true,\n \t \t \t \" InitTime\" : 0.000029114,\n \t \t \t \" OffloadLatency\" : 0,\n \t \t \t \" Duration\" : 0.002802751,\n \t \t \t \" SchedAction\" : \" \" \n \t \t },\n \t \t \" Simple_c7A3CSJ9efgnW2uCvgWt3Y\" : {\n \t \t \t \" Result\" : \" 4\" ,\n \t \t \t \" ResponseTime\" : 0.002977264,\n \t \t \t \" IsWarmStart\" : true,\n \t \t \t \" InitTime\" : 0.000020023,\n \t \t \t \" OffloadLatency\" : 0,\n \t \t \t \" Duration\" : 0.002953664,\n \t \t \t \" SchedAction\" : \" \" \n \t \t },\n \t \t \" Simple_z4Jp4LXWFoPnEFFNhJQ64j\" : {\n \t \t \t \" Result\" : \" 2\" ,\n \t \t \t \" ResponseTime\" : 15.901950313,\n \t \t \t \" IsWarmStart\" : false,\n \t \t \t \" InitTime\" : 12.705640725,\n \t \t \t \" OffloadLatency\" : 0,\n \t \t \t \" Duration\" : 3.196273017,\n \t \t \t \" SchedAction\" : \" \" \n \t \t },\n \t \t \" Start_wxrH86t6zc2T2menLrUgYm\" : {\n \t \t \t \" Result\" : \" start\" ,\n \t \t \t \" ResponseTime\" : 0,\n \t \t \t \" IsWarmStart\" : false,\n \t \t \t \" InitTime\" : 0,\n \t \t \t \" OffloadLatency\" : 0,\n \t \t \t \" Duration\" : 0,\n \t \t \t \" SchedAction\" : \" \" \n \t \t }\n \t },\n \t \" ResponseTime\" : 0,\n \t \" Result\" : {\n \t \t \" result\" : 4\n \t }\n }"
40
- var retrieved fc.CompositionExecutionReport
41
- errUnmarshal := json .Unmarshal ([]byte (composition ), & retrieved )
42
- fmt .Println (retrieved .String ())
43
- u .AssertNilMsg (t , errUnmarshal , "failed to unmarshal composition result" )
44
- u .AssertNonNilMsg (t , retrieved .Result , "the unmarshalled composition result should not have been nil" )
45
- u .AssertNonNilMsg (t , retrieved .Reports , "the unmarshalled composition result should not have been nil" )
39
+ // composition := "{\n\t\"Reports\": {\n\t\t\"End_9TUZZdXNwgroNYp4akDKQ6\": {\n\t\t\t\"Result\": \"end\",\n\t\t\t\"ResponseTime\": 0,\n\t\t\t\"IsWarmStart\": false,\n\t\t\t\"InitTime\": 0,\n\t\t\t\"OffloadLatency\": 0,\n\t\t\t\"Duration\": 0,\n\t\t\t\"SchedAction\": \"\"\n\t\t},\n\t\t\"Simple_JyzhDkLuBzUVSmPEUiEWVm\": {\n\t\t\t\"Result\": \"3\",\n\t\t\t\"ResponseTime\": 0.00283594,\n\t\t\t\"IsWarmStart\": true,\n\t\t\t\"InitTime\": 0.000029114,\n\t\t\t\"OffloadLatency\": 0,\n\t\t\t\"Duration\": 0.002802751,\n\t\t\t\"SchedAction\": \"\"\n\t\t},\n\t\t\"Simple_c7A3CSJ9efgnW2uCvgWt3Y\": {\n\t\t\t\"Result\": \"4\",\n\t\t\t\"ResponseTime\": 0.002977264,\n\t\t\t\"IsWarmStart\": true,\n\t\t\t\"InitTime\": 0.000020023,\n\t\t\t\"OffloadLatency\": 0,\n\t\t\t\"Duration\": 0.002953664,\n\t\t\t\"SchedAction\": \"\"\n\t\t},\n\t\t\"Simple_z4Jp4LXWFoPnEFFNhJQ64j\": {\n\t\t\t\"Result\": \"2\",\n\t\t\t\"ResponseTime\": 15.901950313,\n\t\t\t\"IsWarmStart\": false,\n\t\t\t\"InitTime\": 12.705640725,\n\t\t\t\"OffloadLatency\": 0,\n\t\t\t\"Duration\": 3.196273017,\n\t\t\t\"SchedAction\": \"\"\n\t\t},\n\t\t\"Start_wxrH86t6zc2T2menLrUgYm\": {\n\t\t\t\"Result\": \"start\",\n\t\t\t\"ResponseTime\": 0,\n\t\t\t\"IsWarmStart\": false,\n\t\t\t\"InitTime\": 0,\n\t\t\t\"OffloadLatency\": 0,\n\t\t\t\"Duration\": 0,\n\t\t\t\"SchedAction\": \"\"\n\t\t}\n\t},\n\t\"ResponseTime\": 0,\n\t\"Result\": {\n\t\t\"result\": 4\n\t}\n}"
46
40
47
41
resultMap := make (map [string ]interface {})
48
42
resultMap ["result" ] = 4.
@@ -54,14 +48,24 @@ func TestUnmarshalFunctionCompositionResult(t *testing.T) {
54
48
reportsMap .Set ("Start_wxrH86t6zc2T2menLrUgYm" , & function.ExecutionReport {ResponseTime : 0.000000 , IsWarmStart : false , InitTime : 0.000000 , OffloadLatency : 0.000000 , Duration : 0.000000 , SchedAction : "" , Output : "" , Result : "start" })
55
49
reportsMap .Set ("Simple_z4Jp4LXWFoPnEFFNhJQ64j" , & function.ExecutionReport {ResponseTime : 15.901950313 , IsWarmStart : false , InitTime : 12.705640725 , OffloadLatency : 0.000000 , Duration : 3.196273017 , SchedAction : "" , Output : "" , Result : "2" })
56
50
57
- expected := fc.CompositionExecutionReport {
51
+ expected := & fc.CompositionExecutionReport {
58
52
Result : resultMap ,
59
53
Reports : reportsMap ,
60
54
ResponseTime : 0.000000 ,
61
55
// Progress is not checked
62
56
}
63
57
64
- u .AssertTrueMsg (t , retrieved .Equals (& expected ), fmt .Sprintf ("execution report differs first: %s\n second: %s" , retrieved .String (), expected .String ()))
58
+ marshal , errMarshal := json .Marshal (expected )
59
+ u .AssertNil (t , errMarshal )
60
+
61
+ var retrieved fc.CompositionExecutionReport
62
+ errUnmarshal := json .Unmarshal (marshal , & retrieved )
63
+
64
+ u .AssertNilMsg (t , errUnmarshal , "failed to unmarshal composition result" )
65
+ u .AssertNonNilMsg (t , retrieved .Result , "the unmarshalled composition result should not have been nil" )
66
+ u .AssertNonNilMsg (t , retrieved .Reports , "the unmarshalled composition result should not have been nil" )
67
+
68
+ u .AssertTrueMsg (t , retrieved .Equals (expected ), fmt .Sprintf ("execution report differs first: %v\n second: %v" , retrieved , expected ))
65
69
}
66
70
67
71
// TestComposeFC checks the CREATE, GET and DELETE functionality of the Function Composition
0 commit comments