Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
flame-clmc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flame
flame-clmc
Commits
e63f4198
Commit
e63f4198
authored
7 years ago
by
Nikolay Stanchev
Browse files
Options
Downloads
Patches
Plain Diff
[ Issue #57 and #47 ] - moved the kapacitor conf setup POST in a pytest fixture
parent
ef4cd061
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
test/streaming/conftest.py
+13
-0
13 additions, 0 deletions
test/streaming/conftest.py
test/streaming/setupCLMC.sh
+0
-10
0 additions, 10 deletions
test/streaming/setupCLMC.sh
test/streaming/test_streaming.py
+2
-0
2 additions, 0 deletions
test/streaming/test_streaming.py
with
15 additions
and
10 deletions
test/streaming/conftest.py
+
13
−
0
View file @
e63f4198
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
import
pytest
import
pytest
import
yaml
import
yaml
import
requests
@pytest.fixture
(
scope
=
"
module
"
,
params
=
[{
'
config
'
:
{
'
rspec
'
:
'
/vagrant/test/streaming/rspec.yml
'
}}])
@pytest.fixture
(
scope
=
"
module
"
,
params
=
[{
'
config
'
:
{
'
rspec
'
:
'
/vagrant/test/streaming/rspec.yml
'
}}])
...
@@ -16,3 +17,15 @@ def streaming_config(request):
...
@@ -16,3 +17,15 @@ def streaming_config(request):
with
open
(
request
.
param
[
'
config
'
][
'
rspec
'
],
'
r
'
)
as
stream
:
with
open
(
request
.
param
[
'
config
'
][
'
rspec
'
],
'
r
'
)
as
stream
:
data_loaded
=
yaml
.
load
(
stream
)
data_loaded
=
yaml
.
load
(
stream
)
return
data_loaded
return
data_loaded
@pytest.fixture
(
scope
=
"
module
"
,
autouse
=
True
,
params
=
[{
'
config
'
:
{
'
kapacitor_url
'
:
'
http://localhost:8888/chronograf/v1/sources/1/kapacitors
'
,
'
kapacitor_file
'
:
'
/vagrant/test/streaming/kapacitor.json
'
}}])
def
kapacitor_config
(
request
):
kapacitor_configuration
=
request
.
param
[
'
config
'
][
'
kapacitor_file
'
]
with
open
(
kapacitor_configuration
,
"
r
"
)
as
rule_file
:
data
=
""
.
join
(
line
.
strip
()
for
line
in
rule_file
.
readlines
())
kapacitor_url
=
request
.
param
[
'
config
'
][
'
kapacitor_url
'
]
requests
.
post
(
url
=
kapacitor_url
,
data
=
data
,
headers
=
{
"
Content-Type
"
:
"
application/json
"
})
This diff is collapsed.
Click to expand it.
test/streaming/setupCLMC.sh
+
0
−
10
View file @
e63f4198
...
@@ -33,18 +33,8 @@ echo $TEST_DIR"/kapacitor.conf"
...
@@ -33,18 +33,8 @@ echo $TEST_DIR"/kapacitor.conf"
cp
$TEST_DIR
/kapacitor.conf /etc/kapacitor/kapacitor.conf
cp
$TEST_DIR
/kapacitor.conf /etc/kapacitor/kapacitor.conf
systemctl start kapacitor
systemctl start kapacitor
# wait for kapacitor to restart
# TODO: do this better
sleep
5
# Set up Influx data source
# Set up Influx data source
curl
-i
-X
POST
-H
"Content-Type: application/json"
http://localhost:8888/chronograf/v1/sources
-d
@
$TEST_DIR
/influx.json
curl
-i
-X
POST
-H
"Content-Type: application/json"
http://localhost:8888/chronograf/v1/sources
-d
@
$TEST_DIR
/influx.json
# Set up Kapacitor
curl
-i
-X
POST
-H
"Content-Type: application/json"
http://localhost:8888/chronograf/v1/sources/1/kapacitors
-d
@
$TEST_DIR
/kapacitor.json
# Set up rules
curl
-i
-X
POST
-H
"Content-Type: application/json"
http://localhost:9092/kapacitor/v1/tasks
-d
@
$TEST_DIR
/rules.json
# Set up dashboard
# Set up dashboard
curl
-i
-X
POST
-H
"Content-Type: application/json"
http://localhost:8888/chronograf/v1/dashboards
-d
@
$TEST_DIR
/dashboard.json
curl
-i
-X
POST
-H
"Content-Type: application/json"
http://localhost:8888/chronograf/v1/dashboards
-d
@
$TEST_DIR
/dashboard.json
This diff is collapsed.
Click to expand it.
test/streaming/test_streaming.py
+
2
−
0
View file @
e63f4198
...
@@ -69,6 +69,8 @@ class TestStreamingAlerts(object):
...
@@ -69,6 +69,8 @@ class TestStreamingAlerts(object):
counter
+=
time_delay
# the counter tracks the time taken, for the rules under test usually a 20 seconds time frame is enough
counter
+=
time_delay
# the counter tracks the time taken, for the rules under test usually a 20 seconds time frame is enough
if
counter
>=
8
*
time_delay
:
if
counter
>=
8
*
time_delay
:
for
t
in
threads
:
# kill all running threads in case of test failure
t
.
stop
()
break
break
assert
alert_created
,
"
Alerts test failed: no log file is created indicating a triggered alert for rule {0}.
"
.
format
(
rule
)
assert
alert_created
,
"
Alerts test failed: no log file is created indicating a triggered alert for rule {0}.
"
.
format
(
rule
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment