-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from IBMStreams/develop
1.7.1
- Loading branch information
Showing
14 changed files
with
231 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// | ||
// **************************************************************************** | ||
// * Copyright (C) 2017, International Business Machines Corporation * | ||
// * All rights reserved. * | ||
// **************************************************************************** | ||
// | ||
|
||
use com.ibm.streamsx.topology.topic::Subscribe; | ||
use com.ibm.streamsx.json::*; | ||
|
||
/** | ||
* Create the custom application metrics. The function is usable in the state | ||
* logic of an operator. | ||
*/ | ||
stateful boolean createMetrics() { | ||
createCustomMetric("inc", "The incrementing number.", Sys.Counter, 0l); | ||
return true; | ||
} | ||
|
||
/** | ||
* This test application subscribes the topic of the MetricsMonitor microservice | ||
* | ||
* @param metricsMonitorTopic | ||
* Specifies the topic of the MetricsMonitor microservice | ||
* | ||
*/ | ||
composite Main { | ||
param | ||
expression<rstring> $metricsMonitorTopic : getSubmissionTimeValue("metricsMonitorTopic", "streamsx/monitoring/metrics/alerts"); | ||
|
||
graph | ||
|
||
stream<Json> JsonMonitor = Subscribe() { | ||
param | ||
topic: $metricsMonitorTopic; | ||
streamType: Json; | ||
} | ||
|
||
(stream <rstring result> SaveDone1) as Validator = Custom(JsonMonitor as I) { | ||
logic | ||
state: { | ||
mutable boolean done1Sent = false; | ||
} | ||
onTuple I: { | ||
printStringLn((rstring)I); | ||
if (!done1Sent) { | ||
submit({result="TEST_RESULT_PASS"}, SaveDone1); | ||
submit(Sys.WindowMarker, SaveDone1); | ||
done1Sent = true; | ||
} | ||
} | ||
} | ||
|
||
() as Done1 = FileSink(SaveDone1 as I) { | ||
param file: "done_1"; format: csv; flush: 1u; quoteStrings : false; writePunctuations: false; closeMode: punct; moveFileToDirectory: dataDirectory()+"/.."; | ||
} | ||
|
||
/* | ||
* The Beacon generates incrementing. | ||
*/ | ||
stream<int64 incrementingNumber> Numbers as O = Beacon() { | ||
param period: 0.5; | ||
output O: | ||
incrementingNumber = (int64)IterationCount(); | ||
} | ||
|
||
/* | ||
* The Custom stores the received numbers in metrics. | ||
*/ | ||
() as Storage = Custom(Numbers as I) { | ||
logic | ||
state: { | ||
boolean created = createMetrics(); | ||
} | ||
onTuple I: { | ||
setCustomMetricValue("inc", I.incrementingNumber); | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright (C) 2017, International Business Machines Corporation. | ||
# All Rights Reserved. | ||
|
||
.PHONY: build all clean distributed | ||
|
||
SPLC_FLAGS = -a | ||
OUTPUT_DIR = output | ||
ifeq ($(STREAMS_INSTALL),) | ||
$(error error: environment variable STREAMS_INSTALL has to be set) | ||
endif | ||
STREAMSX_MONITORING_TOOLKIT ?=../../../../com.ibm.streamsx.monitoring | ||
SPLC = $(STREAMS_INSTALL)/bin/sc | ||
STREAMSX_JSON_TOOLKIT ?=$(STREAMS_INSTALL)/toolkits/com.ibm.streamsx.json | ||
STREAMSX_TOPOLOGY_TOOLKIT ?=$(STREAMS_INSTALL)/toolkits/com.ibm.streamsx.topology | ||
SPL_PATH = $(STREAMSX_MONITORING_TOOLKIT):$(STREAMSX_JSON_TOOLKIT):$(STREAMSX_TOPOLOGY_TOOLKIT) | ||
|
||
SPLC_FLAGS += -t $(SPL_PATH) | ||
SPL_DATA_DIR = ./data | ||
|
||
SPL_CMD_ARGS ?= | ||
SPL_MAIN_COMPOSITE = Main | ||
|
||
MICROSERVICES_DIR =../../../../microservices | ||
|
||
build: distributed | ||
|
||
all: clean build | ||
cd $(MICROSERVICES_DIR); make -f Makefile all | ||
|
||
distributed: | ||
$(SPLC) $(SPLC_FLAGS) -M $(SPL_MAIN_COMPOSITE) $(SPL_CMD_ARGS) --data-directory $(SPL_DATA_DIR) --output-directory=$(OUTPUT_DIR) | ||
|
||
clean: | ||
$(SPLC) $(SPLC_FLAGS) -C -M $(SPL_MAIN_COMPOSITE) | ||
rm -rf $(OUTPUT_DIR) | ||
|
||
configure: | ||
-streamtool rmappconfig --noprompt com.ibm.streamsx.monitoring.microservices.ApplicationConfiguration | ||
streamtool mkappconfig --property user=$(JMX_USER) --property password=$(JMX_PASSWORD) --property thresholdDocument=`cat etc/microservices.json | perl -e 'my @content = <STDIN>; my $$str = join("", @content); $$str =~ s/\s//g; print $$str;'` com.ibm.streamsx.monitoring.microservices.ApplicationConfiguration | ||
|
||
configure-none: | ||
-streamtool rmappconfig --noprompt com.ibm.streamsx.monitoring.microservices.ApplicationConfiguration | ||
|
||
start-monitor: | ||
streamtool submitjob $(MICROSERVICES_DIR)/MetricsIngestService/output/com.ibm.streamsx.monitoring.service.MetricsIngestService.sab --jobname microserviceMetrics -P applicationConfigurationName=com.ibm.streamsx.monitoring.microservices.ApplicationConfiguration | ||
streamtool submitjob $(MICROSERVICES_DIR)/MetricsMonitorService/output/com.ibm.streamsx.monitoring.service.MetricsMonitorService.sab --jobname microserviceMonitor -P applicationConfigurationName=com.ibm.streamsx.monitoring.microservices.ApplicationConfiguration | ||
streamtool submitjob output/Main.sab --jobname testMicroservices | ||
|
||
stop-monitor: | ||
streamtool canceljob --jobnames microserviceMetrics --collectlogs | ||
streamtool canceljob --jobnames microserviceMonitor --collectlogs | ||
streamtool canceljob --jobnames testMicroservices --collectlogs | ||
|
Empty file.
1 change: 1 addition & 0 deletions
1
tests/spl-test/MetricsMonitor/test_microservices/data/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
done* |
9 changes: 9 additions & 0 deletions
9
tests/spl-test/MetricsMonitor/test_microservices/etc/microservices.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[ | ||
{ | ||
"metricName":"inc", | ||
"thresholds": | ||
{ | ||
"value":">100" | ||
} | ||
} | ||
] |
42 changes: 42 additions & 0 deletions
42
tests/spl-test/MetricsMonitor/test_microservices/test_microservices.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import unittest | ||
import os | ||
import testharness as th | ||
|
||
class MetricsMonitorMicroservicesTest(unittest.TestCase): | ||
|
||
result_file_1 = "done_1" | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
try: | ||
os.environ["JMX_USER"] | ||
os.environ["JMX_PASSWORD"] | ||
except KeyError: | ||
print ("ERROR: Please set the environment variables JMX_USER and JMX_PASSWORD") | ||
raise | ||
|
||
def setUp(self): | ||
os.chdir(os.path.dirname(os.path.abspath(__file__))) | ||
th.remove_f(self.result_file_1) | ||
th.remove_files("StreamsLogsJob*.tgz") | ||
|
||
def tearDown(self): | ||
os.chdir(os.path.dirname(os.path.abspath(__file__))) | ||
th.remove_f(self.result_file_1) | ||
th.stop_monitor() | ||
th.rm_app_config() | ||
|
||
def test_distributed(self): | ||
os.chdir(os.path.dirname(os.path.abspath(__file__))) | ||
|
||
th.create_app_config() | ||
th.make_applications() | ||
th.start_monitor() | ||
th.wait_for_file(self.result_file_1) | ||
err = th.test_result_file(self.result_file_1) | ||
self.assertEqual(err, 0) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters