Skip to content

Commit

Permalink
monitoring: build jsonnet/jb only for testing
Browse files Browse the repository at this point in the history
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>
(cherry picked from commit 8ff1e6b)
  • Loading branch information
MrFreezeex committed Mar 23, 2022
1 parent b0db2d9 commit be374d6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 22 deletions.
48 changes: 26 additions & 22 deletions monitoring/ceph-mixin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions monitoring/ceph-mixin/jsonnet-build.sh
Original file line number Diff line number Diff line change
@@ -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}
8 changes: 8 additions & 0 deletions monitoring/ceph-mixin/jsonnet-bundler-build.sh
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit be374d6

Please sign in to comment.