You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2021/11/18 19:44:46 UTC

[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #6357: Add t3c retrying app lock

rawlinp commented on a change in pull request #6357:
URL: https://github.com/apache/trafficcontrol/pull/6357#discussion_r752572831



##########
File path: cache-config/testing/ort-tests/t3c-lockfile_test.go
##########
@@ -0,0 +1,113 @@
+package orttest
+
+/*
+   Licensed 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 (
+	"strings"
+	"sync"
+	"testing"
+	"time"
+
+	"github.com/apache/trafficcontrol/cache-config/testing/ort-tests/tcdata"
+)
+
+func TestLockfile(t *testing.T) {
+	testName := "TestLockfile"
+	t.Logf("------------- Starting " + testName + " ---------------")
+	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() {
+
+		hostName := "atlanta-edge-03"
+		const fileName = `records.config`
+
+		firstOut := ""
+		firstCode := 0
+		wg := sync.WaitGroup{}
+		wg.Add(1)
+		go func() {
+			defer wg.Done()
+			t.Logf("TestLockFile first t3c starting %v", time.Now())
+			firstOut, firstCode = t3cUpdateReload(hostName, "badass")
+			t.Logf("TestLockFile first t3c finished %v", time.Now())
+		}()
+
+		time.Sleep(time.Millisecond * 100) // sleep long enough to ensure the concurrent t3c starts
+		t.Logf("TestLockFile second t3c starting %v", time.Now())
+		out, code := t3cUpdateReload(hostName, "badass")
+		t.Logf("TestLockFile second t3c finished %v", time.Now())
+		if code != 0 {
+			t.Fatalf("second t3c apply badass failed: output '''%v''' code %v\n", out, code)

Review comment:
       +1 on the nitpick (more specific types used in format strings). IMO it's tremendously more likely for a developer to accidentally print a pointer address when they really meant to print the actual value, than it is that a type changed and needs a changed format string in various places. Using specific types forces the developer to actually think about what is getting printed and help nudge them into things like dereferencing the pointer where needed. But, like you said, for things like printing pointers to ints, you can't always rely on the compiler or `go vet`.
   
   That said, it is definitely a nitpick, which by definition, I wouldn't necessarily hold up the PR for.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@trafficcontrol.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org