Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v1.1.0 #5

Merged
merged 11 commits into from
Jan 23, 2024
14 changes: 10 additions & 4 deletions .github/scripts/compatibility_api_test_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import unittest

sys.path.append('.')
from zabbix_utils.getter import Getter
from zabbix_utils.getter import Getter, AgentResponse
from zabbix_utils.api import ZabbixAPI, APIVersion
from zabbix_utils.sender import ItemValue, Sender, TrapperResponse
from zabbix_utils.exceptions import APIRequestError, APINotSupported
Expand Down Expand Up @@ -160,13 +160,18 @@ def test_send_values(self):
ItemValue(self.hostname, self.itemkey, 0, 1695713666, 100),
ItemValue(self.hostname, self.itemkey, 5.5, 1695713666)
]
resp = list(self.sender.send(items).values())[0]

resp = self.sender.send(items)
self.assertEqual(type(resp), TrapperResponse, "Sending item values was going wrong")
self.assertEqual(resp.total, len(items), "Total number of the sent values is unexpected")
self.assertEqual(resp.processed, 4, "Number of the processed values is unexpected")
self.assertEqual(resp.failed, (resp.total - resp.processed), "Number of the failed values is unexpected")

first_chunk = list(resp.details.values())[0][0]
self.assertEqual(type(first_chunk), TrapperResponse, "Sending item values was going wrong")
self.assertEqual(first_chunk.total, len(items), "Total number of the sent values is unexpected")
self.assertEqual(first_chunk.processed, 4, "Number of the processed values is unexpected")
self.assertEqual(first_chunk.failed, (first_chunk.total - first_chunk.processed), "Number of the failed values is unexpected")


class CompatibilityGetTest(unittest.TestCase):
"""Compatibility test with Zabbix get version 5.0"""
Expand All @@ -185,7 +190,8 @@ def test_get_values(self):
resp = self.agent.get('system.uname')

self.assertIsNotNone(resp, "Getting item values was going wrong")
self.assertEqual(type(resp), str, "Got value is unexpected")
self.assertEqual(type(resp), AgentResponse, "Got value is unexpected")
self.assertEqual(type(resp.value), str, "Got value is unexpected")


if __name__ == '__main__':
Expand Down
14 changes: 10 additions & 4 deletions .github/scripts/compatibility_api_test_6.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import unittest

sys.path.append('.')
from zabbix_utils.getter import Getter
from zabbix_utils.getter import Getter, AgentResponse
from zabbix_utils.exceptions import APIRequestError
from zabbix_utils.api import ZabbixAPI, APIVersion
from zabbix_utils.sender import ItemValue, Sender, TrapperResponse
Expand Down Expand Up @@ -192,13 +192,18 @@ def test_send_values(self):
ItemValue(self.hostname, self.itemkey, 0, 1695713666, 100),
ItemValue(self.hostname, self.itemkey, 5.5, 1695713666)
]
resp = list(self.sender.send(items).values())[0]

resp = self.sender.send(items)
self.assertEqual(type(resp), TrapperResponse, "Sending item values was going wrong")
self.assertEqual(resp.total, len(items), "Total number of the sent values is unexpected")
self.assertEqual(resp.processed, 4, "Number of the processed values is unexpected")
self.assertEqual(resp.failed, (resp.total - resp.processed), "Number of the failed values is unexpected")

first_chunk = list(resp.details.values())[0][0]
self.assertEqual(type(first_chunk), TrapperResponse, "Sending item values was going wrong")
self.assertEqual(first_chunk.total, len(items), "Total number of the sent values is unexpected")
self.assertEqual(first_chunk.processed, 4, "Number of the processed values is unexpected")
self.assertEqual(first_chunk.failed, (first_chunk.total - first_chunk.processed), "Number of the failed values is unexpected")


class CompatibilityGetTest(unittest.TestCase):
"""Compatibility test with Zabbix get version 6.0"""
Expand All @@ -217,7 +222,8 @@ def test_get_values(self):
resp = self.agent.get('system.uname')

self.assertIsNotNone(resp, "Getting item values was going wrong")
self.assertEqual(type(resp), str, "Got value is unexpected")
self.assertEqual(type(resp), AgentResponse, "Got value is unexpected")
self.assertEqual(type(resp.value), str, "Got value is unexpected")


if __name__ == '__main__':
Expand Down
14 changes: 10 additions & 4 deletions .github/scripts/compatibility_api_test_latest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import unittest

sys.path.append('.')
from zabbix_utils.getter import Getter
from zabbix_utils.getter import Getter, AgentResponse
from zabbix_utils.exceptions import APIRequestError
from zabbix_utils.api import ZabbixAPI, APIVersion
from zabbix_utils.sender import ItemValue, Sender, TrapperResponse
Expand Down Expand Up @@ -204,13 +204,18 @@ def test_send_values(self):
ItemValue(self.hostname, self.itemkey, 0, 1695713666, 100),
ItemValue(self.hostname, self.itemkey, 5.5, 1695713666)
]
resp = list(self.sender.send(items).values())[0]

resp = self.sender.send(items)
self.assertEqual(type(resp), TrapperResponse, "Sending item values was going wrong")
self.assertEqual(resp.total, len(items), "Total number of the sent values is unexpected")
self.assertEqual(resp.processed, 4, "Number of the processed values is unexpected")
self.assertEqual(resp.failed, (resp.total - resp.processed), "Number of the failed values is unexpected")

first_chunk = list(resp.details.values())[0][0]
self.assertEqual(type(first_chunk), TrapperResponse, "Sending item values was going wrong")
self.assertEqual(first_chunk.total, len(items), "Total number of the sent values is unexpected")
self.assertEqual(first_chunk.processed, 4, "Number of the processed values is unexpected")
self.assertEqual(first_chunk.failed, (first_chunk.total - first_chunk.processed), "Number of the failed values is unexpected")


class CompatibilityGetTest(unittest.TestCase):
"""Compatibility test with the latest Zabbix get version"""
Expand All @@ -229,7 +234,8 @@ def test_get_values(self):
resp = self.agent.get('system.uname')

self.assertIsNotNone(resp, "Getting item values was going wrong")
self.assertEqual(type(resp), str, "Got value is unexpected")
self.assertEqual(type(resp), AgentResponse, "Got value is unexpected")
self.assertEqual(type(resp.value), str, "Got value is unexpected")


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/integration_get_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_get(self):

self.assertIsNotNone(resp, "Getting item values was going wrong")
try:
resp_list = json.loads(resp)
resp_list = json.loads(resp.value)
except json.decoder.JSONDecodeError:
self.fail(f"raised unexpected Exception while parsing response: {resp}")

Expand Down
19 changes: 10 additions & 9 deletions .github/scripts/integration_sender_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,18 @@ def test_send(self):
ItemValue('host3', 'item.key1', '{"msg":"test message"}'),
ItemValue('host2', 'item.key1', 0, 1695713666, 100)
]
responses = self.sender.send(items)
response = self.sender.send(items)

self.assertEqual(type(responses), dict, "Sending item values was going wrong")
for node, resp in responses.items():
self.assertEqual(type(response.details), dict, "Sending item values was going wrong")
for node, resp in response.details.items():
self.assertEqual(type(node), Node, "Sending item values was going wrong")
self.assertEqual(type(resp), TrapperResponse, "Sending item values was going wrong")
for key in ('processed', 'failed', 'total', 'time', 'chunk'):
try:
self.assertIsNotNone(getattr(resp, key), f"There aren't expected '{key}' value")
except AttributeError:
self.fail(f"raised unexpected Exception for attribute: {key}")
for item in resp:
self.assertEqual(type(item), TrapperResponse, "Sending item values was going wrong")
for key in ('processed', 'failed', 'total', 'time', 'chunk'):
try:
self.assertIsNotNone(getattr(item, key), f"There aren't expected '{key}' value")
except AttributeError:
self.fail(f"raised unexpected Exception for attribute: {key}")


if __name__ == '__main__':
Expand Down
64 changes: 0 additions & 64 deletions .github/workflows/build.yaml

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: coverage
run-name: Check test coverage

on:
#push:
# branches: [main]
#pull_request:
# branches: [main]
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/integration_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ name: api
run-name: Run Zabbix API integration test

on:
#push:
# branches: [main]
#pull_request:
# branches: [main]
push:
branches: [main]
paths:
- '**api.py'
pull_request:
branches: [main]
paths:
- '**api.py'
workflow_dispatch:

env:
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/integration_get.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ name: get
run-name: Run Zabbix get integration test

on:
#push:
# branches: [main]
#pull_request:
# branches: [main]
push:
branches: [main]
paths:
- '**get.py'
pull_request:
branches: [main]
paths:
- '**get.py'
workflow_dispatch:

env:
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/integration_sender.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ name: sender
run-name: Run Zabbix sender integration test

on:
#push:
# branches: [main]
#pull_request:
# branches: [main]
push:
branches: [main]
paths:
- '**sender.py'
pull_request:
branches: [main]
paths:
- '**sender.py'
workflow_dispatch:

env:
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: release
run-name: Release new version

on:
push:
branches: [main]
paths:
- '**version.py'
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Get pip cache
id: pip-cache
run: |
python -c "from pip._internal.locations import USER_CACHE_DIR; print('dir=' + USER_CACHE_DIR)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip
- name: Install build requirements
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
pip install -r ./requirements.txt
- name: Set version env
run: |
echo "LIBRARY_VERSION=$(python -c "import sys; sys.path.append('.'); from zabbix_utils.version import __version__; print(__version__)")" >> $GITHUB_ENV
- name: Build packages
run: |
python setup.py sdist bdist_wheel
- name: Add version tag
uses: pkgdeps/git-tag-action@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_repo: ${{ github.repository }}
git_commit_sha: ${{ github.sha }}
version: ${{ env.LIBRARY_VERSION }}
git_tag_prefix: "v"
- name: Archive built packages
uses: actions/upload-artifact@v4
with:
name: Archive-v${{ env.LIBRARY_VERSION }}
path: dist/*
- name: Create release notes
run: |
grep -Pzo '(?s)^## \[${{ env.LIBRARY_VERSION }}\].*?(?=## \[)' CHANGELOG.md | sed '$ s/.$//' > RELEASE_NOTES.md
sed -i 's/\[${{ env.LIBRARY_VERSION }}\]/Release [v${{ env.LIBRARY_VERSION }}]/' RELEASE_NOTES.md
- name: Create release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: v${{ env.LIBRARY_VERSION }}
draft: true
prerelease: false
makeLatest: true
skipIfReleaseExists: true
replacesArtifacts: true
removeArtifacts: true
tag: "v${{ env.LIBRARY_VERSION }}"
bodyFile: RELEASE_NOTES.md
artifacts: dist/*
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
## [1.1.0](https://github.com/zabbix/python-zabbix-utils/compare/v1.0.3...v1.1.0) (2024-01-23)

### Breaking Changes:

- changed the format of the Sender response
- changed the format of the Getter response

### Features:

- implemented support for specifying Zabbix clusters in Sender
- implemented pre-processing of the agent response

### Bug fixes:

- fixed issue with hiding private (sensitive) fields in the log
- fixed small bugs and flaws

## [1.0.3](https://github.com/zabbix/python-zabbix-utils/compare/v1.0.2...v1.0.3) (2024-01-09)

### Documentation
Expand Down
Loading