Skip to content

Commit

Permalink
Merge 7640c42 into adc6e95
Browse files Browse the repository at this point in the history
  • Loading branch information
rpeach-sag committed Sep 24, 2018
2 parents adc6e95 + 7640c42 commit b642f88
Show file tree
Hide file tree
Showing 18 changed files with 590 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/tests/Operators/Sample/Async/Input/test.mon
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using utils.Test;
using utils.ExpectValues;

using com.industry.rx_epl.Subject;
using com.industry.rx_epl.ISubject;
using com.industry.rx_epl.Observable;
using com.industry.rx_epl.IObservable;
using com.industry.rx_epl.Subscriber;

monitor TestObservable {
Test test := Test("TestResult");

action onload() {
ISubject s := Subject.create();

any discard := s.sample(Observable.interval(0.2))
.subscribe(ExpectValues.create([<any>1,3], test.complete, test.fail));

on wait(0.1) {
s.next(0);
}
on wait(0.1999) {
s.next(1);
}
on wait(0.2) {
s.next(2);
}
on wait(0.3999) {
s.next(3);
s.complete();
}
}
}
24 changes: 24 additions & 0 deletions test/tests/Operators/Sample/Async/pysystest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" standalone="yes"?>
<pysystest type="auto" state="runnable">

<description>
<title>Sample Async</title>
<purpose><![CDATA[Sample Async]]></purpose>
</description>

<classification>
<groups>
<group></group>
</groups>
</classification>

<data>
<class name="PySysTest" module="run"/>
</data>

<traceability>
<requirements>
<requirement id=""/>
</requirements>
</traceability>
</pysystest>
54 changes: 54 additions & 0 deletions test/tests/Operators/Sample/Async/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright (c) 2015-2018 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from pysys.constants import *
from pysys.basetest import BaseTest
from apama.correlator import CorrelatorHelper

class PySysTest(BaseTest):

def execute(self):
correlator = CorrelatorHelper(self, name='correlator')
correlator.start(logfile='correlator.log', config=os.path.join(PROJECT.TEST_SUBJECT_DIR, 'initialization.yaml'))

correlator.flush()
correlator.injectEPL(filenames='testUtils.mon', filedir=PROJECT.UTILS_DIR)

# Set the log level to DEBUG so that we can see when the listeners are killed
correlator.setApplicationLogLevel(verbosity='DEBUG')

# Start test results receiver
correlator.receive(filename='TestResult.evt', channels=['TestResult'], logChannels=True)

# Inject test
correlator.injectEPL(filenames=['test.mon'])

# wait for all events to be processed
correlator.flush()

# wait for test to complete
self.waitForSignal('TestResult.evt', expr="TestComplete", condition="==1", timeout=10)

def validate(self):
# check the main correlator log for Errors
self.assertGrep('correlator.log', expr=' (ERROR|FATAL) ', contains=False)

# Check that the test didn't fail
self.assertGrep('TestResult.evt', expr='TestFailed', contains=False)

# Check that the interval listener was killed
self.assertLineCount('correlator.log', expr='Interval wait listener killed', condition='==1')

16 changes: 16 additions & 0 deletions test/tests/Operators/Sample/Sync/Input/test.mon
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using utils.Test;
using utils.ExpectValues;

using com.industry.rx_epl.Observable;
using com.industry.rx_epl.IObservable;
using com.industry.rx_epl.Subscriber;

monitor TestObservable {
Test test := Test("TestResult");

action onload() {
any discard := Observable.fromValues([<any>0,1,2,3])
.sample(Observable.interval(1.0))
.subscribe(ExpectValues.create([<any>3], test.complete, test.fail));
}
}
24 changes: 24 additions & 0 deletions test/tests/Operators/Sample/Sync/pysystest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" standalone="yes"?>
<pysystest type="auto" state="runnable">

<description>
<title>Sample Sync</title>
<purpose><![CDATA[Sample Sync]]></purpose>
</description>

<classification>
<groups>
<group></group>
</groups>
</classification>

<data>
<class name="PySysTest" module="run"/>
</data>

<traceability>
<requirements>
<requirement id=""/>
</requirements>
</traceability>
</pysystest>
54 changes: 54 additions & 0 deletions test/tests/Operators/Sample/Sync/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright (c) 2015-2018 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from pysys.constants import *
from pysys.basetest import BaseTest
from apama.correlator import CorrelatorHelper

class PySysTest(BaseTest):

def execute(self):
correlator = CorrelatorHelper(self, name='correlator')
correlator.start(logfile='correlator.log', config=os.path.join(PROJECT.TEST_SUBJECT_DIR, 'initialization.yaml'))

correlator.flush()
correlator.injectEPL(filenames='testUtils.mon', filedir=PROJECT.UTILS_DIR)

# Set the log level to DEBUG so that we can see when the listeners are killed
correlator.setApplicationLogLevel(verbosity='DEBUG')

# Start test results receiver
correlator.receive(filename='TestResult.evt', channels=['TestResult'], logChannels=True)

# Inject test
correlator.injectEPL(filenames=['test.mon'])

# wait for all events to be processed
correlator.flush()

# wait for test to complete
self.waitForSignal('TestResult.evt', expr="TestComplete", condition="==1", timeout=10)

def validate(self):
# check the main correlator log for Errors
self.assertGrep('correlator.log', expr=' (ERROR|FATAL) ', contains=False)

# Check that the test didn't fail
self.assertGrep('TestResult.evt', expr='TestFailed', contains=False)

# The listener should not be killed because it should not be created as the observable completes synchronously
self.assertLineCount('correlator.log', expr='Interval wait listener killed', condition='==0')

15 changes: 15 additions & 0 deletions test/tests/Operators/SampleCount/Async/Input/test.mon
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using utils.Test;
using utils.TestObservables;
using utils.ExpectValues;

using com.industry.rx_epl.Subscriber;

monitor TestObservable {
Test test := Test("TestResult");

action onload() {
any discard := TestObservables.createAsync().take(6)
.sampleCount(2)
.subscribe(ExpectValues.create([<any>1.0,3.0,5.0], test.complete, test.fail));
}
}
24 changes: 24 additions & 0 deletions test/tests/Operators/SampleCount/Async/pysystest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" standalone="yes"?>
<pysystest type="auto" state="runnable">

<description>
<title>SampleCount Async</title>
<purpose><![CDATA[SampleCount Async]]></purpose>
</description>

<classification>
<groups>
<group></group>
</groups>
</classification>

<data>
<class name="PySysTest" module="run"/>
</data>

<traceability>
<requirements>
<requirement id=""/>
</requirements>
</traceability>
</pysystest>
51 changes: 51 additions & 0 deletions test/tests/Operators/SampleCount/Async/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright (c) 2015-2018 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.
#
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from pysys.constants import *
from pysys.basetest import BaseTest
from apama.correlator import CorrelatorHelper

class PySysTest(BaseTest):

def execute(self):
correlator = CorrelatorHelper(self, name='correlator')
correlator.start(logfile='correlator.log', config=os.path.join(PROJECT.TEST_SUBJECT_DIR, 'initialization.yaml'))

correlator.flush()
correlator.injectEPL(filenames='testUtils.mon', filedir=PROJECT.UTILS_DIR)

# Set the log level to DEBUG so that we can see when the listeners are killed
correlator.setApplicationLogLevel(verbosity='DEBUG')

# Start test results receiver
correlator.receive(filename='TestResult.evt', channels=['TestResult'], logChannels=True)

# Inject test
correlator.injectEPL(filenames=['test.mon'])

# wait for all events to be processed
correlator.flush()

# wait for test to complete
self.waitForSignal('TestResult.evt', expr="TestComplete", condition="==1", timeout=10)

def validate(self):
# check the main correlator log for Errors
self.assertGrep('correlator.log', expr=' (ERROR|FATAL) ', contains=False)

# Check that the test didn't fail
self.assertGrep('TestResult.evt', expr='TestFailed', contains=False)

15 changes: 15 additions & 0 deletions test/tests/Operators/SampleCount/Sync/Input/test.mon
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using utils.Test;
using utils.TestObservables;
using utils.ExpectValues;

using com.industry.rx_epl.Subscriber;

monitor TestObservable {
Test test := Test("TestResult");

action onload() {
any discard := TestObservables.createSync().take(6)
.sampleCount(2)
.subscribe(ExpectValues.create([<any>1.0,3.0,5.0], test.complete, test.fail));
}
}
24 changes: 24 additions & 0 deletions test/tests/Operators/SampleCount/Sync/pysystest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" standalone="yes"?>
<pysystest type="auto" state="runnable">

<description>
<title>SampleCount Sync</title>
<purpose><![CDATA[SampleCount Sync]]></purpose>
</description>

<classification>
<groups>
<group></group>
</groups>
</classification>

<data>
<class name="PySysTest" module="run"/>
</data>

<traceability>
<requirements>
<requirement id=""/>
</requirements>
</traceability>
</pysystest>

0 comments on commit b642f88

Please sign in to comment.