diff --git a/d2chaos/d2chaos.go b/d2chaos/d2chaos.go index efa4ecc9a..910c99935 100644 --- a/d2chaos/d2chaos.go +++ b/d2chaos/d2chaos.go @@ -15,6 +15,8 @@ import ( "oss.terrastruct.com/d2/d2target" ) +const complexIDs = false + func GenDSL(maxi int) (_ string, err error) { gs := &dslGenState{ rand: mathrand.New(mathrand.NewSource(time.Now().UnixNano())), @@ -62,7 +64,11 @@ func (gs *dslGenState) gen(maxi int) error { } func (gs *dslGenState) genNode(containerID string) (string, error) { - nodeID := gs.randStr(8, true) + maxLen := 8 + if complexIDs { + maxLen = 32 + } + nodeID := gs.randStr(maxLen, true) if containerID != "" { nodeID = containerID + "." + nodeID } @@ -95,7 +101,11 @@ func (gs *dslGenState) node() error { if gs.roll(25, 75) == 0 { // 25% chance of adding a label. - gs.g, err = d2oracle.Set(gs.g, nodeID, nil, go2.Pointer(gs.randStr(8, false))) + maxLen := 8 + if complexIDs { + maxLen = 256 + } + gs.g, err = d2oracle.Set(gs.g, nodeID, nil, go2.Pointer(gs.randStr(maxLen, false))) if err != nil { return err } @@ -154,7 +164,11 @@ func (gs *dslGenState) edge() error { return err } if gs.randBool() { - gs.g, err = d2oracle.Set(gs.g, key, nil, go2.Pointer(gs.randStr(8, false))) + maxLen := 8 + if complexIDs { + maxLen = 128 + } + gs.g, err = d2oracle.Set(gs.g, key, nil, go2.Pointer(gs.randStr(maxLen, false))) if err != nil { return err } @@ -191,7 +205,15 @@ func (gs *dslGenState) randBool() bool { // TODO go back to using xrand.String, currently some incompatibility with // stuffing these strings into a script for dagre func randRune() rune { - return mathrand.Int31n(26) + 97 + if complexIDs { + if mathrand.Int31n(100) == 0 { + // Generate newline 1% of the time. + return '\n' + } + return mathrand.Int31n(128) + 1 + } else { + return mathrand.Int31n(26) + 97 + } } func (gs *dslGenState) findOuterSequenceDiagram(nodeID string) string {