Skip to content

Commit

Permalink
Merge branch 'main' into appstudio-insights-behavioral-spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Zibricky authored and Martin Zibricky committed Oct 11, 2024
2 parents ee7fa72 + 177b7da commit 98b0f74
Show file tree
Hide file tree
Showing 43 changed files with 129 additions and 174 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Set as automatically merge all the pull requests created by dependabot[bot]
name: Dependabot auto-merge
# Set as automatically merge all the pull requests created by dependabot[bot], red-hat-konflux[bot], InsightsDroid.
name: Bots auto-merge
on: pull_request

# This section adds write permissions to the secrets.GITHUB_TOKEN. Default is just read
Expand All @@ -8,30 +8,27 @@ permissions:
pull-requests: write

jobs:
dependabot:
bot-automerge:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
# Check the pull request author.
if: |
github.event.pull_request.user.login == 'dependabot[bot]' ||
github.event.pull_request.user.login == 'red-hat-konflux[bot]' ||
github.event.pull_request.user.login == 'InsightsDroid'
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
# NOTE: PR approval does not work on PRs from forks
- name: Github Actions bot approves the PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{ github.token }}
- name: InsightsDroid approves the PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.INSIGHTSDROID_TOKEN}}
- name: Enable auto-merge for Dependabot PRs
# We can filter depending on the semver major, minor, or patch updates,
# but let's not do it for now
# if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
- name: Enable auto-merge for PR
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
GH_TOKEN: ${{ github.token }}
2 changes: 0 additions & 2 deletions CODEOWNERS

This file was deleted.

17 changes: 6 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,11 @@ ENV VIRTUAL_ENV=/insights-behavioral-spec-venv \
WORKDIR $HOME

ENV PATH="$VIRTUAL_ENV/bin:$PATH"

RUN microdnf install --nodocs -y python3.11 unzip make lsof git libpq-devel tar

RUN python3.11 -m venv $VIRTUAL_ENV && source $VIRTUAL_ENV/bin/activate

RUN pip install --no-cache-dir -U pip setuptools wheel

COPY requirements/requirements_docker.txt $HOME/requirements/

RUN pip install --no-cache-dir -r requirements/requirements_docker.txt
COPY requirements.txt $HOME/
RUN microdnf install --nodocs -y python3.11 unzip make lsof git libpq-devel tar &&\
python3.11 -m venv $VIRTUAL_ENV && source $VIRTUAL_ENV/bin/activate &&\
pip install --no-cache-dir -U pip wheel &&\
pip install --no-cache-dir -r requirements.txt

COPY . $HOME

Expand All @@ -45,4 +40,4 @@ COPY --from=quay.io/ccxdev/ccx-kcat:1.7.1 /usr/local/bin/kcat $VIRTUAL_ENV_BIN/k

USER 1001

CMD ["sh", "-c", "make $TESTS_TO_EXECUTE"]
CMD ["sh", "-c", "make $TESTS_TO_EXECUTE"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,4 @@ Please look at [this page](https://redhatinsights.github.io/insights-behavioral-
## Additional tools

This repository contains additional tools and helpers. Description of such tools can be found on [this page](https://redhatinsights.github.io/insights-behavioral-spec/tools.html)

8 changes: 4 additions & 4 deletions ccx_upgrade_risk_data_eng_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ PATH_TO_LOCAL_DATA_ENG_SERVICE=${PATH_TO_LOCAL_DATA_ENG_SERVICE:="../ccx-upgrade
[ "$VIRTUAL_ENV" != "" ] || NOVENV=1

function install_reqs() {
pip install -r requirements.txt
pip install -r requirements.txt || exit 1
}

function prepare_venv() {
echo "Preparing environment"
# shellcheck disable=SC1091
virtualenv -p python3 venv && source venv/bin/activate && pip install -r requirements/upgrades_data_eng_service.txt
virtualenv -p python3 venv && source venv/bin/activate && install_reqs
echo "Environment ready"
}

Expand Down Expand Up @@ -69,8 +69,8 @@ function add_exit_trap {

# prepare virtual environment if necessary
case "$NOVENV" in
"") echo "using existing virtual env";;
"1") install_reqs && prepare_venv ;;
"") echo "using existing virtual env" && install_reqs;;
"1") prepare_venv ;;
esac

# Copy the binary and configuration to this folder
Expand Down
8 changes: 4 additions & 4 deletions ccx_upgrade_risk_inference_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ PATH_TO_LOCAL_INFERENCE_SERVICE=${PATH_TO_LOCAL_INFERENCE_SERVICE:="../ccx-upgra
[ "$VIRTUAL_ENV" != "" ] || NOVENV=1

function install_reqs() {
pip install -r requirements.txt
pip install -r requirements.txt || exit 1
}

function prepare_venv() {
echo "Preparing environment"
# shellcheck disable=SC1091
virtualenv -p python3 venv && source venv/bin/activate && pip install -r requirements/upgrades_inference_service.txt
virtualenv -p python3 venv && source venv/bin/activate && install_reqs
echo "Environment ready"
}

Expand Down Expand Up @@ -59,8 +59,8 @@ function add_exit_trap {

# prepare virtual environment if necessary
case "$NOVENV" in
"") echo "using existing virtual env";;
"1") install_reqs && prepare_venv ;;
"") echo "using existing virtual env" && install_reqs;;
"1") prepare_venv ;;
esac

# Copy the binary and configuration to this folder
Expand Down
8 changes: 6 additions & 2 deletions cleaner_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

function install_reqs() {
pip install -r requirements.txt || exit 1
}

function prepare_venv() {
echo "preparing virtual environment for tests execution"
# shellcheck disable=SC1091
python3 -m venv venv && source venv/bin/activate && pip install -r requirements.txt || exit 1
python3 -m venv venv && source venv/bin/activate && install_reqs
echo "Environment ready"
}

Expand Down Expand Up @@ -66,7 +70,7 @@ fi
# prepare virtual environment if necessary
[ "$VIRTUAL_ENV" != "" ] || NOVENV=1
case "$NOVENV" in
"") echo "using existing virtual env";;
"") echo "using existing virtual env" && install_reqs;;
"1") prepare_venv;;
esac

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.9"
services:
# "pod" with the tests
bddtests:
image: quay.io/cloudservices/insights-behavioral-spec:latest
image: quay.io/redhat-services-prod/obsint-processing-tenant/insights-behavioral-spec/insights-behavioral-spec:latest
entrypoint:
- /bin/sh
- -c
Expand Down
3 changes: 1 addition & 2 deletions docs/BDD_intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ def after_all(context):
│ ├── adder.feature
│ └── steps
│ └── common.py
├── requirements.in
├── requirements.txt
├── run_tests.sh
└── src
Expand All @@ -357,7 +356,7 @@ def after_all(context):

```
src/adder.py tested module
requirements.in/requirements.txt used by PIP
requirements.txt used by PIP
feature_list.txt list of test scenarios
features/ test scenario(s) + implementation of test steps
run_tests.sh helper script to run Behave
Expand Down
12 changes: 7 additions & 5 deletions dvo_extractor_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export PATH_TO_LOCAL_DVO_EXTRACTOR=${PATH_TO_LOCAL_DVO_EXTRACTOR:="../dvo-extrac

exit_trap_command=""

function install_reqs() {
pip install -r requirements.txt || exit 1
}

function prepare_venv() {
echo "Preparing environment"
# shellcheck disable=SC1091
virtualenv -p python3 venv
# shellcheck disable=SC1091
source venv/bin/activate
pip install --no-cache -r requirements.in || exit 1
pip install --no-cache -r requirements/dvo_extractor.txt || exit 1
virtualenv -p python3 venv && source venv/bin/activate && install_reqs
echo "Environment ready"
}

Expand Down Expand Up @@ -97,6 +97,8 @@ fi

if [ "$NOVENV" ] ; then
prepare_venv
else
install_reqs
fi

install_extractor
Expand Down
8 changes: 6 additions & 2 deletions dvo_writer_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

function install_reqs() {
pip install -r requirements.txt || exit 1
}

function prepare_venv() {
echo "Preparing environment"
# shellcheck disable=SC1091
virtualenv -p python3 venv && source venv/bin/activate && python3 "$(which pip3)" install -r requirements/dvo_writer.txt || exit 1
virtualenv -p python3 venv && source venv/bin/activate && install_reqs
echo "Environment ready"
}

Expand Down Expand Up @@ -66,7 +70,7 @@ fi
# prepare virtual environment if necessary
[ "$VIRTUAL_ENV" != "" ] || NOVENV=1
case "$NOVENV" in
"") echo "using existing virtual env";;
"") echo "using existing virtual env" && install_reqs;;
"1") prepare_venv ;;
esac

Expand Down
11 changes: 7 additions & 4 deletions exporter_tests.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -x

# Copyright 2022, 2023 Red Hat, Inc
# Copyright 2022, 2023, 2024 Red Hat, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,10 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

function install_reqs() {
pip install -r requirements.txt || exit 1
}

function prepare_venv() {
echo "Preparing environment"
# shellcheck disable=SC1091
virtualenv -p python3 venv && source venv/bin/activate && pip install -r requirements/exporter.txt || exit 1
virtualenv -p python3 venv && source venv/bin/activate && install_reqs
echo "Environment ready"
}

Expand Down Expand Up @@ -73,11 +77,10 @@ fi
# prepare virtual environment if necessary
[ "$VIRTUAL_ENV" != "" ] || NOVENV=1
case "$NOVENV" in
"") echo "using existing virtual env";;
"") echo "using existing virtual env" && install_reqs;;
"1") prepare_venv;;
esac


if [[ -n $ENV_DOCKER ]]
then
# set env vars
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ Feature: Checking Aggregator behaviour during starting the service
And I run the Insights Results Aggregator with the start-service command line flag and config file name set to config/insights_results_aggregator_wrong_kafka.tom
Then The process should finish with exit code 1
And I should see following message in service output: "Failed to connect to broker"
And I should see following message in service output: "kafka: client has run out of available brokers to talk to (Is your cluster reachable?)"
And I should see following message in service output: "kafka: client has run out of available brokers to talk to"
And I should see following message in service output: "waiting for consumer to start"
5 changes: 3 additions & 2 deletions features/steps/insights_content_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ def check_utils_version(context):
def check_groups(context):
"""Check if groups attribute contains all expected group names."""
groups = context.response.json()["groups"]
assert len(groups) == 4, f"groups number is {len(groups)}"
assert len(groups) == 5, f"groups number is {len(groups)}"

expected = ["Performance", "Service Availability", "Security", "Fault Tolerance"]
expected = ["Performance", "Service Availability", "Security",
"Fault Tolerance", "Best Practices"]
for i, group in enumerate(groups):
err_msg = f"{groups[i]['title']} not in {expected}"
assert group["title"] in expected, err_msg
Expand Down
3 changes: 1 addition & 2 deletions insights_content_service_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ function prepare_venv() {
virtualenv -p python3 venv
# shellcheck disable=SC1091
source venv/bin/activate
pip install --no-cache -r requirements.in || exit 1
pip install --no-cache -r requirements/insights_content_service.txt || exit 1
pip install --no-cache -r requirements.txt || exit 1
echo "Environment ready"
}

Expand Down
15 changes: 9 additions & 6 deletions insights_content_template_renderer_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,28 @@ function clone_service() {
[ "$VIRTUAL_ENV" != "" ] || NOVENV=1

function install_reqs() {
pip install -r requirements.txt
pip install -r requirements/insights_content_template_renderer.txt
pip install -r requirements.txt || exit 1
}

function prepare_venv() {
echo "Preparing environment"
# shellcheck disable=SC1091
virtualenv -p python3 venv && source venv/bin/activate
virtualenv -p python3 venv && source venv/bin/activate && install_reqs
echo "Environment ready"
}

function install_service() {
cd "$PATH_TO_LOCAL_TEMPLATE_RENDERER" || exit
pip install -r requirements.txt
install_reqs
cd "$dir_path" || exit
}

# prepare virtual environment if necessary
case "$NOVENV" in
"") echo "using existing virtual env" && install_reqs;;
"1") prepare_venv ;;
esac

if [ ! -d "$PATH_TO_LOCAL_TEMPLATE_RENDERER" ]; then
if [[ -z $ENV_DOCKER ]]
then
Expand All @@ -57,8 +62,6 @@ else
echo "insights-content-template-renderer directory found in working directory"
fi

[ "$NOVENV" != "1" ] || prepare_venv || exit 1
install_reqs

# Copy the binary and configuration to this folder
install_service
Expand Down
8 changes: 6 additions & 2 deletions insights_results_aggregator_mock_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

function install_reqs() {
pip install -r requirements.txt || exit 1
}

function prepare_venv() {
echo "Preparing environment"
# shellcheck disable=SC1091
virtualenv -p python3 venv && source venv/bin/activate && pip install -r requirements/insights_results_aggregator_mock.txt || exit 1
virtualenv -p python3 venv && source venv/bin/activate && install_reqs
echo "Environment ready"
}

Expand Down Expand Up @@ -47,7 +51,7 @@ EOF
# prepare virtual environment if necessary
[ "$VIRTUAL_ENV" != "" ] || NOVENV=1
case "$NOVENV" in
"") echo "using existing virtual env";;
"") echo "using existing virtual env" && install_reqs;;
"1") prepare_venv ;;
esac

Expand Down
Loading

0 comments on commit 98b0f74

Please sign in to comment.