Skip to content

Commit

Permalink
[fix] Workflow and test updated #274
Browse files Browse the repository at this point in the history
Fixes #274
  • Loading branch information
praptisharma28 committed May 31, 2024
1 parent 2e3043c commit 97a0694
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
34 changes: 30 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
name: OpenWISP Monitoring CI Build

on:
Expand All @@ -21,6 +20,23 @@ jobs:
image: redis
ports:
- 6379:6379
influxdb1:
image: influxdb:1.8-alpine
ports:
- 8086:8086
influxdb2:
image: influxdb:2.0-alpine
volumes:
- influxdb2-data:/var/lib/influxdb2
ports:
- 8087:8086
options: >-
--env DOCKER_INFLUXDB_INIT_MODE=setup
--env DOCKER_INFLUXDB_INIT_USERNAME=openwisp
--env DOCKER_INFLUXDB_INIT_PASSWORD=openwisp
--env DOCKER_INFLUXDB_INIT_ORG=openwisp
--env DOCKER_INFLUXDB_INIT_BUCKET=openwisp2
--env DOCKER_INFLUXDB_INIT_RETENTION=1w
strategy:
fail-fast: false
Expand All @@ -33,6 +49,9 @@ jobs:
- django~=3.2.0
- django~=4.1.0
- django~=4.2.0
influxdb-version:
- influxdb1
- influxdb2

steps:
- name: Install system packages
Expand Down Expand Up @@ -62,10 +81,10 @@ jobs:
pip install -U pip wheel setuptools
- name: Install npm dependencies
run: sudo npm install -g install jshint stylelint
run: sudo npm install -g jshint stylelint

- name: Start InfluxDB container
run: docker-compose up -d influxdb
- name: Start InfluxDB ${{ matrix.influxdb-version }} container
run: docker-compose up -d ${{ matrix.influxdb-version }}

- name: Install test dependencies
run: |
Expand All @@ -77,6 +96,13 @@ jobs:
pip uninstall -y django
pip install ${{ matrix.django-version }}
- name: Set InfluxDB environment variables for InfluxDB 2.x
if: matrix.influxdb-version == 'influxdb2'
run: |
export INFLUXDB_HOST=localhost
export INFLUXDB_PORT=8087
export USE_INFLUXDB2=True
- name: QA checks
run: |
./run-qa-checks
Expand Down
7 changes: 6 additions & 1 deletion openwisp_monitoring/monitoring/tests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ def _get_new_metric(self):
"SELECT {fields|SUM|/ 1} FROM {key} "
"WHERE time >= '{time}' AND content_type = "
"'{content_type}' AND object_id = '{object_id}'"
)
),
'influxdb2': (
'from(bucket: "{key}") |> range(start: {time}) '
'|> filter(fn: (r) => r["_measurement"] == "{field_name}" and '
'r["content_type"] == "{content_type}" and r["object_id"] == "{object_id}")'
),
},
}
},
Expand Down

0 comments on commit 97a0694

Please sign in to comment.