@@ -235,15 +235,16 @@ func NewCluster(in *ClusterInput) *Cluster {
235235
236236 wg := sync.WaitGroup {}
237237 wg .Add (len (out .Nodes ))
238- for _ , node := range out .Nodes {
239- go func (node string ) {
238+ for i , node := range out .Nodes {
239+ go func (i int , node string ) {
240240 defer wg .Done ()
241241 CopyFilesToNode (in , node )
242242 CopyDirsToNode (in , node )
243243 if in .CreateRegularUser {
244244 CreateRegularUser (in , node )
245245 }
246- }(node )
246+ out .waitForClockSync (i )
247+ }(i , node )
247248 }
248249 wg .Wait ()
249250
@@ -1136,6 +1137,23 @@ func (c *Cluster) Cleanup(envs ...map[string]string) {
11361137 c .copyPlaywrightReport ()
11371138}
11381139
1140+ func (c * Cluster ) waitForClockSync (node int ) {
1141+ timeout := time .After (5 * time .Minute )
1142+ tick := time .Tick (time .Second )
1143+ for {
1144+ select {
1145+ case <- timeout :
1146+ stdout , stderr , err := c .RunCommandOnNode (node , []string {"timedatectl" , "show" , "-p" , "NTP" , "-p" , "CanNTP" , "-p" , "NTPSynchronized" })
1147+ c .T .Fatalf ("timeout waiting for clock sync on node %d: %v: %s: %s" , node , err , stdout , stderr )
1148+ case <- tick :
1149+ status , _ , _ := c .RunCommandOnNode (node , []string {"timedatectl" , "show" , "-p" , "NTPSynchronized" })
1150+ if strings .Contains (status , "NTPSynchronized=yes" ) {
1151+ return
1152+ }
1153+ }
1154+ }
1155+ }
1156+
11391157func (c * Cluster ) SetupPlaywrightAndRunTest (testName string , args ... string ) (string , string , error ) {
11401158 if err := c .SetupPlaywright (); err != nil {
11411159 return "" , "" , fmt .Errorf ("failed to setup playwright: %w" , err )
0 commit comments