Skip to content

Commit e27dd98

Browse files
committed
Make use of hex string instead of FDB printable to remove test failures because of special characters
1 parent 2fb4154 commit e27dd98

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

e2e/fixtures/status.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ func (fdbCluster *FdbCluster) GetCommandlineForProcessesPerClassWithStatus(
533533
}
534534

535535
// FdbPrintable copied from foundationdb bindings/go/src/fdb/fdb.go func Printable(d []byte) string
536-
// Printable returns a human readable version of a byte array. The bytes that correspond with
536+
// Printable returns a human-readable version of a byte array. The bytes that correspond with
537537
// ASCII printable characters [32-127) are passed through. Other bytes are
538538
// replaced with \x followed by a two character zero-padded hex code for byte.
539539
func FdbPrintable(d []byte) string {
@@ -554,6 +554,21 @@ func FdbPrintable(d []byte) string {
554554
return buf.String()
555555
}
556556

557+
// FdbHexString returns a string where bytes are replaced with \x followed by a two character zero-padded hex code for byte.
558+
func FdbHexString(d []byte) string {
559+
buf := new(bytes.Buffer)
560+
for _, b := range d {
561+
if b == '\\' {
562+
buf.WriteString("\\\\")
563+
continue
564+
}
565+
566+
_, _ = fmt.Fprintf(buf, "\\x%02x", b)
567+
}
568+
569+
return buf.String()
570+
}
571+
557572
// FdbStrinc returns the first key that would sort outside the range prefixed by
558573
// // prefix, or an error if prefix is empty or contains only 0xFF bytes.
559574
// Copied from foundationdb bindings/go/src/fdb/range.go func Strinc(prefix []byte) ([]byte, error)

e2e/test_operator/operator_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,7 @@ var _ = Describe("Operator", Label("e2e", "pr"), func() {
19441944
cmd := fmt.Sprintf(
19451945
"writemode on; option on ACCESS_SYSTEM_KEYS; set %s %s",
19461946
fixtures.FdbPrintable([]byte(key)),
1947-
fixtures.FdbPrintable(timestampByteBuffer.Bytes()),
1947+
fixtures.FdbHexString(timestampByteBuffer.Bytes()),
19481948
)
19491949
_, _, err := fdbCluster.RunFdbCliCommandInOperatorWithoutRetry(cmd, true, 20)
19501950

0 commit comments

Comments
 (0)