Skip to content

Commit 322be7e

Browse files
ci: Move examples to tests and split SdMonitorclient into EventsClient's (#136)
Co-authored-by: Vicente Herrera <[email protected]>
1 parent db014cd commit 322be7e

26 files changed

+1031
-243
lines changed

.github/workflows/ci-pull-request.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ jobs:
1919
run: python -m pip install pipenv
2020

2121
- uses: actions/cache@v2
22+
name: Cache Pipenv dependencies
2223
with:
23-
path: ~/.cache
24+
path: |
25+
~/.cache
26+
~/.local/share/virtualenvs/
2427
key: ${{ runner.os }}-pipenv-${{ hashFiles('**/Pipfile.lock') }}
2528
restore-keys: |
2629
${{ runner.os }}-pipenv-
@@ -47,20 +50,11 @@ jobs:
4750
- name: Travis Test - Install dependencies
4851
run: pip install .
4952

50-
- name: Travis Test - Monitor APIs
51-
env:
52-
PYTHON_SDC_TEST_MONITOR_API_TOKEN: ${{ secrets.STAGING_MONITOR_API_TOKEN }}
53-
run: ./test/test_monitor_apis.sh
54-
5553
- name: Travis Test - Secure APIs
5654
env:
5755
PYTHON_SDC_TEST_API_TOKEN: ${{ secrets.STAGING_SECURE_API_TOKEN }}
5856
run: ./test/test_secure_apis.sh
5957

60-
- name: Travis Test - Stop agent
61-
run: ./test/stop_agent.sh
62-
if: steps.start_agent.outcome == 'success'
63-
6458
- name: Test in staging
6559
env:
6660
SDC_MONITOR_TOKEN: ${{ secrets.STAGING_MONITOR_API_TOKEN }}
@@ -69,3 +63,7 @@ jobs:
6963
SDC_SECURE_URL: "https://secure-staging.sysdig.com"
7064
run: |
7165
pipenv run mamba -f documentation
66+
67+
- name: Travis Test - Stop agent
68+
run: ./test/stop_agent.sh
69+
if: steps.start_agent.outcome == 'success'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,5 @@ venv/
6464

6565
# IntelliJ projects
6666
.idea/
67+
68+
coverage/

.travis.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
3+
.PHONY: test
4+
test:
5+
pipenv run mamba -f documentation
6+
7+
.coverage:
8+
pipenv run coverage run $(shell pipenv run which mamba) -f documentation || true
9+
10+
cover: .coverage
11+
pipenv run coverage report --include 'sdcclient/*'
12+
13+
.PHONY: cover-html
14+
cover-html: .coverage
15+
pipenv run coverage html -d coverage --include 'sdcclient/*'
16+

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ expects = "*"
1111
flake8 = "*"
1212
pipenv-setup = "*"
1313
sdcclient = {editable = true, path = "."}
14+
coverage = "*"
1415

1516
[packages]
1617
requests = "*"

Pipfile.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/delete_event.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
import getopt
77
import sys
88

9-
from sdcclient import SdcClient
10-
9+
from sdcclient import SdcClient, SdMonitorClient
1110

1211
#
1312
# Parse arguments
1413
#
14+
from sdcclient.monitor import EventsClientV2
15+
16+
1517
def usage():
1618
print(('usage: %s [-e|--event <name>] <sysdig-token>' % sys.argv[0]))
1719
print('-e|--event: Name of event to delete')
@@ -37,7 +39,7 @@ def usage():
3739
#
3840
# Instantiate the SDC client
3941
#
40-
sdclient = SdcClient(sdc_token)
42+
sdclient = SdMonitorClient(sdc_token)
4143

4244
#
4345
# Get the events that match a name

examples/list_events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import sys
77

8-
from sdcclient import SdcClient
8+
from sdcclient import SdMonitorClient
99

1010

1111
def print_events(data):
@@ -29,7 +29,7 @@ def print_events(data):
2929
#
3030
# Instantiate the SDC client
3131
#
32-
sdclient = SdcClient(sdc_token)
32+
sdclient = SdMonitorClient(sdc_token)
3333

3434
#
3535
# Get the entire list of events

examples/post_event.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import json
88
import sys
99

10-
from sdcclient import SdcClient
10+
from sdcclient import SdMonitorClient
1111

1212
#
1313
# Parse arguments
@@ -33,7 +33,7 @@
3333
#
3434
# Instantiate the SDC client
3535
#
36-
sdclient = SdcClient(args.sysdig_token)
36+
sdclient = SdMonitorClient(args.sysdig_token)
3737

3838
#
3939
# Post the event using post_event(self, name, description=None, severity=None, event_filter=None, tags=None)

examples/post_event_simple.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import sys
77

8-
from sdcclient import SdcClient
8+
from sdcclient import SdMonitorClient
99

1010
#
1111
# Parse arguments
@@ -29,7 +29,7 @@
2929
#
3030
# Instantiate the SDC client
3131
#
32-
sdclient = SdcClient(sdc_token)
32+
sdclient = SdMonitorClient(sdc_token)
3333

3434
#
3535
# Post the event

0 commit comments

Comments
 (0)