ocket8888 commented on a change in pull request #2967: Fixed compare tool
generating diffs based on timestamp in configuration file headers
URL: https://github.com/apache/trafficcontrol/pull/2967#discussion_r229728614
##########
File path: traffic_ops/testing/compare/compare.go
##########
@@ -138,7 +138,59 @@ func testRoute(tos []*Connect, route string) {
wg.Wait()
close(ch)
- if res[0].Res == res[1].Res {
+ // Check for Traffic Ops headers and remove them before comparison
+ refResult := res[0].Res
+ testResult := res[1].Res
+ if strings.Contains(route, "configfiles") {
+ refLines := strings.Split(refResult, "\n")
+ testLines := strings.Split(testResult, "\n")
+
+ // If the two files have different numbers of lines, they
definitely differ
+ if len(refLines) != len(testLines) {
+ log.Print("Diffs from ", route, " written to")
+ p, err := res[0].TO.writeResults(route, refResult)
+ if err != nil {
+ log.Fatal("Error writing results for ", route)
+ }
+ log.Print(" ", p)
+ p, err = res[1].TO.writeResults(route, testResult)
+ if err != nil {
+ log.Fatal("Error writing results for ", route)
+ }
+ log.Print(" and ", p)
+ }
+
+ refResult = ""
+ testResult = ""
+
+ for i := 0; i < len(refLines); i++ {
+ if len(refLines[i]) < 13 {
+ refResult += refLines[i]
+ } else if refLines[i][:13] != "# DO NOT EDIT" {
+ if len(refLines[i]) >= 19 {
Review comment:
Not necessarily. Arbitrary configuration files can be generated by Trops, so
I don't want to strip out things people want / a `#` may not correspond to a
comment in any arbitrary syntax used by created files. It's theoretically
possible to limit the system to a set of supported syntaxes, but that would
require
1. Doing that
2. Our Content-Type headers being correct - which they aren't
(consistently), see Issue #2565 and Issue #2881
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services