-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
config: config load check tool (#969)
- Loading branch information
Showing
10 changed files
with
92 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,4 @@ Building and installation | |
installation | ||
ref_configs | ||
sandboxes/sandboxes.rst | ||
tools | ||
tools/tools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Config load check tool | ||
====================== | ||
|
||
The config load check tool checks that a configuration file in JSON format is written using valid JSON | ||
and conforms to the Envoy JSON schema. This tool leverages the configuration test in | ||
``test/config_test/config_test.cc``. The test loads the JSON configuration file and runs server configuration | ||
initialization with it. | ||
|
||
Input | ||
The tool expects a PATH to the root of a directory that holds JSON Envoy configuration files. The tool | ||
will recursively go through the filesystem tree and run a configuration test for each file found. Keep in mind that | ||
the tool will try to load all files found in the path. | ||
|
||
Output | ||
The tool will output Envoy logs as it initializes the server configuration with the config it is currently testing. | ||
If there are configuration files where the JSON file is malformed or is does not conform to the Envoy JSON schema, the | ||
tool will exit with status EXIT_FAILURE. If the tool successfully loads all configuration files found it will | ||
exit with status EXIT_SUCCESS. | ||
|
||
Building | ||
The tool can be built locally using Bazel. :: | ||
|
||
bazel build //test/tools/config_load_check:config_load_check_tool | ||
|
||
Running | ||
The tool takes a path as described above. :: | ||
|
||
bazel-bin/test/tools/config_load_check/config_load_check_tool PATH |
4 changes: 2 additions & 2 deletions
4
docs/install/tools.rst → .../install/tools/route_table_check_tool.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Tools | ||
===== | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
config_load_check_tool | ||
route_table_check_tool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
licenses(["notice"]) # Apache 2 | ||
|
||
load( | ||
"//bazel:envoy_build_system.bzl", | ||
"envoy_cc_binary", | ||
"envoy_package", | ||
) | ||
|
||
envoy_package() | ||
|
||
envoy_cc_binary( | ||
name = "config_load_check_tool", | ||
testonly = 1, | ||
srcs = ["config_load_check.cc"], | ||
deps = ["//test/config_test:config_test_lib"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// NOLINT(namespace-envoy) | ||
#include <iostream> | ||
#include <stdexcept> | ||
#include <string> | ||
|
||
#include "test/config_test/config_test.h" | ||
|
||
#include "gtest/gtest.h" | ||
#include "spdlog/spdlog.h" | ||
|
||
int main(int argc, char* argv[]) { | ||
if (argc != 2) { | ||
std::cerr << "Usage: config_load_check PATH\n" | ||
"\nValidate configuration files against json schema\n" | ||
"\n\tPATH - root of the path that holds the json files to verify." | ||
" The tool recursively searches for json files to validate." << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
try { | ||
const uint32_t num_tested = Envoy::ConfigTest::run(std::string(argv[1])); | ||
std::cout << fmt::format("Configs tested: {}. ", num_tested); | ||
if (testing::Test::HasFailure()) { | ||
std::cerr << "There were failures. Please Fix your configuration files." << std::endl; | ||
return EXIT_FAILURE; | ||
} else { | ||
std::cout << "No failures." << std::endl; | ||
return EXIT_SUCCESS; | ||
} | ||
} catch (const std::runtime_error& e) { | ||
// catch directory not found runtime exception. | ||
std::cerr << e.what() << std::endl; | ||
} | ||
return EXIT_FAILURE; | ||
} |