From: Sage Weil Date: Sat, 8 Feb 2020 19:13:11 +0000 (-0600) Subject: common/TextTable: default to 2 spaces separating columns X-Git-Tag: v15.1.1~276^2~4 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=4d42b4c5a0ed7153296ed60c408813ac0cc478f8;p=ceph-ci.git common/TextTable: default to 2 spaces separating columns This is what other projects and libraries default to, and it is more legible. Signed-off-by: Sage Weil --- diff --git a/qa/standalone/crush/crush-choose-args.sh b/qa/standalone/crush/crush-choose-args.sh index d2c33cfed26..daadc2a8571 100755 --- a/qa/standalone/crush/crush-choose-args.sh +++ b/qa/standalone/crush/crush-choose-args.sh @@ -176,19 +176,19 @@ function TEST_reweight() { ceph osd crush weight-set reweight-compat osd.0 2 || return 1 ceph osd crush tree - ceph osd crush tree | grep host | grep '6.00000 5.00000' || return 1 + ceph osd crush tree | grep host | grep '6.00000 5.00000' || return 1 run_osd $dir 2 || return 1 ceph osd crush tree - ceph osd crush tree | grep host | grep '9.00000 5.00000' || return 1 + ceph osd crush tree | grep host | grep '9.00000 5.00000' || return 1 ceph osd crush reweight osd.2 4 ceph osd crush tree - ceph osd crush tree | grep host | grep '10.00000 5.00000' || return 1 + ceph osd crush tree | grep host | grep '10.00000 5.00000' || return 1 ceph osd crush weight-set reweight-compat osd.2 4 ceph osd crush tree - ceph osd crush tree | grep host | grep '10.00000 9.00000' || return 1 + ceph osd crush tree | grep host | grep '10.00000 9.00000' || return 1 } function TEST_move_bucket() { @@ -203,37 +203,37 @@ function TEST_move_bucket() { ceph osd crush weight-set reweight-compat osd.0 2 || return 1 ceph osd crush weight-set reweight-compat osd.1 2 || return 1 ceph osd crush tree - ceph osd crush tree | grep HOST | grep '6.00000 4.00000' || return 1 + ceph osd crush tree | grep HOST | grep '6.00000 4.00000' || return 1 # moving a bucket adjusts the weights ceph osd crush add-bucket RACK rack root=default || return 1 ceph osd crush move HOST rack=RACK || return 1 ceph osd crush tree - ceph osd crush tree | grep HOST | grep '6.00000 4.00000' || return 1 - ceph osd crush tree | grep RACK | grep '6.00000 4.00000' || return 1 + ceph osd crush tree | grep HOST | grep '6.00000 4.00000' || return 1 + ceph osd crush tree | grep RACK | grep '6.00000 4.00000' || return 1 # weight-set reweight adjusts containing buckets ceph osd crush weight-set reweight-compat osd.0 1 || return 1 ceph osd crush tree - ceph osd crush tree | grep HOST | grep '6.00000 3.00000' || return 1 - ceph osd crush tree | grep RACK | grep '6.00000 3.00000' || return 1 + ceph osd crush tree | grep HOST | grep '6.00000 3.00000' || return 1 + ceph osd crush tree | grep RACK | grep '6.00000 3.00000' || return 1 # moving a leaf resets its weight-set to the canonical weight... ceph config set mon osd_crush_update_weight_set true || return 1 ceph osd crush add-bucket FOO host root=default || return 1 ceph osd crush move osd.0 host=FOO || return 1 ceph osd crush tree - ceph osd crush tree | grep osd.0 | grep '3.00000 3.00000' || return 1 - ceph osd crush tree | grep HOST | grep '3.00000 2.00000' || return 1 - ceph osd crush tree | grep RACK | grep '3.00000 2.00000' || return 1 + ceph osd crush tree | grep osd.0 | grep '3.00000 3.00000' || return 1 + ceph osd crush tree | grep HOST | grep '3.00000 2.00000' || return 1 + ceph osd crush tree | grep RACK | grep '3.00000 2.00000' || return 1 # ...or to zero. ceph config set mon osd_crush_update_weight_set false || return 1 ceph osd crush move osd.1 host=FOO || return 1 ceph osd crush tree - ceph osd crush tree | grep osd.0 | grep '3.00000 3.00000' || return 1 - ceph osd crush tree | grep osd.1 | grep '3.00000 0' || return 1 - ceph osd crush tree | grep FOO | grep '6.00000 3.00000' || return 1 + ceph osd crush tree | grep osd.0 | grep '3.00000 3.00000' || return 1 + ceph osd crush tree | grep osd.1 | grep '3.00000 0' || return 1 + ceph osd crush tree | grep FOO | grep '6.00000 3.00000' || return 1 } main crush-choose-args "$@" diff --git a/qa/workunits/mon/config.sh b/qa/workunits/mon/config.sh index 981927bd0a5..36eab8f7ba3 100755 --- a/qa/workunits/mon/config.sh +++ b/qa/workunits/mon/config.sh @@ -82,7 +82,7 @@ while ! ceph config show osd.0 | grep debug_asok | grep 99 do sleep 1 done -ceph config show osd.0 | grep debug_asok | grep 'override mon' +ceph config show osd.0 | grep debug_asok | grep 'override mon' ceph tell osd.0 config unset debug_asok ceph tell osd.0 config unset debug_asok diff --git a/src/common/TextTable.cc b/src/common/TextTable.cc index c94719a9589..8973c9e756c 100644 --- a/src/common/TextTable.cc +++ b/src/common/TextTable.cc @@ -70,7 +70,7 @@ std::ostream &operator<<(std::ostream &out, const TextTable &t) TextTable::TextTableColumn col = t.col[i]; out << string(t.indent, ' ') << pad(col.heading, col.width, col.hd_align) - << ' '; + << t.column_separation; } out << endl; @@ -79,7 +79,7 @@ std::ostream &operator<<(std::ostream &out, const TextTable &t) TextTable::TextTableColumn col = t.col[j]; out << string(t.indent, ' ') << pad(t.row[i][j], col.width, col.col_align) - << ' '; + << t.column_separation; } out << endl; } diff --git a/src/common/TextTable.h b/src/common/TextTable.h index 2d6ad3cc0b1..6702c00575c 100644 --- a/src/common/TextTable.h +++ b/src/common/TextTable.h @@ -53,6 +53,7 @@ private: std::vector col; // column definitions unsigned int curcol, currow; // col, row being inserted into unsigned int indent; // indent width when rendering + std::string column_separation = {" "}; protected: std::vector > row; // row data array @@ -82,6 +83,15 @@ public: */ void set_indent(int i) { indent = i; } + /** + * Set column separation + * + * @param s String to separate columns + */ + void set_column_separation(const std::string& s) { + column_separation = s; + } + /** * Add item to table, perhaps on new row. * table << val1 << val2 << TextTable::endrow; diff --git a/src/test/test_texttable.cc b/src/test/test_texttable.cc index 0d439d16c9c..25a82449c73 100644 --- a/src/test/test_texttable.cc +++ b/src/test/test_texttable.cc @@ -29,7 +29,7 @@ TEST(TextTable, Alignment) { t << "1" << 2 << 3 << TextTable::endrow; std::ostringstream oss; oss << t; - ASSERT_STREQ("HEAD1 HEAD2 HEAD3 \n1 2 3 \n", oss.str().c_str()); + ASSERT_STREQ("HEAD1 HEAD2 HEAD3 \n1 2 3 \n", oss.str().c_str()); } TEST(TextTable, WidenAndClearShrink) { @@ -43,14 +43,14 @@ TEST(TextTable, WidenAndClearShrink) { // validate wide output std::ostringstream oss; oss << t; - ASSERT_STREQ("1 \nwider \n", oss.str().c_str()); + ASSERT_STREQ("1 \nwider \n", oss.str().c_str()); oss.str(""); // reset, validate single-char width output t.clear(); t << "s"; oss << t; - ASSERT_STREQ("1 \ns \n", oss.str().c_str()); + ASSERT_STREQ("1 \ns \n", oss.str().c_str()); } TEST(TextTable, Indent) { @@ -61,7 +61,7 @@ TEST(TextTable, Indent) { t << "s"; std::ostringstream oss; oss << t; - ASSERT_STREQ(" 1 \n s \n", oss.str().c_str()); + ASSERT_STREQ(" 1 \n s \n", oss.str().c_str()); }