You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by ro...@apache.org on 2021/06/28 22:32:11 UTC
[trafficcontrol] branch master updated: t3c-apply: enable and
enhance reload states test (#5964)
This is an automated email from the ASF dual-hosted git repository.
rob pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 0676e13 t3c-apply: enable and enhance reload states test (#5964)
0676e13 is described below
commit 0676e136de9e2df70ec028120402961866045473
Author: Brian Olsen <bn...@gmail.com>
AuthorDate: Mon Jun 28 16:31:59 2021 -0600
t3c-apply: enable and enhance reload states test (#5964)
---
CHANGELOG.md | 1 +
cache-config/t3c-apply/torequest/torequest.go | 14 +++++++--
cache-config/testing/ort-tests/t3c-reload_test.go | 37 +++++++++++------------
3 files changed, 29 insertions(+), 23 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 15db73d..cbf6537 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -49,6 +49,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Added a Traffic Monitor integration test framework.
- Added `traffic_ops/app/db/traffic_vault_migrate` to help with migrating Traffic Ops Traffic Vault backends
- Added a tool at `/traffic_ops/app/db/reencrypt` to re-encrypt the data in the Postgres Traffic Vault with a new key.
+- Enhanced ort integration test for reload states
### Fixed
- [#5690](https://github.com/apache/trafficcontrol/issues/5690) - Fixed github action for added/modified db migration file.
diff --git a/cache-config/t3c-apply/torequest/torequest.go b/cache-config/t3c-apply/torequest/torequest.go
index b9beb77..9fbf87b 100644
--- a/cache-config/t3c-apply/torequest/torequest.go
+++ b/cache-config/t3c-apply/torequest/torequest.go
@@ -493,17 +493,19 @@ func (r *TrafficOpsReq) replaceCfgFile(cfg *ConfigFile) error {
r.RemapConfigReload = r.RemapConfigReload ||
cfg.RemapPluginConfig ||
cfg.Name == "remap.config" ||
- strings.HasPrefix(cfg.Name, "url_sig_") ||
- strings.HasPrefix(cfg.Name, "uri_signing") ||
+ strings.HasPrefix(cfg.Name, "bg_fetch") ||
strings.HasPrefix(cfg.Name, "hdr_rw_") ||
strings.HasPrefix(cfg.Name, "regex_remap_") ||
- strings.HasPrefix(cfg.Name, "bg_fetch") ||
+ strings.HasPrefix(cfg.Name, "set_dscp_") ||
+ strings.HasPrefix(cfg.Name, "url_sig_") ||
+ strings.HasPrefix(cfg.Name, "uri_signing") ||
strings.HasSuffix(cfg.Name, ".lua")
r.TrafficCtlReload = r.TrafficCtlReload ||
strings.HasSuffix(cfg.Dir, "trafficserver") ||
r.RemapConfigReload ||
cfg.Name == "ssl_multicert.config" ||
+ cfg.Name == "records.config" ||
(strings.HasSuffix(cfg.Dir, "ssl") && strings.HasSuffix(cfg.Name, ".cer")) ||
(strings.HasSuffix(cfg.Dir, "ssl") && strings.HasSuffix(cfg.Name, ".key"))
@@ -511,6 +513,8 @@ func (r *TrafficOpsReq) replaceCfgFile(cfg *ConfigFile) error {
r.NtpdRestart = r.NtpdRestart || (cfg.Name == "ntpd.conf")
r.SysCtlReload = r.SysCtlReload || (cfg.Name == "sysctl.conf")
+ log.Debugf("Reload state after %s: remap.config: %t reload: %t restart: %t ntpd: %t sysctl: %t", cfg.Name, r.RemapConfigReload, r.TrafficCtlReload, r.TrafficServerRestart, r.NtpdRestart, r.SysCtlReload)
+
log.Debugf("Setting change applied for '%s'\n", cfg.Name)
return nil
}
@@ -893,6 +897,10 @@ func (r *TrafficOpsReq) ProcessConfigFiles() (UpdateStatus, error) {
}
}
+ if 0 < len(r.changedFiles) {
+ log.Infof("Final state: remap.config: %t reload: %t restart: %t ntpd: %t sysctl: %t", r.RemapConfigReload, r.TrafficCtlReload, r.TrafficServerRestart, r.NtpdRestart, r.SysCtlReload)
+ }
+
if updateStatus != UpdateTropsFailed && changesRequired > 0 {
return UpdateTropsNeeded, nil
}
diff --git a/cache-config/testing/ort-tests/t3c-reload_test.go b/cache-config/testing/ort-tests/t3c-reload_test.go
index e0d123c..bc26386 100644
--- a/cache-config/testing/ort-tests/t3c-reload_test.go
+++ b/cache-config/testing/ort-tests/t3c-reload_test.go
@@ -15,6 +15,7 @@ package orttest
*/
import (
+ "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -37,7 +38,7 @@ func TestT3cReload(t *testing.T) {
doTestT3cReloadAnythingInTrafficserverDir(t)
doTestT3cReloadNoChange(t)
doTestT3cRevalCallsReload(t)
-
+ doTestT3cReloadState(t)
})
t.Logf("------------- End of TestT3cReload ---------------")
}
@@ -199,7 +200,7 @@ func doTestT3cRevalCallsReload(t *testing.T) {
}
func doTestT3cReloadState(t *testing.T) {
- t.Logf("------------- Start doTestT3cReloadReloadState ---------------")
+ t.Logf("------------- Start doTestT3cReloadState ---------------")
cacheHostName := "atlanta-edge-03"
@@ -210,18 +211,19 @@ func doTestT3cReloadState(t *testing.T) {
t.Logf("DEBUG TestT3cReload deleting header rewrite")
- var fileNameToRemove string
-
// delete header rewrite so we know should trigger a remap.config touch and reload.
- fileNameToRemove = filepath.Join(test_config_dir, "hdr_rw_first_ds-top.config")
+ fileNameToRemove := filepath.Join(test_config_dir, "hdr_rw_first_ds-top.config")
if err := os.Remove(fileNameToRemove); err != nil {
t.Fatalf("failed to remove file '" + fileNameToRemove + "': " + err.Error())
}
- // delete storage.config we know should trigger just a reload.
- fileNameToRemove = filepath.Join(test_config_dir, "storage.config")
- if err := os.Remove(fileNameToRemove); err != nil {
- t.Fatalf("failed to remove file '" + fileNameToRemove + "': " + err.Error())
+ // create plugin.config to trigger restart directive
+ t.Logf("DEBUG TestT3cReload creating plugin.config")
+ pluginConfigPath := filepath.Join(test_config_dir, "plugin.config")
+ contents := []byte("remap_stats.so")
+ err := ioutil.WriteFile(pluginConfigPath, contents, 0666)
+ if err != nil {
+ t.Fatalf("Unable to create file %s\n", pluginConfigPath)
}
t.Logf("DEBUG TestT3cReload setting upate flag")
@@ -232,20 +234,15 @@ func doTestT3cReloadState(t *testing.T) {
t.Logf("DEBUG TestT3cReload calling syncds")
stdOut, _ := t3cUpdateReload(cacheHostName, "syncds")
- // Ignore the exit code error for now, because the ORT Integration Test Framework doesn't currently start ATS.
- // TODO check err, after running ATS is added to the tests.
- // if err != nil {
- // t.Fatalf("t3c syncds failed: %v\n", err)
- // }
- t.Logf("DEBUG TestT3cReload looking for reload string")
- if !strings.Contains(stdOut, `Running 'traffic_ctl config reload' now`) {
- t.Errorf("expected t3c to do a reload after adding a header rewrite file, actual: '''%v'''\n", stdOut)
+ t.Logf("DEBUG TestT3cReload looking for reload summary")
+ if !strings.Contains(stdOut, "Final state: remap.config: true reload: true restart: true ntpd: false sysctl: false") {
+ t.Errorf("expected t3c Final reload state for remap.config, reload and restart, actual: '''%v'''\n", stdOut)
}
- t.Logf("DEBUG TestT3cReload looking for remap.config reloading string")
- if !strings.Contains(stdOut, `updated the remap.config for reloading`) {
- t.Errorf("expected t3c to touch remap.config after adding a header rewrite file, actual: '''%v'''\n", stdOut)
+ // remove plugin.config file for next test
+ if err := os.Remove(pluginConfigPath); err != nil {
+ t.Fatalf("failed to remove file '" + pluginConfigPath + "': " + err.Error())
}
t.Logf("------------- End TestT3cReload doTestT3cReloadState ---------------")