You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by zr...@apache.org on 2021/05/21 15:07:29 UTC
[trafficcontrol] branch master updated: Fix t3c reload (#5873)
This is an automated email from the ASF dual-hosted git repository.
zrhoffman 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 6fe2892 Fix t3c reload (#5873)
6fe2892 is described below
commit 6fe2892aa67b15222f0e84ea8efab0b9ab53e23e
Author: Robert O Butts <ro...@users.noreply.github.com>
AuthorDate: Fri May 21 09:07:08 2021 -0600
Fix t3c reload (#5873)
* Fix t3c not reloading
Bug was the data of what files and packages were changed not being
set. This is a critical part of the t3c-reload call, Guessing it
disappearing was a merge failure from the reload PR being so old.
* Add t3c reload test
* Changed t3c test fixture ATS version to "CHANGEME"
Also changes the baseline-config as necessary. I confirmed the change
is correct, the previous was being caused by the ATS version being
detected as 5, confirmed in the test log as:
"Unsupport version of ats found 5"
from lib/go-atscfg/remapdotconfig.go
---
cache-config/t3c-apply/torequest/torequest.go | 2 +
.../ort-tests/baseline-configs/remap.config | 4 +-
.../ort-tests/t3c-apply-unset-update_test.go | 30 +++++++++-
...ply-unset-update_test.go => t3c-reload_test.go} | 70 ++++++----------------
cache-config/testing/ort-tests/tc-fixtures.json | 2 +-
5 files changed, 52 insertions(+), 56 deletions(-)
diff --git a/cache-config/t3c-apply/torequest/torequest.go b/cache-config/t3c-apply/torequest/torequest.go
index 627ec0a..8424446 100644
--- a/cache-config/t3c-apply/torequest/torequest.go
+++ b/cache-config/t3c-apply/torequest/torequest.go
@@ -488,6 +488,7 @@ func (r *TrafficOpsReq) replaceCfgFile(cfg *ConfigFile) error {
return errors.New("Failed to move temp '" + tmpFileName + "' to real '" + cfg.Path + "': " + err.Error())
}
cfg.ChangeApplied = true
+ r.changedFiles = append(r.changedFiles, cfg.Name)
r.RemapConfigReload = cfg.RemapPluginConfig ||
cfg.Name == "remap.config" ||
@@ -998,6 +999,7 @@ func (r *TrafficOpsReq) ProcessPackages() error {
return errors.New("Unable to install " + pkg + " : " + err.Error())
} else if result == true {
r.pkgs[pkg] = true
+ r.installedPkgs[pkg] = struct{}{}
log.Infof("Package %s was installed\n", pkg)
}
}
diff --git a/cache-config/testing/ort-tests/baseline-configs/remap.config b/cache-config/testing/ort-tests/baseline-configs/remap.config
index b20e8fb..238313c 100644
--- a/cache-config/testing/ort-tests/baseline-configs/remap.config
+++ b/cache-config/testing/ort-tests/baseline-configs/remap.config
@@ -1,3 +1,3 @@
# DO NOT EDIT - Generated for atlanta-edge-03 by () on Fri Nov 13 18:49:10 UTC 2020
-map http://atlanta-edge-03.ds-top.test.cdn1.net/ http://origin.topology.example.net/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-top.config # topology 'mso-topology'
-map https://atlanta-edge-03.ds-top.test.cdn1.net/ http://origin.topology.example.net/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-top.config # topology 'mso-topology'
+map http://atlanta-edge-03.ds-top.test.cdn1.net/ http://origin.topology.example.net/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-top.config @plugin=cachekey.so @pparam=--separator= @pparam=--remove-all-params=true @pparam=--remove-path=true @pparam=--capture-prefix-uri=/^([^?]*)/$1/ # topology 'mso-topology'
+map https://atlanta-edge-03.ds-top.test.cdn1.net/ http://origin.topology.example.net/ @plugin=header_rewrite.so @pparam=dscp/set_dscp_40.config @plugin=header_rewrite.so @pparam=hdr_rw_first_ds-top.config @plugin=cachekey.so @pparam=--separator= @pparam=--remove-all-params=true @pparam=--remove-path=true @pparam=--capture-prefix-uri=/^([^?]*)/$1/ # topology 'mso-topology'
\ No newline at end of file
diff --git a/cache-config/testing/ort-tests/t3c-apply-unset-update_test.go b/cache-config/testing/ort-tests/t3c-apply-unset-update_test.go
index 68dd43e..efbd90e 100644
--- a/cache-config/testing/ort-tests/t3c-apply-unset-update_test.go
+++ b/cache-config/testing/ort-tests/t3c-apply-unset-update_test.go
@@ -75,13 +75,39 @@ func TestT3cUnsetsUpdateFlag(t *testing.T) {
}
}
- _, _ = t3cUpdateUnsetFlag(cacheHostName, "syncds")
+ // traffic_ctl doesn't work because the test framework doesn't currently run ATS.
+ // So, temporarily replace it with a no-op, so t3c-apply gets far enough to un-set the update flag.
+ // TODO: remove this when running ATS is added to the test framework
+
+ if err := os.Rename(`/opt/trafficserver/bin/traffic_ctl`, `/opt/trafficserver/bin/traffic_ctl.real`); err != nil {
+ t.Fatal("temporarily moving traffic_ctl: " + err.Error())
+ }
+
+ fi, err := os.OpenFile(`/opt/trafficserver/bin/traffic_ctl`, os.O_RDWR|os.O_CREATE, 755)
+ if err != nil {
+ t.Fatal("creating temp no-op traffic_ctl file: " + err.Error())
+ }
+ if _, err := fi.WriteString(`#!/usr/bin/env bash` + "\n"); err != nil {
+ fi.Close()
+ t.Fatal("writing temp no-op traffic_ctl file: " + err.Error())
+ }
+ fi.Close()
+
+ defer func() {
+ if err := os.Rename(`/opt/trafficserver/bin/traffic_ctl.real`, `/opt/trafficserver/bin/traffic_ctl`); err != nil {
+ t.Fatal("moving real traffic_ctl back: " + err.Error())
+ }
+ }()
+
+ stdOut, _ := t3cUpdateUnsetFlag(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("TestT3cTOUpdates t3cUpdateUnsetFlag stdout '''%v'''", stdOut)
+
{
// verify update status after syncds is now false
@@ -102,7 +128,7 @@ func TestT3cUnsetsUpdateFlag(t *testing.T) {
}
}
})
- fmt.Println("------------- End of TestT3cTOUpdates tests ---------------")
+ fmt.Println("------------- End of TestT3cUnsetsUpdateFlag tests ---------------")
}
func t3cUpdateUnsetFlag(host string, runMode string) (string, int) {
diff --git a/cache-config/testing/ort-tests/t3c-apply-unset-update_test.go b/cache-config/testing/ort-tests/t3c-reload_test.go
similarity index 54%
copy from cache-config/testing/ort-tests/t3c-apply-unset-update_test.go
copy to cache-config/testing/ort-tests/t3c-reload_test.go
index 68dd43e..ad2e868 100644
--- a/cache-config/testing/ort-tests/t3c-apply-unset-update_test.go
+++ b/cache-config/testing/ort-tests/t3c-reload_test.go
@@ -15,34 +15,34 @@ package orttest
*/
import (
- "encoding/json"
- "fmt"
"os"
"path/filepath"
+ "strings"
"testing"
"github.com/apache/trafficcontrol/cache-config/t3cutil"
"github.com/apache/trafficcontrol/cache-config/testing/ort-tests/tcdata"
- "github.com/apache/trafficcontrol/lib/go-tc"
)
-func TestT3cUnsetsUpdateFlag(t *testing.T) {
- fmt.Println("------------- Starting TestT3cUnsetsUpdateFlag tests ---------------")
+func TestT3cReload(t *testing.T) {
+ t.Logf("------------- Starting TestT3cReload ---------------")
tcd.WithObjs(t, []tcdata.TCObj{
tcdata.CDNs, tcdata.Types, tcdata.Tenants, tcdata.Parameters,
tcdata.Profiles, tcdata.ProfileParameters, tcdata.Statuses,
tcdata.Divisions, tcdata.Regions, tcdata.PhysLocations,
tcdata.CacheGroups, tcdata.Servers, tcdata.Topologies,
tcdata.DeliveryServices}, func() {
+ t.Logf("------------- Start TestT3cReload Core ---------------")
- const cacheHostName = `atlanta-edge-03`
- const cmdUpdateStatus = `update-status`
+ cacheHostName := "atlanta-edge-03"
t.Logf("DEBUG TestT3cReload calling badass")
- if stdOut, exitCode := t3cUpdateUnsetFlag(cacheHostName, "badass"); exitCode != 0 {
+ if stdOut, exitCode := t3cUpdateReload(cacheHostName, "badass"); exitCode != 0 {
t.Fatalf("ERROR: t3c badass failed: code '%v' output '%v'\n", exitCode, stdOut)
}
+ t.Logf("DEBUG TestT3cReload deleting file")
+
// delete a file that we know should trigger a reload.
fileNameToRemove := filepath.Join(test_config_dir, "hdr_rw_first_ds-top.config")
if err := os.Remove(fileNameToRemove); err != nil {
@@ -51,61 +51,29 @@ func TestT3cUnsetsUpdateFlag(t *testing.T) {
t.Logf("DEBUG TestT3cReload setting upate flag")
// set the update flag, so syncds will run
- if err := ExecTOUpdater(cacheHostName, false, true); err != nil {
+ if err := ExecTOUpdater("atlanta-edge-03", false, true); err != nil {
t.Fatalf("t3c-update failed: %v\n", err)
}
- {
- // verify update status is now true
-
- output, err := runRequest(cacheHostName, cmdUpdateStatus)
- if err != nil {
- t.Fatalf("ERROR: to_requester run failed: %v\n", err)
- }
- serverStatus := tc.ServerUpdateStatus{}
- if err = json.Unmarshal([]byte(output), &serverStatus); err != nil {
- t.Fatalf("ERROR unmarshalling json output: " + err.Error())
- }
- if serverStatus.HostName != cacheHostName {
- t.Fatalf("expected request update-status host '%v' actual %v", cacheHostName, serverStatus.HostName)
- } else if serverStatus.RevalPending {
- t.Fatal("expected RevalPending false after update")
- } else if !serverStatus.UpdatePending {
- t.Fatal("expected UpdatePending true after update")
- }
- }
-
- _, _ = t3cUpdateUnsetFlag(cacheHostName, "syncds")
+ 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)
// }
- {
- // verify update status after syncds is now false
-
- output, err := runRequest(cacheHostName, cmdUpdateStatus)
- if err != nil {
- t.Fatalf("t3c-request failed: %v\n", err)
- }
- serverStatus := tc.ServerUpdateStatus{}
- if err = json.Unmarshal([]byte(output), &serverStatus); err != nil {
- t.Fatalf("unmarshalling request update-status json: " + err.Error())
- }
- if serverStatus.HostName != cacheHostName {
- t.Errorf("expected update-status host '%v' actual %v", cacheHostName, serverStatus.HostName)
- } else if serverStatus.RevalPending {
- t.Error("expected RevalPending false after syncds run")
- } else if serverStatus.UpdatePending {
- t.Error("expected UpdatePending false after syncds run")
- }
+ 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("------------- End TestT3cReload Core ---------------")
})
- fmt.Println("------------- End of TestT3cTOUpdates tests ---------------")
+ t.Logf("------------- End of TestT3cReload ---------------")
}
-func t3cUpdateUnsetFlag(host string, runMode string) (string, int) {
+func t3cUpdateReload(host string, runMode string) (string, int) {
args := []string{
"apply",
"--traffic-ops-insecure=true",
@@ -120,7 +88,7 @@ func t3cUpdateUnsetFlag(host string, runMode string) (string, int) {
"--log-location-info=stdout",
"--log-location-debug=test.log",
"--omit-via-string-release=true",
- "--git=no",
+ "--git=" + "yes",
"--run-mode=" + runMode,
}
stdOut, _, exitCode := t3cutil.Do("t3c", args...) // should be no stderr, we told it to log to stdout
diff --git a/cache-config/testing/ort-tests/tc-fixtures.json b/cache-config/testing/ort-tests/tc-fixtures.json
index 8a7048f..8abfc8c 100644
--- a/cache-config/testing/ort-tests/tc-fixtures.json
+++ b/cache-config/testing/ort-tests/tc-fixtures.json
@@ -1761,7 +1761,7 @@
"lastUpdated": "2018-01-19T19:01:21.499423+00:00",
"name": "trafficserver",
"secure": true,
- "value": "*"
+ "value": "CHANGEME"
},
{
"configFile": "empty-file.config",