Add query_cache_unit-t to build and init Prometheus registry

- tests/unit/Makefile: Register query_cache_unit-t in the build system
- test_init.cpp: Create a real Prometheus registry in test_init_query_
  cache() since the Query_Cache constructor registers metrics via
  GloVars.prometheus_registry (nullptr would crash)
pull/5486/head
René Cannaò 2 months ago
parent 96387be177
commit 2ae866b59c

@ -81,6 +81,13 @@ int test_init_query_cache() {
return 0;
}
// The Query_Cache constructor registers Prometheus metrics via
// GloVars.prometheus_registry. Provide a real registry so the
// constructor doesn't crash on nullptr dereference.
if (GloVars.prometheus_registry == nullptr) {
GloVars.prometheus_registry = std::make_shared<prometheus::Registry>();
}
GloMyQC = new MySQL_Query_Cache();
GloPgQC = new PgSQL_Query_Cache();

@ -231,7 +231,7 @@ $(ODIR)/test_init.o: $(TEST_HELPERS_DIR)/test_init.cpp | $(ODIR)
# Unit test targets
# ===========================================================================
UNIT_TESTS := smoke_test-t
UNIT_TESTS := smoke_test-t query_cache_unit-t
.PHONY: all
all: $(UNIT_TESTS)
@ -250,6 +250,11 @@ smoke_test-t: smoke_test-t.cpp $(TEST_HELPERS_OBJ) $(LIBPROXYSQLAR)
$(LIBPROXYSQLAR_FULL) $(STATIC_LIBS) $(MYLIBS) \
$(ALLOW_MULTI_DEF) -o $@
query_cache_unit-t: query_cache_unit-t.cpp $(TEST_HELPERS_OBJ) $(LIBPROXYSQLAR)
$(CXX) $< $(TEST_HELPERS_OBJ) $(IDIRS) $(LDIRS) $(OPT) \
$(LIBPROXYSQLAR_FULL) $(STATIC_LIBS) $(MYLIBS) \
$(ALLOW_MULTI_DEF) -o $@
# ===========================================================================
# Clean

Loading…
Cancel
Save