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/06/01 20:14:24 UTC

[trafficcontrol] branch master updated: Fix t3c rpm to create var/lib dir (#5897)

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 4254cbc  Fix t3c rpm to create var/lib dir (#5897)
4254cbc is described below

commit 4254cbce80a39068f6a8025e35ce5c2d5869fbd0
Author: Robert O Butts <ro...@users.noreply.github.com>
AuthorDate: Tue Jun 1 14:13:40 2021 -0600

    Fix t3c rpm to create var/lib dir (#5897)
---
 .../build/trafficcontrol-cache-config.spec         |  4 ++
 cache-config/testing/docker/ort_test/Dockerfile    |  1 -
 cache-config/testing/ort-tests/t3c-dirs_test.go    | 45 ++++++++++++++++++++++
 3 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/cache-config/build/trafficcontrol-cache-config.spec b/cache-config/build/trafficcontrol-cache-config.spec
index f7f40c5..3e7a56f 100644
--- a/cache-config/build/trafficcontrol-cache-config.spec
+++ b/cache-config/build/trafficcontrol-cache-config.spec
@@ -185,6 +185,8 @@ t3c_preprocess_src=src/github.com/apache/trafficcontrol/"$ccdir"/t3c-preprocess
 cp -p "$t3c_preprocess_src"/t3c-preprocess ${RPM_BUILD_ROOT}/"$installdir"
 gzip -c -9 "$src"/t3c-preprocess/t3c-preprocess.1 > ${RPM_BUILD_ROOT}/"$mandir"/"$man1dir"/t3c-preprocess.1.gz
 
+mkdir -p ${RPM_BUILD_ROOT}/var/lib/trafficcontrol-cache-config
+
 ls ${RPM_BUILD_ROOT}/"$mandir"/"$man1dir"/
 
 %clean
@@ -238,6 +240,8 @@ fi
 /usr/share/man/man1/t3c-request.1.gz
 /usr/share/man/man1/t3c-update.1.gz
 
+%dir /var/lib/trafficcontrol-cache-config
+
 %config(noreplace) /etc/logrotate.d/atstccfg
 %config(noreplace) /var/log/trafficcontrol-cache-config/atstccfg.log
 
diff --git a/cache-config/testing/docker/ort_test/Dockerfile b/cache-config/testing/docker/ort_test/Dockerfile
index bdfc8b1..1e88c94 100644
--- a/cache-config/testing/docker/ort_test/Dockerfile
+++ b/cache-config/testing/docker/ort_test/Dockerfile
@@ -45,7 +45,6 @@ RUN sed -i 's/HOME\/bin/HOME\/bin:\/usr\/local\/go\/bin:/g' /root/.bash_profile
 RUN echo "GOPATH=/root/go; export GOPATH" >> /root/.bash_profile
 RUN echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config
 RUN mkdir /root/go
-RUN mkdir -p /var/lib/trafficcontrol-cache-config/status
 
 EXPOSE 80 443
 ADD ort_test/run.sh /
diff --git a/cache-config/testing/ort-tests/t3c-dirs_test.go b/cache-config/testing/ort-tests/t3c-dirs_test.go
new file mode 100644
index 0000000..1476c2a
--- /dev/null
+++ b/cache-config/testing/ort-tests/t3c-dirs_test.go
@@ -0,0 +1,45 @@
+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 (
+	"os"
+	"testing"
+)
+
+// TestDirs tests that the t3c rpm creates directories that t3c-apply requires to run.
+// Right now, that's just /var/lib/trafficcontrol-cache-config, but in the future it may include others like /var/log/trafficcontrol-cache-config or /etc/trafficcontrol-cache-config.
+func TestDirs(t *testing.T) {
+	t.Logf("------------- Starting TestDirs ---------------")
+
+	requiredDirs := []string{
+		`/var/lib/trafficcontrol-cache-config`,
+	}
+
+	for _, dir := range requiredDirs {
+		dirInf, err := os.Stat(dir)
+		if os.IsNotExist(err) {
+			t.Errorf("directory '%v' must exist for t3c-apply to run successfully, expected: exists, actual: not found", dir)
+		} else if err != nil {
+			t.Errorf("checking if directory '%v' exists, expected: no error, actual: %v", dir, err)
+		} else if !dirInf.IsDir() {
+			t.Errorf("directory '%v' must exist for t3c-apply to run successfully, expected: exists, actual: is a file, not a directory", dir)
+		} else {
+			t.Logf("successfully verified '%v' exists and is a directory", dir)
+		}
+	}
+
+	t.Logf("------------- End of TestDirs ---------------")
+}