@@ -721,11 +721,14 @@ func TestServiceProviderUpdate(t *testing.T) {
721
721
verifyServiceCreate (t , "default" , "yellow" , "redis" , port , labels , "" )
722
722
723
723
containerID := "723e55bf5b244f47c1b184cb786a1c2ad8870cc3a3db723c49ac09f68a9d1e69"
724
+ container := "657355bf5b244f47c1b184cb786a14535d8870cc3a3db723c49ac09f68a9d6a5"
724
725
725
- triggerProviderUpdate (t , "20.1.1.1" , "orange" , containerID , "default" , "start" , labels )
726
+ createEP (t , "20.1.1.1" , "orange" , containerID , "default" , container , labels )
727
+ triggerProviderUpdate (t , "20.1.1.1" , "orange" , containerID , container , "default" , "start" , labels )
726
728
verifyProviderUpdate (t , "20.1.1.1" , "orange" , containerID , "default" , "start" , "redis" , labels )
727
- triggerProviderUpdate (t , "20.1.1.1" , "orange" , containerID , "default" , "die" , labels )
729
+ triggerProviderUpdate (t , "20.1.1.1" , "orange" , containerID , container , "default" , "die" , labels )
728
730
verifyProviderUpdate (t , "20.1.1.1" , "orange" , containerID , "default" , "die" , "redis" , labels )
731
+ deleteEP (t , "orange" , "default" , container )
729
732
checkServiceDelete (t , "default" , "redis" )
730
733
verifyServiceDelete (t , "default" , "redis" )
731
734
deleteNetwork (t , "orange" , "default" )
@@ -738,17 +741,19 @@ func TestServiceProviderUpdateServiceAdd(t *testing.T) {
738
741
port := []string {"80:8080:TCP" }
739
742
740
743
containerID := "723e55bf5b244f47c1b184cb786a1c2ad8870cc3a3db723c49ac09f68a9d1e69"
744
+ container := "657355bf5b244f47c1b184cb786a14535d8870cc3a3db723c49ac09f68a9d6a5"
741
745
742
746
createNetwork (t , "orange" , "default" , "vxlan" , "11.1.1.0/24" , "11.1.1.254" )
743
- triggerProviderUpdate (t , "20.1.1.1" , "orange" , containerID , "default" , "start" , labels )
744
-
747
+ createEP (t , "20.1.1.1" , "orange" , containerID , "default" , container , labels )
748
+ triggerProviderUpdate ( t , "20.1.1.1" , "orange" , containerID , container , "default" , "start" , labels )
745
749
createNetwork (t , "yellow" , "default" , "vxlan" , "10.1.1.0/24" , "10.1.1.254" )
746
750
checkServiceCreate (t , "default" , "yellow" , "redis" , port , labels , "" )
747
751
verifyServiceCreate (t , "default" , "yellow" , "redis" , port , labels , "" )
748
752
749
753
verifyProviderUpdate (t , "20.1.1.1" , "orange" , containerID , "default" , "start" , "redis" , labels )
750
- triggerProviderUpdate (t , "20.1.1.1" , "orange" , containerID , "default" , "die" , labels )
754
+ triggerProviderUpdate (t , "20.1.1.1" , "orange" , containerID , container , "default" , "die" , labels )
751
755
verifyProviderUpdate (t , "20.1.1.1" , "orange" , containerID , "default" , "die" , "redis" , labels )
756
+ deleteEP (t , "orange" , "default" , container )
752
757
checkServiceDelete (t , "default" , "redis" )
753
758
verifyServiceDelete (t , "default" , "redis" )
754
759
deleteNetwork (t , "orange" , "default" )
@@ -842,7 +847,7 @@ func verifyServiceDelete(t *testing.T, tenant, serviceName string) {
842
847
}
843
848
}
844
849
845
- func triggerProviderUpdate (t * testing.T , providerIP , network , containerID ,
850
+ func triggerProviderUpdate (t * testing.T , providerIP , network , containerID , container ,
846
851
tenant , event string , labels []string ) {
847
852
848
853
providerUpdReq := master.SvcProvUpdateRequest {}
@@ -852,6 +857,7 @@ func triggerProviderUpdate(t *testing.T, providerIP, network, containerID,
852
857
providerUpdReq .Network = network
853
858
providerUpdReq .Event = event
854
859
providerUpdReq .Labels = make (map [string ]string )
860
+ providerUpdReq .Container = container
855
861
856
862
for _ , v := range labels {
857
863
key := strings .Split (v , "=" )[0 ]
@@ -995,4 +1001,37 @@ func get(getAll bool, hook func(id string) ([]core.State, error)) func(http.Resp
995
1001
}
996
1002
}
997
1003
1004
+ func createEP (t * testing.T , providerIP , network , containerID , tenant , container string , labels []string ) {
1005
+
1006
+ epCfg := & mastercfg.CfgEndpointState {
1007
+ NetID : network ,
1008
+ ContName : containerID ,
1009
+ AttachUUID : container ,
1010
+ IPAddress : providerIP ,
1011
+ }
1012
+ epCfg .Labels = make (map [string ]string )
1013
+ for _ , v := range labels {
1014
+ key := strings .Split (v , "=" )[0 ]
1015
+ value := strings .Split (v , "=" )[1 ]
1016
+ epCfg .Labels [key ] = value
1017
+ }
1018
+ epCfg .StateDriver = stateStore
1019
+ netID := network + "." + tenant
1020
+ epCfg .ID = netID + "-" + container
1021
+ err := epCfg .Write ()
1022
+ if err != nil {
1023
+ t .Errorf ("Error creating Ep :%s" , err )
1024
+ }
1025
+ }
1026
+ func deleteEP (t * testing.T , network , tenant , container string ) {
1027
+ epCfg := & mastercfg.CfgEndpointState {}
1028
+ epCfg .StateDriver = stateStore
1029
+ netID := network + "." + tenant
1030
+ epCfg .ID = netID + "-" + container
1031
+ err := epCfg .Clear ()
1032
+ if err != nil {
1033
+ t .Errorf ("Error deleting Ep :%s" , err )
1034
+ }
1035
+ }
1036
+
998
1037
type httpAPIFunc func (w http.ResponseWriter , r * http.Request , vars map [string ]string ) (interface {}, error )
0 commit comments