@@ -177,3 +177,48 @@ func TestReplicationStopAndUse_DelegateToSingleTemplates(t *testing.T) {
177177 }
178178 }
179179}
180+
181+ // TestInitSlavesTemplates_IncludeReplicaReadyWait ensures that the
182+ // replication initialization templates (used by "deploy replication")
183+ // contain the wait_until_replica_ready logic introduced to fix #131.
184+ // This is a pure template test and does not require any MySQL binaries.
185+ func TestInitSlavesTemplates_IncludeReplicaReadyWait (t * testing.T ) {
186+ for name , tmplContent := range map [string ]string {
187+ "init_slaves" : initSlavesTemplate ,
188+ "init_slaves_84" : initSlaves84Template ,
189+ } {
190+ data := common.StringMap {
191+ "ShellPath" : "/bin/bash" ,
192+ "Copyright" : "# test" ,
193+ "AppVersion" : "test" ,
194+ "DateTime" : "now" ,
195+ "TemplateName" : name ,
196+ "SandboxDir" : "/tmp/rsandbox_1234" ,
197+ "MasterLabel" : "master" ,
198+ "MasterIp" : "127.0.0.1" ,
199+ "RplUser" : "rsandbox" ,
200+ "RplPassword" : "rsandbox" ,
201+ "MasterAutoPosition" : "" ,
202+ "ChangeMasterExtra" : "" ,
203+ "StartReplica" : "START REPLICA" ,
204+ "NodeLabel" : "n" ,
205+ "SlaveLabel" : "slave" ,
206+ "Slaves" : []common.StringMap {
207+ {"NodeLabel" : "n" , "Node" : 1 , "SlaveLabel" : "slave" },
208+ {"NodeLabel" : "n" , "Node" : 2 , "SlaveLabel" : "slave" },
209+ },
210+ }
211+ result := renderTemplate (t , tmplContent , data )
212+
213+ if ! strings .Contains (result , "wait_until_replica_ready" ) {
214+ t .Errorf ("%s template must define the wait_until_replica_ready helper (regression for #131)" , name )
215+ }
216+ // The call must appear for each slave after the START REPLICA line.
217+ if ! strings .Contains (result , `wait_until_replica_ready "$SBDIR/n1/use" 60 1` ) {
218+ t .Errorf ("%s template must invoke wait for the first replica" , name )
219+ }
220+ if ! strings .Contains (result , `wait_until_replica_ready "$SBDIR/n2/use" 60 1` ) {
221+ t .Errorf ("%s template must invoke wait for the second replica" , name )
222+ }
223+ }
224+ }
0 commit comments