testing chaos with more readable/simpler ids and labels

This commit is contained in:
Gavin Nishizawa 2023-02-03 17:20:12 -08:00
parent 088ba0f4a7
commit bb47f98bf0
No known key found for this signature in database
GPG key ID: AE3B177777CE55CD

View file

@ -62,7 +62,7 @@ func (gs *dslGenState) gen(maxi int) error {
} }
func (gs *dslGenState) genNode(containerID string) (string, error) { func (gs *dslGenState) genNode(containerID string) (string, error) {
nodeID := gs.randStr(32, true) nodeID := gs.randStr(8, true)
if containerID != "" { if containerID != "" {
nodeID = containerID + "." + nodeID nodeID = containerID + "." + nodeID
} }
@ -95,7 +95,7 @@ func (gs *dslGenState) node() error {
if gs.roll(25, 75) == 0 { if gs.roll(25, 75) == 0 {
// 25% chance of adding a label. // 25% chance of adding a label.
gs.g, err = d2oracle.Set(gs.g, nodeID, nil, go2.Pointer(gs.randStr(256, false))) gs.g, err = d2oracle.Set(gs.g, nodeID, nil, go2.Pointer(gs.randStr(8, false)))
if err != nil { if err != nil {
return err return err
} }
@ -154,7 +154,7 @@ func (gs *dslGenState) edge() error {
return err return err
} }
if gs.randBool() { if gs.randBool() {
gs.g, err = d2oracle.Set(gs.g, key, nil, go2.Pointer(gs.randStr(128, false))) gs.g, err = d2oracle.Set(gs.g, key, nil, go2.Pointer(gs.randStr(8, false)))
if err != nil { if err != nil {
return err return err
} }
@ -191,11 +191,7 @@ func (gs *dslGenState) randBool() bool {
// TODO go back to using xrand.String, currently some incompatibility with // TODO go back to using xrand.String, currently some incompatibility with
// stuffing these strings into a script for dagre // stuffing these strings into a script for dagre
func randRune() rune { func randRune() rune {
if mathrand.Int31n(100) == 0 { return mathrand.Int31n(26) + 97
// Generate newline 1% of the time.
return '\n'
}
return mathrand.Int31n(128) + 1
} }
func (gs *dslGenState) findOuterSequenceDiagram(nodeID string) string { func (gs *dslGenState) findOuterSequenceDiagram(nodeID string) string {