99 "context"
1010 "fmt"
1111 "math/rand"
12+ "path/filepath"
1213 "slices"
1314 "sort"
1415 "strconv"
@@ -329,8 +330,9 @@ func testingGetPendingChanges(t *testing.T, cs *clusterState) []*pendingReplicaC
329330}
330331
331332func TestClusterState (t * testing.T ) {
333+ tdPath := datapathutils .TestDataPath (t , "cluster_state" )
332334 datadriven .Walk (t ,
333- datapathutils . TestDataPath ( t , "cluster_state" ) ,
335+ tdPath ,
334336 func (t * testing.T , path string ) {
335337 ts := timeutil .NewManualTime (time .Date (2025 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ))
336338 cs := newClusterState (ts , newStringInterner ())
@@ -355,8 +357,15 @@ func TestClusterState(t *testing.T) {
355357 return buf .String ()
356358 }
357359
358- datadriven .RunTest (t , path , func (t * testing.T , d * datadriven.TestData ) string {
360+ // Recursively invoked in `include` directive.
361+ var invokeFn func (t * testing.T , d * datadriven.TestData ) string
362+ invokeFn = func (t * testing.T , d * datadriven.TestData ) string {
359363 switch d .Cmd {
364+ case "include" :
365+ loc := dd .ScanArg [string ](t , d , "path" )
366+ datadriven .RunTest (t , filepath .Join (tdPath , loc ), invokeFn )
367+ return "ok"
368+
360369 case "ranges" :
361370 var rangeIDs []int
362371 for rangeID := range cs .ranges {
@@ -544,7 +553,8 @@ func TestClusterState(t *testing.T) {
544553 default :
545554 panic (fmt .Sprintf ("unknown command: %v" , d .Cmd ))
546555 }
547- },
548- )
556+ }
557+
558+ datadriven .RunTest (t , path , invokeFn )
549559 })
550560}
0 commit comments