]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
monitoring: build jsonnet/jb only for testing
authorArthur Outhenin-Chalandre <arthur.outhenin-chalandre@cern.ch>
Mon, 24 Jan 2022 09:01:04 +0000 (10:01 +0100)
committerArthur Outhenin-Chalandre <arthur.outhenin-chalandre@cern.ch>
Thu, 3 Feb 2022 12:08:37 +0000 (13:08 +0100)
Build jsonnet and jb in the testso that we can build ceph without
internet access and still be able to run the test needed for monitoring
using jsonnet tools.

Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@cern.ch>
monitoring/ceph-mixin/CMakeLists.txt
monitoring/ceph-mixin/jsonnet-build.sh [new file with mode: 0755]
monitoring/ceph-mixin/jsonnet-bundler-build.sh [new file with mode: 0755]

index 26b05e2659b76f8f1dd54727bafa20322fee99ce..66e620f6c85e768a5c92cd25892b5aff05beb18c 100644 (file)
@@ -6,35 +6,39 @@ if(WITH_GRAFANA)
     ${CEPH_GRAFANA_DASHBOARDS}
     DESTINATION ${CEPH_GRAFANA_DASHBOARDS_DIR})
   if(WITH_TESTS)
-    ExternalProject_Add(jsonnet-bundler
-      GIT_REPOSITORY "https://github.com/jsonnet-bundler/jsonnet-bundler.git"
-      GIT_TAG "v0.4.0"
-      GIT_SHALLOW TRUE
-      SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/src/jsonnet-bundler
-      CONFIGURE_COMMAND ""
-      DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/src
-      BUILD_COMMAND make build
-      BUILD_IN_SOURCE 1
-      INSTALL_COMMAND cp <SOURCE_DIR>/_output/jb <INSTALL_DIR>)
-
-    ExternalProject_Add(jsonnet
-      GIT_REPOSITORY "https://github.com/google/go-jsonnet.git"
-      GIT_TAG "v0.18.0"
-      GIT_SHALLOW TRUE
-      SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/src
-      CONFIGURE_COMMAND ""
-      DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/src
-      BUILD_COMMAND make build
-      BUILD_IN_SOURCE 1
-      INSTALL_COMMAND cp <SOURCE_DIR>/_output/jsonnet <INSTALL_DIR>)
-
     set(CEPH_BUILD_VIRTUALENV $ENV{TMPDIR})
     if(NOT CEPH_BUILD_VIRTUALENV)
       include(AddCephTest)
       set(CEPH_BUILD_VIRTUALENV ${CMAKE_BINARY_DIR})
+
+      add_test(NAME jsonnet-build
+          COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/jsonnet-build.sh ${CMAKE_CURRENT_BINARY_DIR})
+      set_property(TEST jsonnet-build PROPERTY
+          FIXTURES_SETUP jsonnet)
+      add_test(NAME jsonnet-cleanup
+          COMMAND rm -rf go-jsonnet
+                         ${CMAKE_CURRENT_BINARY_DIR}/jsonnet
+                         ${CMAKE_CURRENT_BINARY_DIR}/jsonnetfmt)
+      set_property(TEST jsonnet-cleanup PROPERTY
+          FIXTURES_CLEANUP jsonnet)
+
+      add_test(NAME jsonnet-bundler-build
+          COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/jsonnet-bundler-build.sh ${CMAKE_CURRENT_BINARY_DIR})
+      set_property(TEST jsonnet-bundler-build PROPERTY
+          FIXTURES_SETUP jsonnet-bundler)
+      add_test(NAME jsonnet-bundler-cleanup
+          COMMAND rm -rf jsonnet-bundler ${CMAKE_CURRENT_BINARY_DIR}/jb)
+      set_property(TEST jsonnet-bundler-cleanup PROPERTY
+          FIXTURES_CLEANUP jsonnet-bundler)
+
       add_tox_test(grafana-lint TOX_ENVS lint)
       add_tox_test(jsonnet-lint TOX_ENVS jsonnet-lint)
+      set_property(TEST run-tox-jsonnet-lint PROPERTY
+          FIXTURES_REQUIRED venv-for-jsonnet-lint jsonnet)
       add_tox_test(jsonnet-check TOX_ENVS jsonnet-check)
+      set_property(TEST run-tox-jsonnet-check PROPERTY
+          FIXTURES_REQUIRED venv-for-jsonnet-check jsonnet jsonnet-bundler)
+
       add_tox_test(alerts-check TOX_ENVS alerts-check)
       add_tox_test(alerts-lint TOX_ENVS alerts-lint)
       add_tox_test(promql-query-test TOX_ENVS promql-query-test)
diff --git a/monitoring/ceph-mixin/jsonnet-build.sh b/monitoring/ceph-mixin/jsonnet-build.sh
new file mode 100755 (executable)
index 0000000..8e229f9
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh -ex
+
+JSONNET_VERSION="v0.18.0"
+OUTPUT_DIR=${1:-$(pwd)}
+
+git clone -b ${JSONNET_VERSION} --depth 1 https://github.com/google/go-jsonnet.git
+cd go-jsonnet
+go build ./cmd/jsonnet
+go build ./cmd/jsonnetfmt
+mv jsonnet jsonnetfmt ${OUTPUT_DIR}
diff --git a/monitoring/ceph-mixin/jsonnet-bundler-build.sh b/monitoring/ceph-mixin/jsonnet-bundler-build.sh
new file mode 100755 (executable)
index 0000000..d713cff
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh -ex
+
+JSONNET_VERSION="v0.4.0"
+OUTPUT_DIR=${1:-$(pwd)}
+
+git clone -b ${JSONNET_VERSION} --depth 1 https://github.com/jsonnet-bundler/jsonnet-bundler
+make -C jsonnet-bundler  build
+mv jsonnet-bundler/_output/jb ${OUTPUT_DIR}