You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by rr...@apache.org on 2020/07/03 18:55:41 UTC
[trafficserver] branch master updated: Add new test and fix for
float configuration failure in conf_remap (#6967)
This is an automated email from the ASF dual-hosted git repository.
rrm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 43b0ca0 Add new test and fix for float configuration failure in conf_remap (#6967)
43b0ca0 is described below
commit 43b0ca0399c03ed8c8387872492fdb01028279ae
Author: willwendorfvm <66...@users.noreply.github.com>
AuthorDate: Fri Jul 3 13:55:30 2020 -0500
Add new test and fix for float configuration failure in conf_remap (#6967)
Test that conf_remap can override float settings (e.g. proxy.config.http.background_fill_completed_threshold) successfully.
---
plugins/conf_remap/conf_remap.cc | 14 +++++-
.../gold_tests/autest-site/trafficserver.test.ext | 5 +++
tests/gold_tests/remap/conf_remap_float.py | 51 ++++++++++++++++++++++
3 files changed, 69 insertions(+), 1 deletion(-)
diff --git a/plugins/conf_remap/conf_remap.cc b/plugins/conf_remap/conf_remap.cc
index 34b6198..4a3d160 100644
--- a/plugins/conf_remap/conf_remap.cc
+++ b/plugins/conf_remap/conf_remap.cc
@@ -63,6 +63,8 @@ str_to_datatype(const char *str)
type = TS_RECORDDATATYPE_INT;
} else if (!strcmp(str, "STRING")) {
type = TS_RECORDDATATYPE_STRING;
+ } else if (!strcmp(str, "FLOAT")) {
+ type = TS_RECORDDATATYPE_FLOAT;
}
return type;
@@ -106,6 +108,9 @@ RemapConfigs::parse_inline(const char *arg)
_items[_current]._data_len = value.size();
}
break;
+ case TS_RECORDDATATYPE_FLOAT:
+ _items[_current]._data.rec_float = strtof(value.c_str(), nullptr);
+ break;
default:
TSError("[%s] Configuration variable '%s' is of an unsupported type", PLUGIN_NAME, key.c_str());
return false;
@@ -181,7 +186,7 @@ RemapConfigs::parse_file(const char *filename)
// Find the type (INT or STRING only)
tok = strtok_r(nullptr, " \t", &ln);
if (TS_RECORDDATATYPE_NULL == (type = str_to_datatype(tok))) {
- TSError("[%s] file %s, line %d: only INT and STRING types supported", PLUGIN_NAME, path.c_str(), line_num);
+ TSError("[%s] file %s, line %d: only INT, STRING, and FLOAT types supported", PLUGIN_NAME, path.c_str(), line_num);
continue;
}
@@ -231,6 +236,9 @@ RemapConfigs::parse_file(const char *filename)
_items[_current]._data_len = strlen(tok);
}
break;
+ case TS_RECORDDATATYPE_FLOAT:
+ _items[_current]._data.rec_float = strtof(tok, nullptr);
+ break;
default:
TSError("[%s] file %s, line %d: type not support (unheard of)", PLUGIN_NAME, path.c_str(), line_num);
continue;
@@ -330,6 +338,10 @@ TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo * /* rri ATS_UNUSED */
TSHttpTxnConfigStringSet(txnp, conf->_items[ix]._name, conf->_items[ix]._data.rec_string, conf->_items[ix]._data_len);
TSDebug(PLUGIN_NAME, "Setting config id %d to %s", conf->_items[ix]._name, conf->_items[ix]._data.rec_string);
break;
+ case TS_RECORDDATATYPE_FLOAT:
+ TSHttpTxnConfigFloatSet(txnp, conf->_items[ix]._name, conf->_items[ix]._data.rec_int);
+ TSDebug(PLUGIN_NAME, "Setting config id %d to %f", conf->_items[ix]._name, conf->_items[ix]._data.rec_float);
+ break;
default:
break; // Error ?
}
diff --git a/tests/gold_tests/autest-site/trafficserver.test.ext b/tests/gold_tests/autest-site/trafficserver.test.ext
index e01507c..b1481ca 100755
--- a/tests/gold_tests/autest-site/trafficserver.test.ext
+++ b/tests/gold_tests/autest-site/trafficserver.test.ext
@@ -209,6 +209,11 @@ def MakeATSProcess(obj, name, command='traffic_server', select_ports=True,
tmpname = os.path.join(config_dir, fname)
p.Disk.File(tmpname, id=make_id(fname), typename="ats:config")
+ # for conf_remap_float, used by conf_remap plugin
+ fname = "delain.config"
+ tmpname = os.path.join(config_dir, fname)
+ p.Disk.File(tmpname, id=make_id(fname), typename="ats:config")
+
fname = "hosting.config"
tmpname = os.path.join(config_dir, fname)
p.Disk.File(tmpname, id=make_id(fname), typename="ats:config")
diff --git a/tests/gold_tests/remap/conf_remap_float.py b/tests/gold_tests/remap/conf_remap_float.py
new file mode 100644
index 0000000..ffef888
--- /dev/null
+++ b/tests/gold_tests/remap/conf_remap_float.py
@@ -0,0 +1,51 @@
+'''
+'''
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+import os
+
+Test.Summary = '''
+Test command: traffic_ctl config describe proxy.config.http.background_fill_completed_threshold (YTSATS-3309)
+'''
+Test.testName = 'Float in conf_remap Config Test'
+
+ts = Test.MakeATSProcess("ts", command="traffic_manager", select_ports=True)
+
+# Add dummy remap rule
+ts.Disk.remap_config.AddLine(
+ 'map http://cdn.example.com/ http://origin.example.com/ @plugin=conf_remap.so @pparam={file}'.format(file=os.path.join(ts.RunDirectory, 'ts/config/delain.config'))
+)
+
+ts.Disk.delain_config.AddLine(
+ 'CONFIG proxy.config.http.background_fill_completed_threshold FLOAT 0.500000'
+)
+
+#
+# Test body
+#
+
+# First reload
+tr = Test.AddTestRun("traffic_ctl command")
+tr.Env = ts.Env
+tr.TimeOut = 5
+tr.StillRunningAfter = ts
+
+p = tr.Processes.Default
+p.Command = "traffic_ctl config describe proxy.config.http.background_fill_completed_threshold"
+p.ReturnCode = 0
+p.StartBefore(Test.Processes.ts, ready=When.FileExists(os.path.join(tr.RunDirectory, 'ts/log/diags.log')))