|
42 | 42 |
|
43 | 43 | ##### CONFIG GET |
44 | 44 |
|
45 | | -# YAML output |
| 45 | +# Test 0: YAML output |
46 | 46 | traffic_ctl.config().get("proxy.config.diags.debug.tags").as_records().validate_with_goldfile("t1_yaml.gold") |
47 | | -# Default output |
| 47 | +# Test 1: Default output |
48 | 48 | traffic_ctl.config().get("proxy.config.diags.debug.enabled").validate_with_text("proxy.config.diags.debug.enabled: 1") |
49 | | -# Default output with default. |
| 49 | +# Test 2: Default output with default. |
50 | 50 | traffic_ctl.config().get("proxy.config.diags.debug.tags").with_default() \ |
51 | 51 | .validate_with_text("proxy.config.diags.debug.tags: rpc # default http|dns") |
52 | 52 |
|
53 | | -# Now same output test but with defaults, traffic_ctl supports adding default value |
| 53 | +# Test 3: Now same output test but with defaults, traffic_ctl supports adding default value |
54 | 54 | # when using --records. |
55 | 55 | traffic_ctl.config().get("proxy.config.diags.debug.tags").as_records().with_default().validate_with_goldfile("t2_yaml.gold") |
| 56 | +# Test 4: |
56 | 57 | traffic_ctl.config().get( |
57 | 58 | "proxy.config.diags.debug.tags proxy.config.diags.debug.enabled proxy.config.diags.debug.throttling_interval_msec").as_records( |
58 | 59 | ).with_default().validate_with_goldfile("t3_yaml.gold") |
59 | 60 |
|
60 | 61 | ##### CONFIG MATCH |
| 62 | +# Test 5: |
61 | 63 | traffic_ctl.config().match("threads").with_default().validate_with_goldfile("match.gold") |
62 | 64 |
|
63 | | -# The idea is to check the traffic_ctl yaml emitter when a value starts with the |
| 65 | +# Test 6: The idea is to check the traffic_ctl yaml emitter when a value starts with the |
64 | 66 | # same prefix of a node like: |
65 | 67 | # diags: |
66 | 68 | # logfile: |
|
70 | 72 | traffic_ctl.config().match("diags.logfile").as_records().validate_with_goldfile("t4_yaml.gold") |
71 | 73 |
|
72 | 74 | ##### CONFIG DIFF |
| 75 | +# Test 7: |
73 | 76 | traffic_ctl.config().diff().validate_with_goldfile("diff.gold") |
| 77 | +# Test 8: |
74 | 78 | traffic_ctl.config().diff().as_records().validate_with_goldfile("diff_yaml.gold") |
75 | 79 |
|
76 | 80 | ##### CONFIG DESCRIBE |
77 | | -# don't really care about values, but just output and that the command actually went through |
| 81 | +# Test 9: don't really care about values, but just output and that the command actually went through |
78 | 82 | traffic_ctl.config().describe("proxy.config.http.server_ports").validate_with_goldfile("describe.gold") |
79 | 83 |
|
80 | | -# Make sure that the command returns an exit code of 2 |
| 84 | +##### CONFIG RESET |
| 85 | +# Test 10: Reset a single modified record (proxy.config.diags.debug.tags is set to "rpc" in records_yaml, |
| 86 | +# default is "http|dns", so it should be reset) |
| 87 | +traffic_ctl.config().reset("proxy.config.diags.debug.tags").validate_with_text( |
| 88 | + "Set proxy.config.diags.debug.tags, please wait 10 seconds for traffic server to sync " |
| 89 | + "configuration, restart is not required") |
| 90 | +# Test 11: Validate the record was reset to its default value |
| 91 | +traffic_ctl.config().get("proxy.config.diags.debug.tags").validate_with_text("proxy.config.diags.debug.tags: http|dns") |
| 92 | + |
| 93 | +# Test 12: Reset records matching a partial path (proxy.config.diags) |
| 94 | +# First set the record back to non-default for this test |
| 95 | +traffic_ctl.config().set("proxy.config.diags.debug.tags", "rpc").exec() |
| 96 | +# Test 13: Resetting proxy.config.diags should reset all matching modified records under that path |
| 97 | +traffic_ctl.config().reset("proxy.config.diags").validate_contains_all( |
| 98 | + "Set proxy.config.diags.debug.tags", "Set proxy.config.diags.debug.enabled") |
| 99 | +# Test 14: Validate the record was reset to its default value |
| 100 | +traffic_ctl.config().get("proxy.config.diags.debug.tags").validate_with_text("proxy.config.diags.debug.tags: http|dns") |
| 101 | + |
| 102 | +# Test 15: Reset all records using "records" keyword |
| 103 | +# First set the record back to non-default for this test |
| 104 | +traffic_ctl.config().set("proxy.config.diags.debug.tags", "rpc").exec() |
| 105 | +# Test 16: This will reset all modified records (including proxy.config.diags.debug.tags) |
| 106 | +# Some may require restart, which is ok, we can use diff anyways as the records that needs |
| 107 | +# restart will just chage the value but won't have any effect. |
| 108 | +traffic_ctl.config().reset("records").exec() |
| 109 | +# Validate the diff |
| 110 | +# Test 17: Validate the diff |
| 111 | +traffic_ctl.config().diff().validate_with_text("") |
| 112 | +# Test 18: Validate the record was reset to its default value |
| 113 | +traffic_ctl.config().get("proxy.config.diags.debug.tags").validate_with_text("proxy.config.diags.debug.tags: http|dns") |
| 114 | + |
| 115 | +# # Test resetting when no records need resetting (all already at default) |
| 116 | +# # Create a new instance with default values only |
| 117 | +# traffic_ctl_default = Make_traffic_ctl(Test, None) |
| 118 | +# traffic_ctl_default.config().reset("proxy.config.diags.debug.enabled").validate_with_text( |
| 119 | +# "No records to reset (all matching records are already at default values)") |
| 120 | + |
| 121 | +##### CONFIG RESET with YAML-style paths (records.* format) |
| 122 | +# Test 19: Set a record to non-default first |
| 123 | +traffic_ctl.config().set("proxy.config.diags.debug.tags", "yaml_test").exec() |
| 124 | +# Test 20: Reset using YAML-style path (records.diags.debug.tags instead of proxy.config.diags.debug.tags) |
| 125 | +traffic_ctl.config().reset("records.diags.debug.tags").validate_with_text( |
| 126 | + "Set proxy.config.diags.debug.tags, please wait 10 seconds for traffic server to sync " |
| 127 | + "configuration, restart is not required") |
| 128 | +# Test 21: Validate the record was reset to its default value |
| 129 | +traffic_ctl.config().get("proxy.config.diags.debug.tags").validate_with_text("proxy.config.diags.debug.tags: http|dns") |
| 130 | + |
| 131 | +# Test 22: Reset using YAML-style partial path (records.diags) |
| 132 | +traffic_ctl.config().set("proxy.config.diags.debug.tags", "yaml_partial_test").exec() |
| 133 | +traffic_ctl.config().set("proxy.config.diags.debug.enabled", "1").exec() |
| 134 | +# Test 23: Reset using records.diags (YAML format) |
| 135 | +traffic_ctl.config().reset("records.diags").validate_contains_all( |
| 136 | + "Set proxy.config.diags.debug.tags", "Set proxy.config.diags.debug.enabled") |
| 137 | +# Test 24: Validate record was reset |
| 138 | +traffic_ctl.config().get("proxy.config.diags.debug.tags").validate_with_text("proxy.config.diags.debug.tags: http|dns") |
| 139 | + |
| 140 | +# Test 25: Make sure that the command returns an exit code of 2 |
81 | 141 | traffic_ctl.config().get("invalid.should.set.the.exit.code.to.2").validate_with_exit_code(2) |
0 commit comments