CI: reduce test verbosity; set PKG_CONFIG_PATH for re2 in rpm distros (#2331)
* wip * wip * go install with commit hash
This commit is contained in:
parent
8bcb4c2436
commit
486b56d1ed
5 changed files with 20 additions and 17 deletions
3
Makefile
3
Makefile
|
@ -78,6 +78,9 @@ endif
|
||||||
|
|
||||||
GO_TAGS := netgo,osusergo,sqlite_omit_load_extension
|
GO_TAGS := netgo,osusergo,sqlite_omit_load_extension
|
||||||
|
|
||||||
|
# this will be used by Go in the make target, some distributions require it
|
||||||
|
export PKG_CONFIG_PATH:=/usr/local/lib/pkgconfig:$(PKG_CONFIG_PATH)
|
||||||
|
|
||||||
ifeq ($(call bool,$(BUILD_RE2_WASM)),0)
|
ifeq ($(call bool,$(BUILD_RE2_WASM)),0)
|
||||||
ifeq ($(PKG_CONFIG),)
|
ifeq ($(PKG_CONFIG),)
|
||||||
$(error "pkg-config is not available. Please install pkg-config.")
|
$(error "pkg-config is not available. Please install pkg-config.")
|
||||||
|
|
15
test/bats.mk
15
test/bats.mk
|
@ -66,15 +66,24 @@ bats-environment:
|
||||||
bats-check-requirements:
|
bats-check-requirements:
|
||||||
@$(TEST_DIR)/bin/check-requirements
|
@$(TEST_DIR)/bin/check-requirements
|
||||||
|
|
||||||
|
# Install/update some of the tools required to run the tests
|
||||||
|
bats-update-tools:
|
||||||
|
# yq v4.34.1
|
||||||
|
GOBIN=$(TEST_DIR)/tools go install github.com/mikefarah/yq/v4@5ef537f3fd1a9437aa3ee44c32c6459a126efdc4
|
||||||
|
# cfssl v1.6.4
|
||||||
|
GOBIN=$(TEST_DIR)/tools go install github.com/cloudflare/cfssl/cmd/cfssl@b4d0d877cac528f63db39dfb62d5c96cd3a32a0b
|
||||||
|
GOBIN=$(TEST_DIR)/tools go install github.com/cloudflare/cfssl/cmd/cfssljson@b4d0d877cac528f63db39dfb62d5c96cd3a32a0b
|
||||||
|
|
||||||
# Build and installs crowdsec in a local directory. Rebuilds if already exists.
|
# Build and installs crowdsec in a local directory. Rebuilds if already exists.
|
||||||
bats-build: bats-environment bats-check-requirements
|
bats-build: bats-environment
|
||||||
@$(MKDIR) $(BIN_DIR) $(LOG_DIR) $(PID_DIR) $(BATS_PLUGIN_DIR)
|
@$(MKDIR) $(BIN_DIR) $(LOG_DIR) $(PID_DIR) $(BATS_PLUGIN_DIR)
|
||||||
@TEST_COVERAGE=$(TEST_COVERAGE) DEFAULT_CONFIGDIR=$(CONFIG_DIR) DEFAULT_DATADIR=$(DATA_DIR) $(MAKE) build
|
@TEST_COVERAGE=$(TEST_COVERAGE) DEFAULT_CONFIGDIR=$(CONFIG_DIR) DEFAULT_DATADIR=$(DATA_DIR) $(MAKE) build
|
||||||
@install -m 0755 cmd/crowdsec/crowdsec cmd/crowdsec-cli/cscli $(BIN_DIR)/
|
@install -m 0755 cmd/crowdsec/crowdsec cmd/crowdsec-cli/cscli $(BIN_DIR)/
|
||||||
@install -m 0755 plugins/notifications/*/notification-* $(BATS_PLUGIN_DIR)/
|
@install -m 0755 plugins/notifications/*/notification-* $(BATS_PLUGIN_DIR)/
|
||||||
|
|
||||||
# Create a reusable package with initial configuration + data
|
# Create a reusable package with initial configuration + data
|
||||||
bats-fixture:
|
bats-fixture: bats-check-requirements bats-update-tools
|
||||||
|
@echo "Creating functional test fixture..."
|
||||||
@$(TEST_DIR)/instance-data make
|
@$(TEST_DIR)/instance-data make
|
||||||
|
|
||||||
# Remove the local crowdsec installation and the fixture config + data
|
# Remove the local crowdsec installation and the fixture config + data
|
||||||
|
@ -87,7 +96,7 @@ bats-clean:
|
||||||
@$(RM) test/coverage/* $(WIN_IGNORE_ERR)
|
@$(RM) test/coverage/* $(WIN_IGNORE_ERR)
|
||||||
|
|
||||||
# Run the test suite
|
# Run the test suite
|
||||||
bats-test: bats-environment bats-check-requirements
|
bats-test: bats-environment
|
||||||
$(TEST_DIR)/run-tests $(TEST_DIR)/bats
|
$(TEST_DIR)/run-tests $(TEST_DIR)/bats
|
||||||
|
|
||||||
# Generate dynamic tests
|
# Generate dynamic tests
|
||||||
|
|
|
@ -176,7 +176,7 @@ teardown() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "cscli alerts delete (must ignore the query limit)" {
|
@test "cscli alerts delete (must ignore the query limit)" {
|
||||||
for i in $(seq 1 200); do
|
for _i in $(seq 1 200); do
|
||||||
rune -0 cscli decisions add -i 1.2.3.4
|
rune -0 cscli decisions add -i 1.2.3.4
|
||||||
done
|
done
|
||||||
rune -0 cscli alerts delete -i 1.2.3.4
|
rune -0 cscli alerts delete -i 1.2.3.4
|
||||||
|
|
|
@ -62,12 +62,6 @@ check_daemonizer() {
|
||||||
|
|
||||||
echo "Checking requirements..."
|
echo "Checking requirements..."
|
||||||
|
|
||||||
GOBIN=${TEST_DIR}/tools
|
|
||||||
export GOBIN
|
|
||||||
go install github.com/mikefarah/yq/v4@latest
|
|
||||||
go install github.com/cloudflare/cfssl/cmd/cfssl@master
|
|
||||||
go install github.com/cloudflare/cfssl/cmd/cfssljson@master
|
|
||||||
|
|
||||||
check_bats_core
|
check_bats_core
|
||||||
check_curl
|
check_curl
|
||||||
check_daemonizer
|
check_daemonizer
|
||||||
|
|
|
@ -100,7 +100,7 @@ config_generate() {
|
||||||
.api.server.profiles_path=strenv(CONFIG_DIR)+"/profiles.yaml" |
|
.api.server.profiles_path=strenv(CONFIG_DIR)+"/profiles.yaml" |
|
||||||
.api.server.console_path=strenv(CONFIG_DIR)+"/console.yaml" |
|
.api.server.console_path=strenv(CONFIG_DIR)+"/console.yaml" |
|
||||||
.crowdsec_service.console_context_path=strenv(CONFIG_DIR) + "/console/context.yaml" |
|
.crowdsec_service.console_context_path=strenv(CONFIG_DIR) + "/console/context.yaml" |
|
||||||
.api.server.online_client.credentials_path=strenv(CONFIG_DIR)+"/online_api_credentials.yaml"
|
del(.api.server.online_client)
|
||||||
' ../config/config.yaml >"${CONFIG_DIR}/config.yaml"
|
' ../config/config.yaml >"${CONFIG_DIR}/config.yaml"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,9 +120,9 @@ make_init_data() {
|
||||||
./instance-db config-yaml
|
./instance-db config-yaml
|
||||||
./instance-db setup
|
./instance-db setup
|
||||||
|
|
||||||
"$CSCLI" machines add githubciXXXXXXXXXXXXXXXXXXXXXXXX --auto
|
"$CSCLI" --warning machines add githubciXXXXXXXXXXXXXXXXXXXXXXXX --auto
|
||||||
"$CSCLI" hub update
|
"$CSCLI" --warning hub update
|
||||||
"$CSCLI" collections install crowdsecurity/linux
|
"$CSCLI" --warning collections install crowdsecurity/linux
|
||||||
|
|
||||||
mkdir -p "$LOCAL_INIT_DIR"
|
mkdir -p "$LOCAL_INIT_DIR"
|
||||||
|
|
||||||
|
@ -130,9 +130,6 @@ make_init_data() {
|
||||||
|
|
||||||
echo "${DB_BACKEND}" > "${LOCAL_INIT_DIR}/.backend"
|
echo "${DB_BACKEND}" > "${LOCAL_INIT_DIR}/.backend"
|
||||||
|
|
||||||
# disable CAPI by default
|
|
||||||
yq e 'del(.api.server.online_client)' -i "${CONFIG_DIR}/config.yaml"
|
|
||||||
|
|
||||||
"${TAR}" -C "${LOCAL_DIR}" --create \
|
"${TAR}" -C "${LOCAL_DIR}" --create \
|
||||||
--exclude "${REL_DATA_DIR}"/crowdsec.db \
|
--exclude "${REL_DATA_DIR}"/crowdsec.db \
|
||||||
--file "${LOCAL_INIT_DIR}/init-config-data.tar" "${REL_CONFIG_DIR}" "${REL_DATA_DIR}"
|
--file "${LOCAL_INIT_DIR}/init-config-data.tar" "${REL_CONFIG_DIR}" "${REL_DATA_DIR}"
|
||||||
|
|
Loading…
Reference in a new issue