@@ -877,22 +877,61 @@ func TestServiceProviderUpdate(t *testing.T) {
877
877
878
878
labels := []string {"key1=value1" , "key2=value2" }
879
879
port := []string {"80:8080:TCP" }
880
+ ch := make (chan error , 1 )
880
881
881
882
createNetwork (t , "yellow" , "default" , "vxlan" , "10.1.1.0/24" , "10.1.1.254" )
882
883
createNetwork (t , "orange" , "default" , "vxlan" , "11.1.1.0/24" , "11.1.1.254" )
883
884
884
885
checkServiceCreate (t , "default" , "yellow" , "redis" , port , labels , "" )
885
886
verifyServiceCreate (t , "default" , "yellow" , "redis" , port , labels , "" )
886
887
887
- containerID := "723e55bf5b244f47c1b184cb786a1c2ad8870cc3a3db723c49ac09f68a9d1e69"
888
- container := "657355bf5b244f47c1b184cb786a14535d8870cc3a3db723c49ac09f68a9d6a5"
888
+ containerID1 := "723e55bf5b244f47c1b184cb786a1c2ad8870cc3a3db723c49ac09f68a9d1e69"
889
+ containerID2 := "823e55bf5b244f47c1b184cb786a1c2ad8870cc3a3db723c49ac09f68a9d1e69"
890
+ containerID3 := "023e55bf5b244f47c1b184cb786a1c2ad8870cc3a3db723c49ac09f68a9d1e69"
891
+ containerID4 := "123e55bf5b244f47c1b184cb786a1c2ad8870cc3a3db723c49ac09f68a9d1e69"
892
+ container1 := "657355bf5b244f47c1b184cb786a14535d8870cc3a3db723c49ac09f68a9d6a5"
893
+ container2 := "757355bf5b244f47c1b184cb786a14535d8870cc3a3db723c49ac09f68a9d6a5"
894
+ container3 := "857355bf5b244f47c1b184cb786a14535d8870cc3a3db723c49ac09f68a9d6a5"
895
+ container4 := "957355bf5b244f47c1b184cb786a14535d8870cc3a3db723c49ac09f68a9d6a5"
896
+
897
+ createEP (t , "20.1.1.1" , "orange" , containerID1 , "default" , container1 , labels )
898
+ createEP (t , "20.1.1.2" , "orange" , containerID2 , "default" , container2 , labels )
899
+ createEP (t , "20.1.1.3" , "orange" , containerID3 , "default" , container3 , labels )
900
+ createEP (t , "20.1.1.4" , "orange" , containerID4 , "default" , container4 , labels )
901
+
902
+ go triggerProviderUpdate (t , "20.1.1.1" , "orange" , containerID1 , container1 , "default" , "start" , labels , ch )
903
+ go triggerProviderUpdate (t , "20.1.1.2" , "orange" , containerID2 , container2 , "default" , "start" , labels , ch )
904
+ go triggerProviderUpdate (t , "20.1.1.3" , "orange" , containerID3 , container3 , "default" , "start" , labels , ch )
905
+ go triggerProviderUpdate (t , "20.1.1.4" , "orange" , containerID4 , container4 , "default" , "start" , labels , ch )
906
+
907
+ for i := 0 ; i < 4 ; i ++ {
908
+ <- ch
909
+ }
910
+
911
+ verifyProviderUpdate (t , "20.1.1.1" , "orange" , containerID1 , "default" , "start" , "redis" , labels )
912
+ verifyProviderUpdate (t , "20.1.1.2" , "orange" , containerID2 , "default" , "start" , "redis" , labels )
913
+ verifyProviderUpdate (t , "20.1.1.3" , "orange" , containerID3 , "default" , "start" , "redis" , labels )
914
+ verifyProviderUpdate (t , "20.1.1.4" , "orange" , containerID4 , "default" , "start" , "redis" , labels )
915
+
916
+ go triggerProviderUpdate (t , "20.1.1.1" , "orange" , containerID1 , container1 , "default" , "die" , labels , ch )
917
+ go triggerProviderUpdate (t , "20.1.1.2" , "orange" , containerID2 , container2 , "default" , "die" , labels , ch )
918
+ go triggerProviderUpdate (t , "20.1.1.3" , "orange" , containerID3 , container3 , "default" , "die" , labels , ch )
919
+ go triggerProviderUpdate (t , "20.1.1.4" , "orange" , containerID4 , container4 , "default" , "die" , labels , ch )
920
+
921
+ for i := 0 ; i < 4 ; i ++ {
922
+ <- ch
923
+ }
924
+
925
+ verifyProviderUpdate (t , "20.1.1.1" , "orange" , containerID1 , "default" , "die" , "redis" , labels )
926
+ verifyProviderUpdate (t , "20.1.1.2" , "orange" , containerID2 , "default" , "die" , "redis" , labels )
927
+ verifyProviderUpdate (t , "20.1.1.3" , "orange" , containerID3 , "default" , "die" , "redis" , labels )
928
+ verifyProviderUpdate (t , "20.1.1.4" , "orange" , containerID4 , "default" , "die" , "redis" , labels )
929
+
930
+ deleteEP (t , "orange" , "default" , container1 )
931
+ deleteEP (t , "orange" , "default" , container2 )
932
+ deleteEP (t , "orange" , "default" , container3 )
933
+ deleteEP (t , "orange" , "default" , container4 )
889
934
890
- createEP (t , "20.1.1.1" , "orange" , containerID , "default" , container , labels )
891
- triggerProviderUpdate (t , "20.1.1.1" , "orange" , containerID , container , "default" , "start" , labels )
892
- verifyProviderUpdate (t , "20.1.1.1" , "orange" , containerID , "default" , "start" , "redis" , labels )
893
- triggerProviderUpdate (t , "20.1.1.1" , "orange" , containerID , container , "default" , "die" , labels )
894
- verifyProviderUpdate (t , "20.1.1.1" , "orange" , containerID , "default" , "die" , "redis" , labels )
895
- deleteEP (t , "orange" , "default" , container )
896
935
checkServiceDelete (t , "default" , "redis" )
897
936
verifyServiceDelete (t , "default" , "redis" )
898
937
deleteNetwork (t , "orange" , "default" )
@@ -903,21 +942,60 @@ func TestServiceProviderUpdateServiceAdd(t *testing.T) {
903
942
904
943
labels := []string {"key1=value1" , "key2=value2" }
905
944
port := []string {"80:8080:TCP" }
945
+ ch := make (chan error , 1 )
906
946
907
- containerID := "723e55bf5b244f47c1b184cb786a1c2ad8870cc3a3db723c49ac09f68a9d1e69"
908
- container := "657355bf5b244f47c1b184cb786a14535d8870cc3a3db723c49ac09f68a9d6a5"
947
+ containerID1 := "723e55bf5b244f47c1b184cb786a1c2ad8870cc3a3db723c49ac09f68a9d1e69"
948
+ containerID2 := "823e55bf5b244f47c1b184cb786a1c2ad8870cc3a3db723c49ac09f68a9d1e69"
949
+ containerID3 := "023e55bf5b244f47c1b184cb786a1c2ad8870cc3a3db723c49ac09f68a9d1e69"
950
+ containerID4 := "123e55bf5b244f47c1b184cb786a1c2ad8870cc3a3db723c49ac09f68a9d1e69"
951
+ container1 := "657355bf5b244f47c1b184cb786a14535d8870cc3a3db723c49ac09f68a9d6a5"
952
+ container2 := "757355bf5b244f47c1b184cb786a14535d8870cc3a3db723c49ac09f68a9d6a5"
953
+ container3 := "857355bf5b244f47c1b184cb786a14535d8870cc3a3db723c49ac09f68a9d6a5"
954
+ container4 := "957355bf5b244f47c1b184cb786a14535d8870cc3a3db723c49ac09f68a9d6a5"
909
955
910
956
createNetwork (t , "orange" , "default" , "vxlan" , "11.1.1.0/24" , "11.1.1.254" )
911
- createEP (t , "20.1.1.1" , "orange" , containerID , "default" , container , labels )
912
- triggerProviderUpdate (t , "20.1.1.1" , "orange" , containerID , container , "default" , "start" , labels )
957
+
958
+ createEP (t , "20.1.1.1" , "orange" , containerID1 , "default" , container1 , labels )
959
+ createEP (t , "20.1.1.2" , "orange" , containerID2 , "default" , container2 , labels )
960
+ createEP (t , "20.1.1.3" , "orange" , containerID3 , "default" , container3 , labels )
961
+ createEP (t , "20.1.1.4" , "orange" , containerID4 , "default" , container4 , labels )
962
+
963
+ go triggerProviderUpdate (t , "20.1.1.1" , "orange" , containerID1 , container1 , "default" , "start" , labels , ch )
964
+ go triggerProviderUpdate (t , "20.1.1.2" , "orange" , containerID2 , container2 , "default" , "start" , labels , ch )
965
+ go triggerProviderUpdate (t , "20.1.1.3" , "orange" , containerID3 , container3 , "default" , "start" , labels , ch )
966
+ go triggerProviderUpdate (t , "20.1.1.4" , "orange" , containerID4 , container4 , "default" , "start" , labels , ch )
967
+
968
+ for i := 0 ; i < 4 ; i ++ {
969
+ <- ch
970
+ }
971
+
913
972
createNetwork (t , "yellow" , "default" , "vxlan" , "10.1.1.0/24" , "10.1.1.254" )
914
973
checkServiceCreate (t , "default" , "yellow" , "redis" , port , labels , "" )
915
974
verifyServiceCreate (t , "default" , "yellow" , "redis" , port , labels , "" )
916
975
917
- verifyProviderUpdate (t , "20.1.1.1" , "orange" , containerID , "default" , "start" , "redis" , labels )
918
- triggerProviderUpdate (t , "20.1.1.1" , "orange" , containerID , container , "default" , "die" , labels )
919
- verifyProviderUpdate (t , "20.1.1.1" , "orange" , containerID , "default" , "die" , "redis" , labels )
920
- deleteEP (t , "orange" , "default" , container )
976
+ verifyProviderUpdate (t , "20.1.1.1" , "orange" , containerID1 , "default" , "start" , "redis" , labels )
977
+ verifyProviderUpdate (t , "20.1.1.2" , "orange" , containerID2 , "default" , "start" , "redis" , labels )
978
+ verifyProviderUpdate (t , "20.1.1.3" , "orange" , containerID3 , "default" , "start" , "redis" , labels )
979
+ verifyProviderUpdate (t , "20.1.1.4" , "orange" , containerID4 , "default" , "start" , "redis" , labels )
980
+
981
+ go triggerProviderUpdate (t , "20.1.1.1" , "orange" , containerID1 , container1 , "default" , "die" , labels , ch )
982
+ go triggerProviderUpdate (t , "20.1.1.2" , "orange" , containerID2 , container2 , "default" , "die" , labels , ch )
983
+ go triggerProviderUpdate (t , "20.1.1.3" , "orange" , containerID3 , container3 , "default" , "die" , labels , ch )
984
+ go triggerProviderUpdate (t , "20.1.1.4" , "orange" , containerID4 , container4 , "default" , "die" , labels , ch )
985
+ for i := 0 ; i < 4 ; i ++ {
986
+ <- ch
987
+ }
988
+
989
+ verifyProviderUpdate (t , "20.1.1.1" , "orange" , containerID1 , "default" , "die" , "redis" , labels )
990
+ verifyProviderUpdate (t , "20.1.1.2" , "orange" , containerID2 , "default" , "die" , "redis" , labels )
991
+ verifyProviderUpdate (t , "20.1.1.3" , "orange" , containerID3 , "default" , "die" , "redis" , labels )
992
+ verifyProviderUpdate (t , "20.1.1.4" , "orange" , containerID4 , "default" , "die" , "redis" , labels )
993
+
994
+ deleteEP (t , "orange" , "default" , container1 )
995
+ deleteEP (t , "orange" , "default" , container2 )
996
+ deleteEP (t , "orange" , "default" , container3 )
997
+ deleteEP (t , "orange" , "default" , container4 )
998
+
921
999
checkServiceDelete (t , "default" , "redis" )
922
1000
verifyServiceDelete (t , "default" , "redis" )
923
1001
deleteNetwork (t , "orange" , "default" )
@@ -935,6 +1013,7 @@ func TestServicePreferredIP(t *testing.T) {
935
1013
checkServiceDelete (t , "default" , "redis" )
936
1014
deleteNetwork (t , "yellow" , "default" )
937
1015
}
1016
+
938
1017
func checkServiceCreate (t * testing.T , tenant , network , serviceName string , port []string , label []string ,
939
1018
preferredIP string ) {
940
1019
@@ -1012,7 +1091,7 @@ func verifyServiceDelete(t *testing.T, tenant, serviceName string) {
1012
1091
}
1013
1092
1014
1093
func triggerProviderUpdate (t * testing.T , providerIP , network , containerID , container ,
1015
- tenant , event string , labels []string ) {
1094
+ tenant , event string , labels []string , ch chan error ) {
1016
1095
1017
1096
providerUpdReq := master.SvcProvUpdateRequest {}
1018
1097
providerUpdReq .IPAddress = providerIP
@@ -1032,20 +1111,25 @@ func triggerProviderUpdate(t *testing.T, providerIP, network, containerID, conta
1032
1111
1033
1112
jsonStr , err := json .Marshal (providerUpdReq )
1034
1113
if err != nil {
1114
+ ch <- err
1035
1115
t .Fatalf ("Error converting request data(%#v) to Json. Err: %v" , providerUpdReq , err )
1036
1116
}
1037
1117
url := netmasterTestURL + "/plugin/svcProviderUpdate"
1038
1118
// Perform HTTP POST operation
1039
1119
res , err := http .Post (url , "application/json" , strings .NewReader (string (jsonStr )))
1040
1120
if err != nil {
1041
1121
t .Fatalf ("Error during http get. Err: %v" , err )
1122
+ ch <- err
1042
1123
}
1043
1124
1044
1125
// Check the response code
1045
1126
if res .StatusCode != http .StatusOK {
1127
+ ch <- err
1046
1128
t .Fatalf ("HTTP error response. Status: %s, StatusCode: %d" , res .Status , res .StatusCode )
1047
1129
}
1048
1130
1131
+ ch <- nil
1132
+
1049
1133
}
1050
1134
func verifyProviderUpdate (t * testing.T , providerIP , network , containerID ,
1051
1135
tenant , event , service string , labels []string ) {
0 commit comments