Skip to content

Commit f13d799

Browse files
authored
Release v1.1.0
2 parents a1eeeb6 + 246383a commit f13d799

31 files changed

+541
-259
lines changed

Diff for: .github/scripts/compatibility_api_test_5.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import unittest
1010

1111
sys.path.append('.')
12-
from zabbix_utils.getter import Getter
12+
from zabbix_utils.getter import Getter, AgentResponse
1313
from zabbix_utils.api import ZabbixAPI, APIVersion
1414
from zabbix_utils.sender import ItemValue, Sender, TrapperResponse
1515
from zabbix_utils.exceptions import APIRequestError, APINotSupported
@@ -160,13 +160,18 @@ def test_send_values(self):
160160
ItemValue(self.hostname, self.itemkey, 0, 1695713666, 100),
161161
ItemValue(self.hostname, self.itemkey, 5.5, 1695713666)
162162
]
163-
resp = list(self.sender.send(items).values())[0]
164-
163+
resp = self.sender.send(items)
165164
self.assertEqual(type(resp), TrapperResponse, "Sending item values was going wrong")
166165
self.assertEqual(resp.total, len(items), "Total number of the sent values is unexpected")
167166
self.assertEqual(resp.processed, 4, "Number of the processed values is unexpected")
168167
self.assertEqual(resp.failed, (resp.total - resp.processed), "Number of the failed values is unexpected")
169168

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

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

187192
self.assertIsNotNone(resp, "Getting item values was going wrong")
188-
self.assertEqual(type(resp), str, "Got value is unexpected")
193+
self.assertEqual(type(resp), AgentResponse, "Got value is unexpected")
194+
self.assertEqual(type(resp.value), str, "Got value is unexpected")
189195

190196

191197
if __name__ == '__main__':

Diff for: .github/scripts/compatibility_api_test_6.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import unittest
1010

1111
sys.path.append('.')
12-
from zabbix_utils.getter import Getter
12+
from zabbix_utils.getter import Getter, AgentResponse
1313
from zabbix_utils.exceptions import APIRequestError
1414
from zabbix_utils.api import ZabbixAPI, APIVersion
1515
from zabbix_utils.sender import ItemValue, Sender, TrapperResponse
@@ -192,13 +192,18 @@ def test_send_values(self):
192192
ItemValue(self.hostname, self.itemkey, 0, 1695713666, 100),
193193
ItemValue(self.hostname, self.itemkey, 5.5, 1695713666)
194194
]
195-
resp = list(self.sender.send(items).values())[0]
196-
195+
resp = self.sender.send(items)
197196
self.assertEqual(type(resp), TrapperResponse, "Sending item values was going wrong")
198197
self.assertEqual(resp.total, len(items), "Total number of the sent values is unexpected")
199198
self.assertEqual(resp.processed, 4, "Number of the processed values is unexpected")
200199
self.assertEqual(resp.failed, (resp.total - resp.processed), "Number of the failed values is unexpected")
201200

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

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

219224
self.assertIsNotNone(resp, "Getting item values was going wrong")
220-
self.assertEqual(type(resp), str, "Got value is unexpected")
225+
self.assertEqual(type(resp), AgentResponse, "Got value is unexpected")
226+
self.assertEqual(type(resp.value), str, "Got value is unexpected")
221227

222228

223229
if __name__ == '__main__':

Diff for: .github/scripts/compatibility_api_test_latest.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import unittest
1010

1111
sys.path.append('.')
12-
from zabbix_utils.getter import Getter
12+
from zabbix_utils.getter import Getter, AgentResponse
1313
from zabbix_utils.exceptions import APIRequestError
1414
from zabbix_utils.api import ZabbixAPI, APIVersion
1515
from zabbix_utils.sender import ItemValue, Sender, TrapperResponse
@@ -204,13 +204,18 @@ def test_send_values(self):
204204
ItemValue(self.hostname, self.itemkey, 0, 1695713666, 100),
205205
ItemValue(self.hostname, self.itemkey, 5.5, 1695713666)
206206
]
207-
resp = list(self.sender.send(items).values())[0]
208-
207+
resp = self.sender.send(items)
209208
self.assertEqual(type(resp), TrapperResponse, "Sending item values was going wrong")
210209
self.assertEqual(resp.total, len(items), "Total number of the sent values is unexpected")
211210
self.assertEqual(resp.processed, 4, "Number of the processed values is unexpected")
212211
self.assertEqual(resp.failed, (resp.total - resp.processed), "Number of the failed values is unexpected")
213212

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

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

231236
self.assertIsNotNone(resp, "Getting item values was going wrong")
232-
self.assertEqual(type(resp), str, "Got value is unexpected")
237+
self.assertEqual(type(resp), AgentResponse, "Got value is unexpected")
238+
self.assertEqual(type(resp.value), str, "Got value is unexpected")
233239

234240

235241
if __name__ == '__main__':

Diff for: .github/scripts/integration_get_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_get(self):
3030

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

Diff for: .github/scripts/integration_sender_test.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,18 @@ def test_send(self):
3434
ItemValue('host3', 'item.key1', '{"msg":"test message"}'),
3535
ItemValue('host2', 'item.key1', 0, 1695713666, 100)
3636
]
37-
responses = self.sender.send(items)
37+
response = self.sender.send(items)
3838

39-
self.assertEqual(type(responses), dict, "Sending item values was going wrong")
40-
for node, resp in responses.items():
39+
self.assertEqual(type(response.details), dict, "Sending item values was going wrong")
40+
for node, resp in response.details.items():
4141
self.assertEqual(type(node), Node, "Sending item values was going wrong")
42-
self.assertEqual(type(resp), TrapperResponse, "Sending item values was going wrong")
43-
for key in ('processed', 'failed', 'total', 'time', 'chunk'):
44-
try:
45-
self.assertIsNotNone(getattr(resp, key), f"There aren't expected '{key}' value")
46-
except AttributeError:
47-
self.fail(f"raised unexpected Exception for attribute: {key}")
42+
for item in resp:
43+
self.assertEqual(type(item), TrapperResponse, "Sending item values was going wrong")
44+
for key in ('processed', 'failed', 'total', 'time', 'chunk'):
45+
try:
46+
self.assertIsNotNone(getattr(item, key), f"There aren't expected '{key}' value")
47+
except AttributeError:
48+
self.fail(f"raised unexpected Exception for attribute: {key}")
4849

4950

5051
if __name__ == '__main__':

Diff for: .github/workflows/build.yaml

-64
This file was deleted.

Diff for: .github/workflows/coverage.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: coverage
22
run-name: Check test coverage
33

44
on:
5-
#push:
6-
# branches: [main]
7-
#pull_request:
8-
# branches: [main]
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
99
workflow_dispatch:
1010

1111
jobs:

Diff for: .github/workflows/integration_api.yaml

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ name: api
22
run-name: Run Zabbix API integration test
33

44
on:
5-
#push:
6-
# branches: [main]
7-
#pull_request:
8-
# branches: [main]
5+
push:
6+
branches: [main]
7+
paths:
8+
- '**api.py'
9+
pull_request:
10+
branches: [main]
11+
paths:
12+
- '**api.py'
913
workflow_dispatch:
1014

1115
env:

Diff for: .github/workflows/integration_get.yaml

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ name: get
22
run-name: Run Zabbix get integration test
33

44
on:
5-
#push:
6-
# branches: [main]
7-
#pull_request:
8-
# branches: [main]
5+
push:
6+
branches: [main]
7+
paths:
8+
- '**get.py'
9+
pull_request:
10+
branches: [main]
11+
paths:
12+
- '**get.py'
913
workflow_dispatch:
1014

1115
env:

Diff for: .github/workflows/integration_sender.yaml

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ name: sender
22
run-name: Run Zabbix sender integration test
33

44
on:
5-
#push:
6-
# branches: [main]
7-
#pull_request:
8-
# branches: [main]
5+
push:
6+
branches: [main]
7+
paths:
8+
- '**sender.py'
9+
pull_request:
10+
branches: [main]
11+
paths:
12+
- '**sender.py'
913
workflow_dispatch:
1014

1115
env:

Diff for: .github/workflows/release.yaml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: release
2+
run-name: Release new version
3+
4+
on:
5+
push:
6+
branches: [main]
7+
paths:
8+
- '**version.py'
9+
workflow_dispatch:
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-python@v4
17+
with:
18+
python-version: '3.10'
19+
- name: Get pip cache
20+
id: pip-cache
21+
run: |
22+
python -c "from pip._internal.locations import USER_CACHE_DIR; print('dir=' + USER_CACHE_DIR)" >> $GITHUB_OUTPUT
23+
- uses: actions/cache@v3
24+
with:
25+
path: ${{ steps.pip-cache.outputs.dir }}
26+
key: ${{ runner.os }}-pip
27+
- name: Install build requirements
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install setuptools wheel
31+
pip install -r ./requirements.txt
32+
- name: Set version env
33+
run: |
34+
echo "LIBRARY_VERSION=$(python -c "import sys; sys.path.append('.'); from zabbix_utils.version import __version__; print(__version__)")" >> $GITHUB_ENV
35+
- name: Build packages
36+
run: |
37+
python setup.py sdist bdist_wheel
38+
- name: Add version tag
39+
uses: pkgdeps/git-tag-action@v2
40+
with:
41+
github_token: ${{ secrets.GITHUB_TOKEN }}
42+
github_repo: ${{ github.repository }}
43+
git_commit_sha: ${{ github.sha }}
44+
version: ${{ env.LIBRARY_VERSION }}
45+
git_tag_prefix: "v"
46+
- name: Archive built packages
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: Archive-v${{ env.LIBRARY_VERSION }}
50+
path: dist/*
51+
- name: Create release notes
52+
run: |
53+
grep -Pzo '(?s)^## \[${{ env.LIBRARY_VERSION }}\].*?(?=## \[)' CHANGELOG.md | sed '$ s/.$//' > RELEASE_NOTES.md
54+
sed -i 's/\[${{ env.LIBRARY_VERSION }}\]/Release [v${{ env.LIBRARY_VERSION }}]/' RELEASE_NOTES.md
55+
- name: Create release
56+
uses: ncipollo/release-action@v1
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
with:
60+
name: v${{ env.LIBRARY_VERSION }}
61+
draft: true
62+
prerelease: false
63+
makeLatest: true
64+
skipIfReleaseExists: true
65+
replacesArtifacts: true
66+
removeArtifacts: true
67+
tag: "v${{ env.LIBRARY_VERSION }}"
68+
bodyFile: RELEASE_NOTES.md
69+
artifacts: dist/*

Diff for: CHANGELOG.md

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
## [1.1.0](https://github.com/zabbix/python-zabbix-utils/compare/v1.0.3...v1.1.0) (2024-01-23)
2+
3+
### Breaking Changes:
4+
5+
- changed the format of the Sender response
6+
- changed the format of the Getter response
7+
8+
### Features:
9+
10+
- implemented support for specifying Zabbix clusters in Sender
11+
- implemented pre-processing of the agent response
12+
13+
### Bug fixes:
14+
15+
- fixed issue with hiding private (sensitive) fields in the log
16+
- fixed small bugs and flaws
17+
118
## [1.0.3](https://github.com/zabbix/python-zabbix-utils/compare/v1.0.2...v1.0.3) (2024-01-09)
219

320
### Documentation

0 commit comments

Comments
 (0)