[#762] add serviceType infomation for rule because select box component

need service type information.
This commit is contained in:
Minwoo Jung
2015-08-19 14:00:20 +09:00
parent 9261658629
commit 86f2aff584
21 changed files with 1156 additions and 1195 deletions
@@ -23,7 +23,8 @@ public class Rule {
private String ruleId;
private String applicationId;
private String CheckerName;
private String serviceType;
private String checkerName;
private Integer threshold;
private String userGroupId;
private boolean smsSend;
@@ -33,9 +34,10 @@ public class Rule {
public Rule() {
}
public Rule(String applicationId, String checkerName, Integer Threshold, String userGroupId, boolean smsSend, boolean emailSend, String notes) {
public Rule(String applicationId, String serviceType, String checkerName, Integer Threshold, String userGroupId, boolean smsSend, boolean emailSend, String notes) {
this.applicationId = applicationId;
this.CheckerName = checkerName;
this.serviceType = serviceType;
this.checkerName = checkerName;
this.threshold = Threshold;
this.userGroupId = userGroupId;
this.smsSend = smsSend;
@@ -51,12 +53,20 @@ public class Rule {
this.applicationId = applicationId;
}
public String getServiceType() {
return serviceType;
}
public void setServiceType(String serviceType) {
this.serviceType = serviceType;
}
public String getCheckerName() {
return CheckerName;
return checkerName;
}
public void setCheckerName(String checkerName) {
CheckerName = checkerName;
this.checkerName = checkerName;
}
public Integer getThreshold() {
@@ -1,70 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.navercorp.pinpoint.web.dao.AlarmResourceDao">
<!-- <select id="selectRules" resultType="rule" parameterType="String"> -->
<!-- SELECT * -->
<!-- FROM alarm_rule -->
<!-- WHERE application_id = #{applicationId} -->
<!-- </select> -->
<select id="selectEmpGroupPhoneNumber" resultType="String" parameterType="String">
SELECT sms
FROM user
WHERE id IN (
SELECT emp_id
FROM alarm_group
WHERE group_name = #{group_name}
)
</select>
<select id="selectEmpGroupEmail" resultType="String" parameterType="String">
SELECT email
FROM user
WHERE id IN (
SELECT emp_id
FROM alarm_group
WHERE group_name = #{group_name}
)
</select>
<!-- <insert id="insertAppRule" parameterType="java.util.List"> -->
<!-- INSERT INTO alarm_rule(application_id, checker_name, threshold, user_group_id, sms_send, email_send, notes) -->
<!-- VALUES -->
<!-- <foreach collection="list" item="rule" separator=","> -->
<!-- (#{rule.applicationId}, #{rule.checkerName}, #{rule.threshold}, #{rule.userGroupId}, #{rule.smsSend}, #{rule.emailSend}, #{rule.notes}) -->
<!-- </foreach> -->
<!-- </insert> -->
<!-- <delete id="deleteAppRule" parameterType="String"> -->
<!-- DELETE -->
<!-- FROM alarm_rule -->
<!-- WHERE application_id = #{applicationId} -->
<!-- </delete> -->
<!-- <select id="selectAlarmGroupList" resultType="String" parameterType="String"> -->
<!-- SELECT DISTINCT(group_name) -->
<!-- FROM alarm_group -->
<!-- </select> -->
<!-- <select id="selectAlarmGroupMember" resultType="alarmEmp" parameterType="String"> -->
<!-- SELECT * -->
<!-- FROM alarm_group -->
<!-- WHERE group_name = #{group_name} -->
<!-- </select> -->
<!-- <insert id="insertAlarmGroupMember" parameterType="java.util.List"> -->
<!-- INSERT INTO alarm_group(group_name, emp_id) -->
<!-- VALUES -->
<!-- <foreach collection="list" item="alarmEmp" separator=","> -->
<!-- (#{alarmEmp.groupName}, #{alarmEmp.empId}) -->
<!-- </foreach> -->
<!-- </insert> -->
<!-- <delete id="deleteAlarmGroupMember" parameterType="String"> -->
<!-- DELETE -->
<!-- FROM alarm_group -->
<!-- WHERE group_name = #{group_name} -->
<!-- </delete> -->
</mapper>
@@ -4,9 +4,9 @@
<mapper namespace="com.navercorp.pinpoint.web.dao.AlarmDao">
<insert id="insertRule" parameterType="Rule" useGeneratedKeys="true" keyProperty="ruleId">
INSERT INTO alarm_rule(application_id, checker_name, threshold, user_group_id, sms_send, email_send, notes)
INSERT INTO alarm_rule(application_id, service_type, checker_name, threshold, user_group_id, sms_send, email_send, notes)
VALUES
(#{applicationId}, #{checkerName}, #{threshold}, #{userGroupId}, #{smsSend}, #{emailSend}, #{notes})
(#{applicationId}, #{serviceType}, #{checkerName}, #{threshold}, #{userGroupId}, #{smsSend}, #{emailSend}, #{notes})
</insert>
<delete id="deleteRule" parameterType="Rule">
@@ -35,7 +35,7 @@
<update id="updateRule">
UPDATE alarm_rule
SET application_id = #{applicationId}, checker_name = #{checkerName}, threshold = #{threshold}, user_group_id = #{userGroupId}, sms_send = #{smsSend}, email_send = #{emailSend}, notes = #{notes}
SET application_id = #{applicationId}, service_type = #{serviceType}, checker_name = #{checkerName}, threshold = #{threshold}, user_group_id = #{userGroupId}, sms_send = #{smsSend}, email_send = #{emailSend}, notes = #{notes}
WHERE rule_id = #{ruleId}
</update>
</mapper>
@@ -28,12 +28,13 @@ CREATE TABLE `user` (
CREATE TABLE `alarm_rule` (
`rule_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`application_id` VARCHAR(30) NOT NULL,
`service_type` VARCHAR(30) NOT NULL,
`checker_name` VARCHAR(30) NOT NULL,
`threshold` INT(10) DEFAULT NULL,
`user_group_id` VARCHAR(30) NOT NULL,
`sms_send` CHAR(1) DEFAULT NULL,
`email_send` CHAR(1) DEFAULT NULL,
`notes` VARCHAR(50) DEFAULT NULL,
PRIMARY KEY (`rule_id`),
PRIMARY KEY (`rule_id`)
);
ALTER TABLE alarm_rule ADD UNIQUE KEY application_id_checker_name_user_group_id_idx (application_id, user_group_id, checker_name);
@@ -1,49 +1,49 @@
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import org.junit.Test;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.checker.SlowCountChecker;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
public class CheckerCategoryTest {
@Test
public void createCheckerTest() {
CheckerCategory slowCount = CheckerCategory.getValue("slow_count");
Rule rule = new Rule(null, CheckerCategory.SLOW_COUNT.getName(), 75, "testGroup", false, false, "");
SlowCountChecker checker = (SlowCountChecker) slowCount.createChecker(null, rule);
rule = new Rule(null, CheckerCategory.SLOW_COUNT.getName(), 63, "testGroup", false, false, "");
SlowCountChecker checker2 = (SlowCountChecker) slowCount.createChecker(null, rule);
assertNotSame(checker, checker2);
assertNotNull(checker);
assertEquals(75, (int)checker.getRule().getThreshold());
assertNotNull(checker2);
assertEquals(63, (int)checker2.getRule().getThreshold());
}
}
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import org.junit.Test;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.checker.SlowCountChecker;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
public class CheckerCategoryTest {
@Test
public void createCheckerTest() {
CheckerCategory slowCount = CheckerCategory.getValue("slow_count");
Rule rule = new Rule(null, "", CheckerCategory.SLOW_COUNT.getName(), 75, "testGroup", false, false, "");
SlowCountChecker checker = (SlowCountChecker) slowCount.createChecker(null, rule);
rule = new Rule(null, "", CheckerCategory.SLOW_COUNT.getName(), 63, "testGroup", false, false, "");
SlowCountChecker checker2 = (SlowCountChecker) slowCount.createChecker(null, rule);
assertNotSame(checker, checker2);
assertNotNull(checker);
assertEquals(75, (int)checker.getRule().getThreshold());
assertNotNull(checker2);
assertEquals(63, (int)checker2.getRule().getThreshold());
}
}
@@ -44,6 +44,7 @@ public class ReaderTest {
private static AlarmService alarmService;
private static DataCollectorFactory dataCollectorFactory;
private static final String APP_NAME = "app";
private static final String SERVICE_TYPE = "tomcat";
@Test
public void readTest() {
@@ -127,7 +128,7 @@ public class ReaderTest {
ruleMap = new HashMap<String, Rule>();
for(int i = 0; i <=6; i++) {
ruleMap.put(APP_NAME + i, new Rule(APP_NAME + i, CheckerCategory.SLOW_COUNT.getName(), 76, "testGroup", false, false, ""));
ruleMap.put(APP_NAME + i, new Rule(APP_NAME + i, SERVICE_TYPE, CheckerCategory.SLOW_COUNT.getName(), 76, "testGroup", false, false, ""));
}
}
@@ -1,84 +1,84 @@
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm;
import java.util.LinkedList;
import java.util.List;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.navercorp.pinpoint.web.alarm.AlarmWriter;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.checker.AlarmChecker;
import com.navercorp.pinpoint.web.alarm.checker.SlowCountChecker;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext-test.xml")
public class WriterTest {
@Autowired
AlarmWriter writer;
@Ignore
@Test
public void smsSendTest() throws Exception {
Rule rule = new Rule("testService", CheckerCategory.SLOW_COUNT.getName(), 100, "testGroup", true, false, "");
SlowCountChecker checker = new SlowCountChecker(null, rule) {
@Override
public boolean isDetected() {
return true;
}
@Override
protected long getDetectedValue() {
return 10000;
}
};
List<AlarmChecker> checkers = new LinkedList<AlarmChecker>();
checkers.add(checker);
writer.write(checkers);
}
@Ignore
@Test
public void emailSendTest() throws Exception {
Rule rule = new Rule("testService", CheckerCategory.SLOW_COUNT.getName(), 100, "testGroup", false, true, "");
SlowCountChecker checker = new SlowCountChecker(null, rule) {
@Override
public boolean isDetected() {
return true;
}
@Override
protected long getDetectedValue() {
return 10000;
}
};
List<AlarmChecker> checkers = new LinkedList<AlarmChecker>();
checkers.add(checker);
writer.write(checkers);
}
}
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm;
import java.util.LinkedList;
import java.util.List;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.navercorp.pinpoint.web.alarm.AlarmWriter;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.checker.AlarmChecker;
import com.navercorp.pinpoint.web.alarm.checker.SlowCountChecker;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext-test.xml")
public class WriterTest {
@Autowired
AlarmWriter writer;
@Ignore
@Test
public void smsSendTest() throws Exception {
Rule rule = new Rule("testService", "tomcat", CheckerCategory.SLOW_COUNT.getName(), 100, "testGroup", true, false, "");
SlowCountChecker checker = new SlowCountChecker(null, rule) {
@Override
public boolean isDetected() {
return true;
}
@Override
protected long getDetectedValue() {
return 10000;
}
};
List<AlarmChecker> checkers = new LinkedList<AlarmChecker>();
checkers.add(checker);
writer.write(checkers);
}
@Ignore
@Test
public void emailSendTest() throws Exception {
Rule rule = new Rule("testService", "tomcat", CheckerCategory.SLOW_COUNT.getName(), 100, "testGroup", false, true, "");
SlowCountChecker checker = new SlowCountChecker(null, rule) {
@Override
public boolean isDetected() {
return true;
}
@Override
protected long getDetectedValue() {
return 10000;
}
};
List<AlarmChecker> checkers = new LinkedList<AlarmChecker>();
checkers.add(checker);
writer.write(checkers);
}
}
@@ -1,104 +1,105 @@
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm.checker;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.LinkedList;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import com.navercorp.pinpoint.common.trace.ServiceType;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory;
import com.navercorp.pinpoint.web.alarm.checker.ErrorCountChecker;
import com.navercorp.pinpoint.web.alarm.collector.ResponseTimeDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram;
import com.navercorp.pinpoint.web.dao.MapResponseDao;
import com.navercorp.pinpoint.web.vo.Application;
import com.navercorp.pinpoint.web.vo.Range;
import com.navercorp.pinpoint.web.vo.ResponseTime;
public class ErrorCountCheckerTest {
private static final String SERVICE_NAME = "local_service";
private static MapResponseDao mockMapResponseDAO;
@BeforeClass
public static void before() {
mockMapResponseDAO = new MapResponseDao() {
@Override
public List<ResponseTime> selectResponseTime(Application application, Range range) {
List<ResponseTime> list = new LinkedList<ResponseTime>();
long timeStamp = 1409814914298L;
ResponseTime responseTime = new ResponseTime(SERVICE_NAME, ServiceType.STAND_ALONE, timeStamp);
list.add(responseTime);
TimeHistogram histogram = null;
for (int i=0 ; i < 5; i++) {
for (int j=0 ; j < 5; j++) {
histogram = new TimeHistogram(ServiceType.STAND_ALONE, timeStamp);
histogram.addCallCountByElapsedTime(1000);
histogram.addCallCountByElapsedTime(3000);
histogram.addCallCountByElapsedTime(-1);
histogram.addCallCountByElapsedTime(-1);
histogram.addCallCountByElapsedTime(-1);
responseTime.addResponseTime("agent_" + i + "_" + j, histogram);
}
timeStamp += 1;
}
return list;
}
};
}
/*
* alert conditions not satisfied
*/
@Test
public void checkTest1() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), 300000);
Rule rule = new Rule(SERVICE_NAME, CheckerCategory.ERROR_COUNT.getName(), 74, "testGroup", false, false, "");
ErrorCountChecker filter = new ErrorCountChecker(collector, rule);
filter.check();
assertTrue(filter.isDetected());
}
/*
* alert conditions not satisfied
*/
@Test
public void checkTest2() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), 300000);
Rule rule = new Rule(SERVICE_NAME, CheckerCategory.ERROR_COUNT.getName(), 76, "testGroup", false, false, "");
ErrorCountChecker filter = new ErrorCountChecker(collector, rule);
filter.check();
assertFalse(filter.isDetected());
}
}
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm.checker;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.LinkedList;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import com.navercorp.pinpoint.common.trace.ServiceType;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory;
import com.navercorp.pinpoint.web.alarm.checker.ErrorCountChecker;
import com.navercorp.pinpoint.web.alarm.collector.ResponseTimeDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram;
import com.navercorp.pinpoint.web.dao.MapResponseDao;
import com.navercorp.pinpoint.web.vo.Application;
import com.navercorp.pinpoint.web.vo.Range;
import com.navercorp.pinpoint.web.vo.ResponseTime;
public class ErrorCountCheckerTest {
private static final String SERVICE_NAME = "local_service";
private static final String SERVICE_TYPE = "tomcat";
private static MapResponseDao mockMapResponseDAO;
@BeforeClass
public static void before() {
mockMapResponseDAO = new MapResponseDao() {
@Override
public List<ResponseTime> selectResponseTime(Application application, Range range) {
List<ResponseTime> list = new LinkedList<ResponseTime>();
long timeStamp = 1409814914298L;
ResponseTime responseTime = new ResponseTime(SERVICE_NAME, ServiceType.STAND_ALONE, timeStamp);
list.add(responseTime);
TimeHistogram histogram = null;
for (int i=0 ; i < 5; i++) {
for (int j=0 ; j < 5; j++) {
histogram = new TimeHistogram(ServiceType.STAND_ALONE, timeStamp);
histogram.addCallCountByElapsedTime(1000);
histogram.addCallCountByElapsedTime(3000);
histogram.addCallCountByElapsedTime(-1);
histogram.addCallCountByElapsedTime(-1);
histogram.addCallCountByElapsedTime(-1);
responseTime.addResponseTime("agent_" + i + "_" + j, histogram);
}
timeStamp += 1;
}
return list;
}
};
}
/*
* alert conditions not satisfied
*/
@Test
public void checkTest1() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), 300000);
Rule rule = new Rule(SERVICE_NAME, SERVICE_TYPE, CheckerCategory.ERROR_COUNT.getName(), 74, "testGroup", false, false, "");
ErrorCountChecker filter = new ErrorCountChecker(collector, rule);
filter.check();
assertTrue(filter.isDetected());
}
/*
* alert conditions not satisfied
*/
@Test
public void checkTest2() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), 300000);
Rule rule = new Rule(SERVICE_NAME, SERVICE_TYPE, CheckerCategory.ERROR_COUNT.getName(), 76, "testGroup", false, false, "");
ErrorCountChecker filter = new ErrorCountChecker(collector, rule);
filter.check();
assertFalse(filter.isDetected());
}
}
@@ -43,6 +43,7 @@ public class ErrorCountToCalleCheckerTest {
private static final String FROM_SERVICE_NAME = "from_local_service";
private static final String TO_SERVICE_NAME = "to_local_service";
private static final String SERVICE_TYPE = "tomcat";
public static MapStatisticsCallerDao dao;
@BeforeClass
@@ -90,7 +91,7 @@ public class ErrorCountToCalleCheckerTest {
public void checkTest() {
Application application = new Application(FROM_SERVICE_NAME, ServiceType.STAND_ALONE);
MapStatisticsCallerDataCollector dataCollector = new MapStatisticsCallerDataCollector(DataCollectorCategory.CALLER_STAT, application, dao, System.currentTimeMillis(), 300000);
Rule rule = new Rule(FROM_SERVICE_NAME, CheckerCategory.ERROR_COUNT_TO_CALLEE.getName(), 5, "testGroup", false, false, TO_SERVICE_NAME + 1);
Rule rule = new Rule(FROM_SERVICE_NAME, SERVICE_TYPE, CheckerCategory.ERROR_COUNT_TO_CALLEE.getName(), 5, "testGroup", false, false, TO_SERVICE_NAME + 1);
ErrorCountToCalleeChecker checker = new ErrorCountToCalleeChecker(dataCollector, rule);
checker.check();
@@ -101,7 +102,7 @@ public class ErrorCountToCalleCheckerTest {
public void checkTest2() {
Application application = new Application(FROM_SERVICE_NAME, ServiceType.STAND_ALONE);
MapStatisticsCallerDataCollector dataCollector = new MapStatisticsCallerDataCollector(DataCollectorCategory.CALLER_STAT, application, dao, System.currentTimeMillis(), 300000);
Rule rule = new Rule(FROM_SERVICE_NAME, CheckerCategory.ERROR_COUNT_TO_CALLEE.getName(), 6, "testGroup", false, false, TO_SERVICE_NAME + 1);
Rule rule = new Rule(FROM_SERVICE_NAME, SERVICE_TYPE, CheckerCategory.ERROR_COUNT_TO_CALLEE.getName(), 6, "testGroup", false, false, TO_SERVICE_NAME + 1);
ErrorCountToCalleeChecker checker = new ErrorCountToCalleeChecker(dataCollector, rule);
checker.check();
@@ -112,7 +113,7 @@ public class ErrorCountToCalleCheckerTest {
public void checkTest3() {
Application application = new Application(FROM_SERVICE_NAME, ServiceType.STAND_ALONE);
MapStatisticsCallerDataCollector dataCollector = new MapStatisticsCallerDataCollector(DataCollectorCategory.CALLER_STAT, application, dao, System.currentTimeMillis(), 300000);
Rule rule = new Rule(FROM_SERVICE_NAME, CheckerCategory.ERROR_COUNT_TO_CALLEE.getName(), 5, "testGroup", false, false, TO_SERVICE_NAME + 2);
Rule rule = new Rule(FROM_SERVICE_NAME, SERVICE_TYPE, CheckerCategory.ERROR_COUNT_TO_CALLEE.getName(), 5, "testGroup", false, false, TO_SERVICE_NAME + 2);
ErrorCountToCalleeChecker checker = new ErrorCountToCalleeChecker(dataCollector, rule);
checker.check();
@@ -1,103 +1,104 @@
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm.checker;
import static org.junit.Assert.*;
import java.util.LinkedList;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import com.navercorp.pinpoint.common.trace.ServiceType;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory;
import com.navercorp.pinpoint.web.alarm.checker.ErrorRateChecker;
import com.navercorp.pinpoint.web.alarm.collector.ResponseTimeDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram;
import com.navercorp.pinpoint.web.dao.MapResponseDao;
import com.navercorp.pinpoint.web.vo.Application;
import com.navercorp.pinpoint.web.vo.Range;
import com.navercorp.pinpoint.web.vo.ResponseTime;
public class ErrorRateCheckerTest {
private static final String SERVICE_NAME = "local_service";
private static MapResponseDao mockMapResponseDAO;
@BeforeClass
public static void before() {
mockMapResponseDAO = new MapResponseDao() {
@Override
public List<ResponseTime> selectResponseTime(Application application, Range range) {
List<ResponseTime> list = new LinkedList<ResponseTime>();
long timeStamp = 1409814914298L;
ResponseTime responseTime = new ResponseTime(SERVICE_NAME, ServiceType.STAND_ALONE, timeStamp);
list.add(responseTime);
TimeHistogram histogram = null;
for (int i=0 ; i < 5; i++) {
for (int j=0 ; j < 5; j++) {
histogram = new TimeHistogram(ServiceType.STAND_ALONE, timeStamp);
histogram.addCallCountByElapsedTime(1000);
histogram.addCallCountByElapsedTime(3000);
histogram.addCallCountByElapsedTime(-1);
histogram.addCallCountByElapsedTime(-1);
histogram.addCallCountByElapsedTime(-1);
responseTime.addResponseTime("agent_" + i + "_" + j, histogram);
}
timeStamp += 1;
}
return list;
}
};
}
/*
* alert conditions not satisfied
*/
@Test
public void checkTest1() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), 300000);
Rule rule = new Rule(SERVICE_NAME, CheckerCategory.ERROR_RATE.getName(), 60, "testGroup", false, false, "");
ErrorRateChecker filter = new ErrorRateChecker(collector, rule);
filter.check();
assertTrue(filter.isDetected());
}
/*
* alert conditions not satisfied
*/
@Test
public void checkTest2() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), 300000);
Rule rule = new Rule(SERVICE_NAME, CheckerCategory.ERROR_RATE.getName(), 61, "testGroup", false, false, "");
ErrorRateChecker filter = new ErrorRateChecker(collector, rule);
filter.check();
assertFalse(filter.isDetected());
}
}
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm.checker;
import static org.junit.Assert.*;
import java.util.LinkedList;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import com.navercorp.pinpoint.common.trace.ServiceType;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory;
import com.navercorp.pinpoint.web.alarm.checker.ErrorRateChecker;
import com.navercorp.pinpoint.web.alarm.collector.ResponseTimeDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram;
import com.navercorp.pinpoint.web.dao.MapResponseDao;
import com.navercorp.pinpoint.web.vo.Application;
import com.navercorp.pinpoint.web.vo.Range;
import com.navercorp.pinpoint.web.vo.ResponseTime;
public class ErrorRateCheckerTest {
private static final String SERVICE_NAME = "local_service";
private static final String SERVICE_TYPE = "tomcat";
private static MapResponseDao mockMapResponseDAO;
@BeforeClass
public static void before() {
mockMapResponseDAO = new MapResponseDao() {
@Override
public List<ResponseTime> selectResponseTime(Application application, Range range) {
List<ResponseTime> list = new LinkedList<ResponseTime>();
long timeStamp = 1409814914298L;
ResponseTime responseTime = new ResponseTime(SERVICE_NAME, ServiceType.STAND_ALONE, timeStamp);
list.add(responseTime);
TimeHistogram histogram = null;
for (int i=0 ; i < 5; i++) {
for (int j=0 ; j < 5; j++) {
histogram = new TimeHistogram(ServiceType.STAND_ALONE, timeStamp);
histogram.addCallCountByElapsedTime(1000);
histogram.addCallCountByElapsedTime(3000);
histogram.addCallCountByElapsedTime(-1);
histogram.addCallCountByElapsedTime(-1);
histogram.addCallCountByElapsedTime(-1);
responseTime.addResponseTime("agent_" + i + "_" + j, histogram);
}
timeStamp += 1;
}
return list;
}
};
}
/*
* alert conditions not satisfied
*/
@Test
public void checkTest1() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), 300000);
Rule rule = new Rule(SERVICE_NAME, SERVICE_TYPE, CheckerCategory.ERROR_RATE.getName(), 60, "testGroup", false, false, "");
ErrorRateChecker filter = new ErrorRateChecker(collector, rule);
filter.check();
assertTrue(filter.isDetected());
}
/*
* alert conditions not satisfied
*/
@Test
public void checkTest2() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), 300000);
Rule rule = new Rule(SERVICE_NAME, SERVICE_TYPE, CheckerCategory.ERROR_RATE.getName(), 61, "testGroup", false, false, "");
ErrorRateChecker filter = new ErrorRateChecker(collector, rule);
filter.check();
assertFalse(filter.isDetected());
}
}
@@ -43,6 +43,8 @@ public class ErrorRateToCalleCheckerTest {
private static final String FROM_SERVICE_NAME = "from_local_service";
private static final String TO_SERVICE_NAME = "to_local_service";
private static final String SERVICE_TYPE = "tomcat";
public static MapStatisticsCallerDao dao;
@BeforeClass
@@ -90,7 +92,7 @@ public class ErrorRateToCalleCheckerTest {
public void checkTest() {
Application application = new Application(FROM_SERVICE_NAME, ServiceType.STAND_ALONE);
MapStatisticsCallerDataCollector dataCollector = new MapStatisticsCallerDataCollector(DataCollectorCategory.CALLER_STAT, application, dao, System.currentTimeMillis(), 300000);
Rule rule = new Rule(FROM_SERVICE_NAME, CheckerCategory.ERROR_RATE_TO_CALLEE.getName(), 50, "testGroup", false, false, TO_SERVICE_NAME + 1);
Rule rule = new Rule(FROM_SERVICE_NAME, SERVICE_TYPE, CheckerCategory.ERROR_RATE_TO_CALLEE.getName(), 50, "testGroup", false, false, TO_SERVICE_NAME + 1);
ErrorRateToCalleeChecker checker = new ErrorRateToCalleeChecker(dataCollector, rule);
checker.check();
@@ -101,7 +103,7 @@ public class ErrorRateToCalleCheckerTest {
public void checkTest2() {
Application application = new Application(FROM_SERVICE_NAME, ServiceType.STAND_ALONE);
MapStatisticsCallerDataCollector dataCollector = new MapStatisticsCallerDataCollector(DataCollectorCategory.CALLER_STAT, application, dao, System.currentTimeMillis(), 300000);
Rule rule = new Rule(FROM_SERVICE_NAME, CheckerCategory.ERROR_RATE_TO_CALLEE.getName(), 51, "testGroup", false, false, TO_SERVICE_NAME + 1);
Rule rule = new Rule(FROM_SERVICE_NAME, SERVICE_TYPE, CheckerCategory.ERROR_RATE_TO_CALLEE.getName(), 51, "testGroup", false, false, TO_SERVICE_NAME + 1);
ErrorRateToCalleeChecker checker = new ErrorRateToCalleeChecker(dataCollector, rule);
checker.check();
@@ -112,7 +114,7 @@ public class ErrorRateToCalleCheckerTest {
public void checkTest3() {
Application application = new Application(FROM_SERVICE_NAME, ServiceType.STAND_ALONE);
MapStatisticsCallerDataCollector dataCollector = new MapStatisticsCallerDataCollector(DataCollectorCategory.CALLER_STAT, application, dao, System.currentTimeMillis(), 300000);
Rule rule = new Rule(FROM_SERVICE_NAME, CheckerCategory.ERROR_RATE_TO_CALLEE.getName(), 50, "testGroup", false, false, TO_SERVICE_NAME + 2);
Rule rule = new Rule(FROM_SERVICE_NAME, SERVICE_TYPE, CheckerCategory.ERROR_RATE_TO_CALLEE.getName(), 50, "testGroup", false, false, TO_SERVICE_NAME + 2);
ErrorRateToCalleeChecker checker = new ErrorRateToCalleeChecker(dataCollector, rule);
checker.check();
@@ -1,132 +1,133 @@
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm.checker;
import static org.junit.Assert.*;
import java.util.LinkedList;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import com.navercorp.pinpoint.common.bo.AgentStatCpuLoadBo;
import com.navercorp.pinpoint.common.bo.AgentStatMemoryGcBo;
import com.navercorp.pinpoint.common.trace.ServiceType;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory;
import com.navercorp.pinpoint.web.alarm.checker.AgentChecker;
import com.navercorp.pinpoint.web.alarm.checker.GcCountChecker;
import com.navercorp.pinpoint.web.alarm.collector.AgentStatDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
import com.navercorp.pinpoint.web.dao.AgentStatDao;
import com.navercorp.pinpoint.web.dao.ApplicationIndexDao;
import com.navercorp.pinpoint.web.vo.AgentStat;
import com.navercorp.pinpoint.web.vo.Application;
import com.navercorp.pinpoint.web.vo.Range;
public class GcCountCheckerTest {
private static final String SERVICE_NAME = "local_service";
private static ApplicationIndexDao applicationIndexDao;
private static AgentStatDao agentStatDao;
@BeforeClass
public static void before() {
agentStatDao = new AgentStatDao() {
@Override
public List<AgentStat> scanAgentStatList(String agentId, Range range) {
List<AgentStat> AgentStatList = new LinkedList<AgentStat>();
for (int i = 36; i > 0; i--) {
AgentStatMemoryGcBo.Builder memoryBuilder = new AgentStatMemoryGcBo.Builder("AGETNT_NAME", 0L, 1L);
memoryBuilder.jvmGcOldCount(i);
AgentStatMemoryGcBo memoryBo = memoryBuilder.build();
AgentStatCpuLoadBo.Builder cpuBuilder = new AgentStatCpuLoadBo.Builder("AGETNT_NAME", 0L, 1L);
AgentStatCpuLoadBo cpuLoadBo = cpuBuilder.build();
AgentStat stat = new AgentStat();
stat.setMemoryGc(memoryBo);
stat.setCpuLoad(cpuLoadBo);
AgentStatList.add(stat);
}
return AgentStatList;
}
};
applicationIndexDao = new ApplicationIndexDao() {
@Override
public List<Application> selectAllApplicationNames() {
throw new UnsupportedOperationException();
}
@Override
public List<String> selectAgentIds(String applicationName) {
if (SERVICE_NAME.equals(applicationName)) {
List<String> agentIds = new LinkedList<String>();
agentIds.add("local_tomcat");
return agentIds;
}
throw new IllegalArgumentException();
}
@Override
public void deleteApplicationName(String applicationName) {
throw new UnsupportedOperationException();
}
@Override
public void deleteAgentId(String applicationName, String agentId) {
throw new UnsupportedOperationException();
}
};
}
@Test
public void checkTest1() {
Rule rule = new Rule(SERVICE_NAME, CheckerCategory.GC_COUNT.getName(), 35, "testGroup", false, false, "");
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
AgentStatDataCollector collector = new AgentStatDataCollector(DataCollectorCategory.AGENT_STAT, application, agentStatDao, applicationIndexDao, System.currentTimeMillis(), DataCollectorFactory.SLOT_INTERVAL_FIVE_MIN);
AgentChecker checker = new GcCountChecker(collector, rule);
checker.check();
assertTrue(checker.isDetected());
}
@Test
public void checkTest2() {
Rule rule = new Rule(SERVICE_NAME, CheckerCategory.GC_COUNT.getName(), 36, "testGroup", false, false, "");
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
AgentStatDataCollector collector = new AgentStatDataCollector(DataCollectorCategory.AGENT_STAT, application, agentStatDao, applicationIndexDao, System.currentTimeMillis(), DataCollectorFactory.SLOT_INTERVAL_FIVE_MIN);
AgentChecker checker = new GcCountChecker(collector, rule);
checker.check();
assertFalse(checker.isDetected());
}
}
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm.checker;
import static org.junit.Assert.*;
import java.util.LinkedList;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import com.navercorp.pinpoint.common.bo.AgentStatCpuLoadBo;
import com.navercorp.pinpoint.common.bo.AgentStatMemoryGcBo;
import com.navercorp.pinpoint.common.trace.ServiceType;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory;
import com.navercorp.pinpoint.web.alarm.checker.AgentChecker;
import com.navercorp.pinpoint.web.alarm.checker.GcCountChecker;
import com.navercorp.pinpoint.web.alarm.collector.AgentStatDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
import com.navercorp.pinpoint.web.dao.AgentStatDao;
import com.navercorp.pinpoint.web.dao.ApplicationIndexDao;
import com.navercorp.pinpoint.web.vo.AgentStat;
import com.navercorp.pinpoint.web.vo.Application;
import com.navercorp.pinpoint.web.vo.Range;
public class GcCountCheckerTest {
private static final String SERVICE_NAME = "local_service";
private static final String SERVICE_TYPE = "tomcat";
private static ApplicationIndexDao applicationIndexDao;
private static AgentStatDao agentStatDao;
@BeforeClass
public static void before() {
agentStatDao = new AgentStatDao() {
@Override
public List<AgentStat> scanAgentStatList(String agentId, Range range) {
List<AgentStat> AgentStatList = new LinkedList<AgentStat>();
for (int i = 36; i > 0; i--) {
AgentStatMemoryGcBo.Builder memoryBuilder = new AgentStatMemoryGcBo.Builder("AGETNT_NAME", 0L, 1L);
memoryBuilder.jvmGcOldCount(i);
AgentStatMemoryGcBo memoryBo = memoryBuilder.build();
AgentStatCpuLoadBo.Builder cpuBuilder = new AgentStatCpuLoadBo.Builder("AGETNT_NAME", 0L, 1L);
AgentStatCpuLoadBo cpuLoadBo = cpuBuilder.build();
AgentStat stat = new AgentStat();
stat.setMemoryGc(memoryBo);
stat.setCpuLoad(cpuLoadBo);
AgentStatList.add(stat);
}
return AgentStatList;
}
};
applicationIndexDao = new ApplicationIndexDao() {
@Override
public List<Application> selectAllApplicationNames() {
throw new UnsupportedOperationException();
}
@Override
public List<String> selectAgentIds(String applicationName) {
if (SERVICE_NAME.equals(applicationName)) {
List<String> agentIds = new LinkedList<String>();
agentIds.add("local_tomcat");
return agentIds;
}
throw new IllegalArgumentException();
}
@Override
public void deleteApplicationName(String applicationName) {
throw new UnsupportedOperationException();
}
@Override
public void deleteAgentId(String applicationName, String agentId) {
throw new UnsupportedOperationException();
}
};
}
@Test
public void checkTest1() {
Rule rule = new Rule(SERVICE_NAME, SERVICE_TYPE, CheckerCategory.GC_COUNT.getName(), 35, "testGroup", false, false, "");
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
AgentStatDataCollector collector = new AgentStatDataCollector(DataCollectorCategory.AGENT_STAT, application, agentStatDao, applicationIndexDao, System.currentTimeMillis(), DataCollectorFactory.SLOT_INTERVAL_FIVE_MIN);
AgentChecker checker = new GcCountChecker(collector, rule);
checker.check();
assertTrue(checker.isDetected());
}
@Test
public void checkTest2() {
Rule rule = new Rule(SERVICE_NAME, SERVICE_TYPE, CheckerCategory.GC_COUNT.getName(), 36, "testGroup", false, false, "");
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
AgentStatDataCollector collector = new AgentStatDataCollector(DataCollectorCategory.AGENT_STAT, application, agentStatDao, applicationIndexDao, System.currentTimeMillis(), DataCollectorFactory.SLOT_INTERVAL_FIVE_MIN);
AgentChecker checker = new GcCountChecker(collector, rule);
checker.check();
assertFalse(checker.isDetected());
}
}
@@ -1,151 +1,152 @@
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm.checker;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.LinkedList;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import com.navercorp.pinpoint.common.bo.AgentStatCpuLoadBo;
import com.navercorp.pinpoint.common.bo.AgentStatMemoryGcBo;
import com.navercorp.pinpoint.common.trace.ServiceType;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory;
import com.navercorp.pinpoint.web.alarm.checker.AgentChecker;
import com.navercorp.pinpoint.web.alarm.checker.HeapUsageRateChecker;
import com.navercorp.pinpoint.web.alarm.collector.AgentStatDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
import com.navercorp.pinpoint.web.dao.AgentStatDao;
import com.navercorp.pinpoint.web.dao.ApplicationIndexDao;
import com.navercorp.pinpoint.web.vo.AgentStat;
import com.navercorp.pinpoint.web.vo.Application;
import com.navercorp.pinpoint.web.vo.Range;
public class HeapUsageRateCheckerTest {
private static final String SERVICE_NAME = "local_service";
private static ApplicationIndexDao applicationIndexDao;
private static AgentStatDao agentStatDao;
@BeforeClass
public static void before() {
agentStatDao = new AgentStatDao() {
@Override
public List<AgentStat> scanAgentStatList(String agentId, Range range) {
List<AgentStat> AgentStatList = new LinkedList<AgentStat>();
for (int i = 0; i < 36; i++) {
AgentStatMemoryGcBo.Builder memoryBuilder = new AgentStatMemoryGcBo.Builder("AGETNT_NAME", 0L, 1L);
memoryBuilder.jvmMemoryHeapUsed(70L);
memoryBuilder.jvmMemoryHeapMax(100L);
AgentStatMemoryGcBo memoryBo = memoryBuilder.build();
AgentStatCpuLoadBo.Builder cpuBuilder = new AgentStatCpuLoadBo.Builder("AGETNT_NAME", 0L, 1L);
AgentStatCpuLoadBo cpuLoadBo = cpuBuilder.build();
AgentStat stat = new AgentStat();
stat.setMemoryGc(memoryBo);
stat.setCpuLoad(cpuLoadBo);
AgentStatList.add(stat);
}
return AgentStatList;
}
};
applicationIndexDao = new ApplicationIndexDao() {
@Override
public List<Application> selectAllApplicationNames() {
throw new UnsupportedOperationException();
}
@Override
public List<String> selectAgentIds(String applicationName) {
if (SERVICE_NAME.equals(applicationName)) {
List<String> agentIds = new LinkedList<String>();
agentIds.add("local_tomcat");
return agentIds;
}
throw new IllegalArgumentException();
}
@Override
public void deleteApplicationName(String applicationName) {
throw new UnsupportedOperationException();
}
@Override
public void deleteAgentId(String applicationName, String agentId) {
throw new UnsupportedOperationException();
}
};
}
@Test
public void checkTest1() {
Rule rule = new Rule(SERVICE_NAME, CheckerCategory.HEAP_USAGE_RATE.getName(), 70, "testGroup", false, false, "");
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
AgentStatDataCollector collector = new AgentStatDataCollector(DataCollectorCategory.AGENT_STAT, application, agentStatDao, applicationIndexDao, System.currentTimeMillis(), DataCollectorFactory.SLOT_INTERVAL_FIVE_MIN);
AgentChecker checker = new HeapUsageRateChecker(collector, rule);
checker.check();
assertTrue(checker.isDetected());
}
@Test
public void checkTest2() {
Rule rule = new Rule(SERVICE_NAME, CheckerCategory.HEAP_USAGE_RATE.getName(), 71, "testGroup", false, false, "");
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
AgentStatDataCollector collector = new AgentStatDataCollector(DataCollectorCategory.AGENT_STAT, application, agentStatDao, applicationIndexDao, System.currentTimeMillis(), DataCollectorFactory.SLOT_INTERVAL_FIVE_MIN);
AgentChecker checker = new HeapUsageRateChecker(collector, rule);
checker.check();
assertFalse(checker.isDetected());
}
// @Autowired
// private HbaseAgentStatDao hbaseAgentStatDao ;
// @Autowired
// private HbaseApplicationIndexDao applicationIndexDao;
// @Test
// public void checkTest1() {
// Rule rule = new Rule(SERVICE_NAME, CheckerCategory.HEAP_USAGE_RATE.getName(), 60, "testGroup", false, false);
// Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
// AgentStatDataCollector collector = new AgentStatDataCollector(DataCollectorCategory.AGENT_STAT, application, hbaseAgentStatDao, applicationIndexDao, System.currentTimeMillis(), (long)300000);
// AgentChecker checker = new HeapUsageRateChecker(collector, rule);
//
// checker.check();
// assertTrue(checker.isDetected());
// }
}
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm.checker;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.LinkedList;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import com.navercorp.pinpoint.common.bo.AgentStatCpuLoadBo;
import com.navercorp.pinpoint.common.bo.AgentStatMemoryGcBo;
import com.navercorp.pinpoint.common.trace.ServiceType;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory;
import com.navercorp.pinpoint.web.alarm.checker.AgentChecker;
import com.navercorp.pinpoint.web.alarm.checker.HeapUsageRateChecker;
import com.navercorp.pinpoint.web.alarm.collector.AgentStatDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
import com.navercorp.pinpoint.web.dao.AgentStatDao;
import com.navercorp.pinpoint.web.dao.ApplicationIndexDao;
import com.navercorp.pinpoint.web.vo.AgentStat;
import com.navercorp.pinpoint.web.vo.Application;
import com.navercorp.pinpoint.web.vo.Range;
public class HeapUsageRateCheckerTest {
private static final String SERVICE_NAME = "local_service";
private static final String SERVICE_TYPE = "tomcat";
private static ApplicationIndexDao applicationIndexDao;
private static AgentStatDao agentStatDao;
@BeforeClass
public static void before() {
agentStatDao = new AgentStatDao() {
@Override
public List<AgentStat> scanAgentStatList(String agentId, Range range) {
List<AgentStat> AgentStatList = new LinkedList<AgentStat>();
for (int i = 0; i < 36; i++) {
AgentStatMemoryGcBo.Builder memoryBuilder = new AgentStatMemoryGcBo.Builder("AGETNT_NAME", 0L, 1L);
memoryBuilder.jvmMemoryHeapUsed(70L);
memoryBuilder.jvmMemoryHeapMax(100L);
AgentStatMemoryGcBo memoryBo = memoryBuilder.build();
AgentStatCpuLoadBo.Builder cpuBuilder = new AgentStatCpuLoadBo.Builder("AGETNT_NAME", 0L, 1L);
AgentStatCpuLoadBo cpuLoadBo = cpuBuilder.build();
AgentStat stat = new AgentStat();
stat.setMemoryGc(memoryBo);
stat.setCpuLoad(cpuLoadBo);
AgentStatList.add(stat);
}
return AgentStatList;
}
};
applicationIndexDao = new ApplicationIndexDao() {
@Override
public List<Application> selectAllApplicationNames() {
throw new UnsupportedOperationException();
}
@Override
public List<String> selectAgentIds(String applicationName) {
if (SERVICE_NAME.equals(applicationName)) {
List<String> agentIds = new LinkedList<String>();
agentIds.add("local_tomcat");
return agentIds;
}
throw new IllegalArgumentException();
}
@Override
public void deleteApplicationName(String applicationName) {
throw new UnsupportedOperationException();
}
@Override
public void deleteAgentId(String applicationName, String agentId) {
throw new UnsupportedOperationException();
}
};
}
@Test
public void checkTest1() {
Rule rule = new Rule(SERVICE_NAME, SERVICE_TYPE, CheckerCategory.HEAP_USAGE_RATE.getName(), 70, "testGroup", false, false, "");
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
AgentStatDataCollector collector = new AgentStatDataCollector(DataCollectorCategory.AGENT_STAT, application, agentStatDao, applicationIndexDao, System.currentTimeMillis(), DataCollectorFactory.SLOT_INTERVAL_FIVE_MIN);
AgentChecker checker = new HeapUsageRateChecker(collector, rule);
checker.check();
assertTrue(checker.isDetected());
}
@Test
public void checkTest2() {
Rule rule = new Rule(SERVICE_NAME, SERVICE_TYPE, CheckerCategory.HEAP_USAGE_RATE.getName(), 71, "testGroup", false, false, "");
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
AgentStatDataCollector collector = new AgentStatDataCollector(DataCollectorCategory.AGENT_STAT, application, agentStatDao, applicationIndexDao, System.currentTimeMillis(), DataCollectorFactory.SLOT_INTERVAL_FIVE_MIN);
AgentChecker checker = new HeapUsageRateChecker(collector, rule);
checker.check();
assertFalse(checker.isDetected());
}
// @Autowired
// private HbaseAgentStatDao hbaseAgentStatDao ;
// @Autowired
// private HbaseApplicationIndexDao applicationIndexDao;
// @Test
// public void checkTest1() {
// Rule rule = new Rule(SERVICE_NAME, CheckerCategory.HEAP_USAGE_RATE.getName(), 60, "testGroup", false, false);
// Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
// AgentStatDataCollector collector = new AgentStatDataCollector(DataCollectorCategory.AGENT_STAT, application, hbaseAgentStatDao, applicationIndexDao, System.currentTimeMillis(), (long)300000);
// AgentChecker checker = new HeapUsageRateChecker(collector, rule);
//
// checker.check();
// assertTrue(checker.isDetected());
// }
}
@@ -1,132 +1,133 @@
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm.checker;
import static org.junit.Assert.*;
import java.util.LinkedList;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import com.navercorp.pinpoint.common.bo.AgentStatCpuLoadBo;
import com.navercorp.pinpoint.common.bo.AgentStatMemoryGcBo;
import com.navercorp.pinpoint.common.trace.ServiceType;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory;
import com.navercorp.pinpoint.web.alarm.checker.AgentChecker;
import com.navercorp.pinpoint.web.alarm.checker.JvmCpuUsageRateChecker;
import com.navercorp.pinpoint.web.alarm.collector.AgentStatDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
import com.navercorp.pinpoint.web.dao.AgentStatDao;
import com.navercorp.pinpoint.web.dao.ApplicationIndexDao;
import com.navercorp.pinpoint.web.vo.AgentStat;
import com.navercorp.pinpoint.web.vo.Application;
import com.navercorp.pinpoint.web.vo.Range;
public class JvmCpuUsageRateCheckerTest {
private static final String SERVICE_NAME = "local_service";
private static ApplicationIndexDao applicationIndexDao;
private static AgentStatDao agentStatDao;
@BeforeClass
public static void before() {
agentStatDao = new AgentStatDao() {
@Override
public List<AgentStat> scanAgentStatList(String agentId, Range range) {
List<AgentStat> AgentStatList = new LinkedList<AgentStat>();
for (int i = 0; i < 36; i++) {
AgentStatCpuLoadBo.Builder cpuLoadBoBuilder = new AgentStatCpuLoadBo.Builder("AGETNT_NAME", 0L, 1L);
cpuLoadBoBuilder.jvmCpuLoad(0.6);
AgentStatCpuLoadBo cpuLoadBo = cpuLoadBoBuilder.build();
AgentStatMemoryGcBo.Builder memoryGcBobuilder = new AgentStatMemoryGcBo.Builder("AGETNT_NAME", 0L, 1L);
AgentStatMemoryGcBo memoryGcBo = memoryGcBobuilder.build();
AgentStat stat = new AgentStat();
stat.setCpuLoad(cpuLoadBo);
stat.setMemoryGc(memoryGcBo);
AgentStatList.add(stat);
}
return AgentStatList;
}
};
applicationIndexDao = new ApplicationIndexDao() {
@Override
public List<Application> selectAllApplicationNames() {
throw new UnsupportedOperationException();
}
@Override
public List<String> selectAgentIds(String applicationName) {
if (SERVICE_NAME.equals(applicationName)) {
List<String> agentIds = new LinkedList<String>();
agentIds.add("local_tomcat");
return agentIds;
}
throw new IllegalArgumentException();
}
@Override
public void deleteApplicationName(String applicationName) {
throw new UnsupportedOperationException();
}
@Override
public void deleteAgentId(String applicationName, String agentId) {
throw new UnsupportedOperationException();
}
};
}
@Test
public void checkTest1() {
Rule rule = new Rule(SERVICE_NAME, CheckerCategory.JVM_CPU_USAGE_RATE.getName(), 60, "testGroup", false, false, "");
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
AgentStatDataCollector collector = new AgentStatDataCollector(DataCollectorCategory.AGENT_STAT, application, agentStatDao, applicationIndexDao, System.currentTimeMillis(), DataCollectorFactory.SLOT_INTERVAL_FIVE_MIN);
AgentChecker checker = new JvmCpuUsageRateChecker(collector, rule);
checker.check();
assertTrue(checker.isDetected());
}
@Test
public void checkTest2() {
Rule rule = new Rule(SERVICE_NAME, CheckerCategory.JVM_CPU_USAGE_RATE.getName(), 61, "testGroup", false, false, "");
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
AgentStatDataCollector collector = new AgentStatDataCollector(DataCollectorCategory.AGENT_STAT, application, agentStatDao, applicationIndexDao, System.currentTimeMillis(), DataCollectorFactory.SLOT_INTERVAL_FIVE_MIN);
AgentChecker checker = new JvmCpuUsageRateChecker(collector, rule);
checker.check();
assertFalse(checker.isDetected());
}
}
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm.checker;
import static org.junit.Assert.*;
import java.util.LinkedList;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import com.navercorp.pinpoint.common.bo.AgentStatCpuLoadBo;
import com.navercorp.pinpoint.common.bo.AgentStatMemoryGcBo;
import com.navercorp.pinpoint.common.trace.ServiceType;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory;
import com.navercorp.pinpoint.web.alarm.checker.AgentChecker;
import com.navercorp.pinpoint.web.alarm.checker.JvmCpuUsageRateChecker;
import com.navercorp.pinpoint.web.alarm.collector.AgentStatDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
import com.navercorp.pinpoint.web.dao.AgentStatDao;
import com.navercorp.pinpoint.web.dao.ApplicationIndexDao;
import com.navercorp.pinpoint.web.vo.AgentStat;
import com.navercorp.pinpoint.web.vo.Application;
import com.navercorp.pinpoint.web.vo.Range;
public class JvmCpuUsageRateCheckerTest {
private static final String SERVICE_NAME = "local_service";
private static final String SERVICE_TYPE = "tomcat";
private static ApplicationIndexDao applicationIndexDao;
private static AgentStatDao agentStatDao;
@BeforeClass
public static void before() {
agentStatDao = new AgentStatDao() {
@Override
public List<AgentStat> scanAgentStatList(String agentId, Range range) {
List<AgentStat> AgentStatList = new LinkedList<AgentStat>();
for (int i = 0; i < 36; i++) {
AgentStatCpuLoadBo.Builder cpuLoadBoBuilder = new AgentStatCpuLoadBo.Builder("AGETNT_NAME", 0L, 1L);
cpuLoadBoBuilder.jvmCpuLoad(0.6);
AgentStatCpuLoadBo cpuLoadBo = cpuLoadBoBuilder.build();
AgentStatMemoryGcBo.Builder memoryGcBobuilder = new AgentStatMemoryGcBo.Builder("AGETNT_NAME", 0L, 1L);
AgentStatMemoryGcBo memoryGcBo = memoryGcBobuilder.build();
AgentStat stat = new AgentStat();
stat.setCpuLoad(cpuLoadBo);
stat.setMemoryGc(memoryGcBo);
AgentStatList.add(stat);
}
return AgentStatList;
}
};
applicationIndexDao = new ApplicationIndexDao() {
@Override
public List<Application> selectAllApplicationNames() {
throw new UnsupportedOperationException();
}
@Override
public List<String> selectAgentIds(String applicationName) {
if (SERVICE_NAME.equals(applicationName)) {
List<String> agentIds = new LinkedList<String>();
agentIds.add("local_tomcat");
return agentIds;
}
throw new IllegalArgumentException();
}
@Override
public void deleteApplicationName(String applicationName) {
throw new UnsupportedOperationException();
}
@Override
public void deleteAgentId(String applicationName, String agentId) {
throw new UnsupportedOperationException();
}
};
}
@Test
public void checkTest1() {
Rule rule = new Rule(SERVICE_NAME, SERVICE_TYPE, CheckerCategory.JVM_CPU_USAGE_RATE.getName(), 60, "testGroup", false, false, "");
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
AgentStatDataCollector collector = new AgentStatDataCollector(DataCollectorCategory.AGENT_STAT, application, agentStatDao, applicationIndexDao, System.currentTimeMillis(), DataCollectorFactory.SLOT_INTERVAL_FIVE_MIN);
AgentChecker checker = new JvmCpuUsageRateChecker(collector, rule);
checker.check();
assertTrue(checker.isDetected());
}
@Test
public void checkTest2() {
Rule rule = new Rule(SERVICE_NAME, SERVICE_TYPE, CheckerCategory.JVM_CPU_USAGE_RATE.getName(), 61, "testGroup", false, false, "");
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
AgentStatDataCollector collector = new AgentStatDataCollector(DataCollectorCategory.AGENT_STAT, application, agentStatDao, applicationIndexDao, System.currentTimeMillis(), DataCollectorFactory.SLOT_INTERVAL_FIVE_MIN);
AgentChecker checker = new JvmCpuUsageRateChecker(collector, rule);
checker.check();
assertFalse(checker.isDetected());
}
}
@@ -1,105 +1,106 @@
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm.checker;
import static org.junit.Assert.*;
import java.util.LinkedList;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import com.navercorp.pinpoint.common.trace.ServiceType;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory;
import com.navercorp.pinpoint.web.alarm.checker.ResponseCountChecker;
import com.navercorp.pinpoint.web.alarm.collector.ResponseTimeDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram;
import com.navercorp.pinpoint.web.dao.MapResponseDao;
import com.navercorp.pinpoint.web.vo.Application;
import com.navercorp.pinpoint.web.vo.Range;
import com.navercorp.pinpoint.web.vo.ResponseTime;
public class ResponseCountCheckerTest {
private static final String SERVICE_NAME = "local_service";
private static MapResponseDao mockMapResponseDAO;
@BeforeClass
public static void before() {
mockMapResponseDAO = new MapResponseDao() {
@Override
public List<ResponseTime> selectResponseTime(Application application, Range range) {
List<ResponseTime> list = new LinkedList<ResponseTime>();
long timeStamp = 1409814914298L;
ResponseTime responseTime = new ResponseTime(SERVICE_NAME, ServiceType.STAND_ALONE, timeStamp);
list.add(responseTime);
TimeHistogram histogram = null;
for (int i=0 ; i < 5; i++) {
for (int j=0 ; j < 5; j++) {
histogram = new TimeHistogram(ServiceType.STAND_ALONE, timeStamp);
histogram.addCallCountByElapsedTime(1000);
histogram.addCallCountByElapsedTime(3000);
histogram.addCallCountByElapsedTime(-1);
histogram.addCallCountByElapsedTime(-1);
histogram.addCallCountByElapsedTime(-1);
responseTime.addResponseTime("agent_" + i + "_" + j, histogram);
}
timeStamp += 1;
}
return list;
}
};
}
/*
* alert conditions not satisfied
*/
@Test
public void checkTest1() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), DataCollectorFactory.SLOT_INTERVAL_FIVE_MIN);
Rule rule = new Rule(SERVICE_NAME, CheckerCategory.RESPONSE_COUNT.getName(), 125, "testGroup", false, false, "");
ResponseCountChecker filter = new ResponseCountChecker(collector, rule);
filter.check();
assertTrue(filter.isDetected());
}
/*
* alert conditions not satisfied
*/
@Test
public void checkTest2() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), 300000);
Rule rule = new Rule(SERVICE_NAME, CheckerCategory.RESPONSE_COUNT.getName(), 126, "testGroup", false, false, "");
ResponseCountChecker filter = new ResponseCountChecker(collector, rule);
filter.check();
assertFalse(filter.isDetected());
}
}
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm.checker;
import static org.junit.Assert.*;
import java.util.LinkedList;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import com.navercorp.pinpoint.common.trace.ServiceType;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory;
import com.navercorp.pinpoint.web.alarm.checker.ResponseCountChecker;
import com.navercorp.pinpoint.web.alarm.collector.ResponseTimeDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram;
import com.navercorp.pinpoint.web.dao.MapResponseDao;
import com.navercorp.pinpoint.web.vo.Application;
import com.navercorp.pinpoint.web.vo.Range;
import com.navercorp.pinpoint.web.vo.ResponseTime;
public class ResponseCountCheckerTest {
private static final String SERVICE_NAME = "local_service";
private static final String SERVICE_TYPE = "tomcat";
private static MapResponseDao mockMapResponseDAO;
@BeforeClass
public static void before() {
mockMapResponseDAO = new MapResponseDao() {
@Override
public List<ResponseTime> selectResponseTime(Application application, Range range) {
List<ResponseTime> list = new LinkedList<ResponseTime>();
long timeStamp = 1409814914298L;
ResponseTime responseTime = new ResponseTime(SERVICE_NAME, ServiceType.STAND_ALONE, timeStamp);
list.add(responseTime);
TimeHistogram histogram = null;
for (int i=0 ; i < 5; i++) {
for (int j=0 ; j < 5; j++) {
histogram = new TimeHistogram(ServiceType.STAND_ALONE, timeStamp);
histogram.addCallCountByElapsedTime(1000);
histogram.addCallCountByElapsedTime(3000);
histogram.addCallCountByElapsedTime(-1);
histogram.addCallCountByElapsedTime(-1);
histogram.addCallCountByElapsedTime(-1);
responseTime.addResponseTime("agent_" + i + "_" + j, histogram);
}
timeStamp += 1;
}
return list;
}
};
}
/*
* alert conditions not satisfied
*/
@Test
public void checkTest1() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), DataCollectorFactory.SLOT_INTERVAL_FIVE_MIN);
Rule rule = new Rule(SERVICE_NAME, SERVICE_TYPE, CheckerCategory.RESPONSE_COUNT.getName(), 125, "testGroup", false, false, "");
ResponseCountChecker filter = new ResponseCountChecker(collector, rule);
filter.check();
assertTrue(filter.isDetected());
}
/*
* alert conditions not satisfied
*/
@Test
public void checkTest2() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), 300000);
Rule rule = new Rule(SERVICE_NAME, SERVICE_TYPE, CheckerCategory.RESPONSE_COUNT.getName(), 126, "testGroup", false, false, "");
ResponseCountChecker filter = new ResponseCountChecker(collector, rule);
filter.check();
assertFalse(filter.isDetected());
}
}
@@ -1,127 +1,128 @@
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm.checker;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.LinkedList;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import com.navercorp.pinpoint.common.trace.ServiceType;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory;
import com.navercorp.pinpoint.web.alarm.checker.SlowCountChecker;
import com.navercorp.pinpoint.web.alarm.collector.ResponseTimeDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram;
import com.navercorp.pinpoint.web.dao.MapResponseDao;
import com.navercorp.pinpoint.web.vo.Application;
import com.navercorp.pinpoint.web.vo.Range;
import com.navercorp.pinpoint.web.vo.ResponseTime;
public class SlowCountCheckerTest {
private static final String SERVICE_NAME = "local_service";
private static MapResponseDao mockMapResponseDAO;
@BeforeClass
public static void before() {
mockMapResponseDAO = new MapResponseDao() {
@Override
public List<ResponseTime> selectResponseTime(Application application, Range range) {
List<ResponseTime> list = new LinkedList<ResponseTime>();
long timeStamp = 1409814914298L;
ResponseTime responseTime = new ResponseTime(SERVICE_NAME, ServiceType.STAND_ALONE, timeStamp);
list.add(responseTime);
TimeHistogram histogram = null;
for (int i=0 ; i < 5; i++) {
for (int j=0 ; j < 5; j++) {
histogram = new TimeHistogram(ServiceType.STAND_ALONE, timeStamp);
histogram.addCallCountByElapsedTime(1000);
histogram.addCallCountByElapsedTime(3000);
histogram.addCallCountByElapsedTime(5000);
histogram.addCallCountByElapsedTime(6000);
histogram.addCallCountByElapsedTime(7000);
responseTime.addResponseTime("agent_" + i + "_" + j, histogram);
}
timeStamp += 1;
}
return list;
}
};
}
/*
* alert conditions not satisfied
*/
@Test
public void checkTest1() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), 300000);
Rule rule = new Rule(SERVICE_NAME, CheckerCategory.SLOW_COUNT.getName(), 74, "testGroup", false, false, "");
SlowCountChecker checker = new SlowCountChecker(collector, rule);
checker.check();
assertTrue(checker.isDetected());
}
/*
* alert conditions not satisfied
*/
@Test
public void checkTest2() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), 300000);
Rule rule = new Rule(SERVICE_NAME, CheckerCategory.SLOW_COUNT.getName(), 76, "testGroup", false, false, "");
SlowCountChecker checker = new SlowCountChecker(collector, rule);
checker.check();
assertFalse(checker.isDetected());
}
/*
the test data fetched directly from Hbase server.
use this in case of need because the data is not kept usually.
*/
/*
@Autowired
private HbaseMapResponseTimeDao hbaseMapResponseTimeDao;
@Test
public void checkTest1() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
SlowCountFilter filter = new SlowCountFilter(application);
AlarmRuleResource rule = new AlarmRuleResource();
rule.setThresholdRule(10);
rule.setContinuousTime(36000000);
filter.initialize(rule);
DefaultAlarmEvent event = new DefaultAlarmEvent(System.currentTimeMillis(), hbaseMapResponseTimeDao);
assertTrue(filter.check(event));
}
*/
}
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm.checker;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.LinkedList;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import com.navercorp.pinpoint.common.trace.ServiceType;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory;
import com.navercorp.pinpoint.web.alarm.checker.SlowCountChecker;
import com.navercorp.pinpoint.web.alarm.collector.ResponseTimeDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram;
import com.navercorp.pinpoint.web.dao.MapResponseDao;
import com.navercorp.pinpoint.web.vo.Application;
import com.navercorp.pinpoint.web.vo.Range;
import com.navercorp.pinpoint.web.vo.ResponseTime;
public class SlowCountCheckerTest {
private static final String SERVICE_NAME = "local_service";
private static final String SERVICE_TYPE = "tomcat";
private static MapResponseDao mockMapResponseDAO;
@BeforeClass
public static void before() {
mockMapResponseDAO = new MapResponseDao() {
@Override
public List<ResponseTime> selectResponseTime(Application application, Range range) {
List<ResponseTime> list = new LinkedList<ResponseTime>();
long timeStamp = 1409814914298L;
ResponseTime responseTime = new ResponseTime(SERVICE_NAME, ServiceType.STAND_ALONE, timeStamp);
list.add(responseTime);
TimeHistogram histogram = null;
for (int i=0 ; i < 5; i++) {
for (int j=0 ; j < 5; j++) {
histogram = new TimeHistogram(ServiceType.STAND_ALONE, timeStamp);
histogram.addCallCountByElapsedTime(1000);
histogram.addCallCountByElapsedTime(3000);
histogram.addCallCountByElapsedTime(5000);
histogram.addCallCountByElapsedTime(6000);
histogram.addCallCountByElapsedTime(7000);
responseTime.addResponseTime("agent_" + i + "_" + j, histogram);
}
timeStamp += 1;
}
return list;
}
};
}
/*
* alert conditions not satisfied
*/
@Test
public void checkTest1() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), 300000);
Rule rule = new Rule(SERVICE_NAME, SERVICE_TYPE, CheckerCategory.SLOW_COUNT.getName(), 74, "testGroup", false, false, "");
SlowCountChecker checker = new SlowCountChecker(collector, rule);
checker.check();
assertTrue(checker.isDetected());
}
/*
* alert conditions not satisfied
*/
@Test
public void checkTest2() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), 300000);
Rule rule = new Rule(SERVICE_NAME, SERVICE_TYPE, CheckerCategory.SLOW_COUNT.getName(), 76, "testGroup", false, false, "");
SlowCountChecker checker = new SlowCountChecker(collector, rule);
checker.check();
assertFalse(checker.isDetected());
}
/*
the test data fetched directly from Hbase server.
use this in case of need because the data is not kept usually.
*/
/*
@Autowired
private HbaseMapResponseTimeDao hbaseMapResponseTimeDao;
@Test
public void checkTest1() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
SlowCountFilter filter = new SlowCountFilter(application);
AlarmRuleResource rule = new AlarmRuleResource();
rule.setThresholdRule(10);
rule.setContinuousTime(36000000);
filter.initialize(rule);
DefaultAlarmEvent event = new DefaultAlarmEvent(System.currentTimeMillis(), hbaseMapResponseTimeDao);
assertTrue(filter.check(event));
}
*/
}
@@ -43,6 +43,7 @@ public class SlowCountToCalleCheckerTest {
private static final String FROM_SERVICE_NAME = "from_local_service";
private static final String TO_SERVICE_NAME = "to_local_service";
private static final String SERVICE_TYPE = "tomcat";
public static MapStatisticsCallerDao dao;
@BeforeClass
@@ -84,7 +85,7 @@ public class SlowCountToCalleCheckerTest {
public void checkTest() {
Application application = new Application(FROM_SERVICE_NAME, ServiceType.STAND_ALONE);
MapStatisticsCallerDataCollector dataCollector = new MapStatisticsCallerDataCollector(DataCollectorCategory.CALLER_STAT, application, dao, System.currentTimeMillis(), 300000);
Rule rule = new Rule(FROM_SERVICE_NAME, CheckerCategory.SLOW_COUNT_TO_CALLEE.getName(), 7, "testGroup", false, false, TO_SERVICE_NAME + 1);
Rule rule = new Rule(FROM_SERVICE_NAME, SERVICE_TYPE, CheckerCategory.SLOW_COUNT_TO_CALLEE.getName(), 7, "testGroup", false, false, TO_SERVICE_NAME + 1);
SlowCountToCalleeChecker checker = new SlowCountToCalleeChecker(dataCollector, rule);
checker.check();
@@ -95,7 +96,7 @@ public class SlowCountToCalleCheckerTest {
public void checkTest2() {
Application application = new Application(FROM_SERVICE_NAME, ServiceType.STAND_ALONE);
MapStatisticsCallerDataCollector dataCollector = new MapStatisticsCallerDataCollector(DataCollectorCategory.CALLER_STAT, application, dao, System.currentTimeMillis(), 300000);
Rule rule = new Rule(FROM_SERVICE_NAME, CheckerCategory.SLOW_COUNT_TO_CALLEE.getName(), 8, "testGroup", false, false, TO_SERVICE_NAME + 1);
Rule rule = new Rule(FROM_SERVICE_NAME, SERVICE_TYPE, CheckerCategory.SLOW_COUNT_TO_CALLEE.getName(), 8, "testGroup", false, false, TO_SERVICE_NAME + 1);
SlowCountToCalleeChecker checker = new SlowCountToCalleeChecker(dataCollector, rule);
checker.check();
@@ -106,7 +107,7 @@ public class SlowCountToCalleCheckerTest {
public void checkTest3() {
Application application = new Application(FROM_SERVICE_NAME, ServiceType.STAND_ALONE);
MapStatisticsCallerDataCollector dataCollector = new MapStatisticsCallerDataCollector(DataCollectorCategory.CALLER_STAT, application, dao, System.currentTimeMillis(), 300000);
Rule rule = new Rule(FROM_SERVICE_NAME, CheckerCategory.SLOW_COUNT_TO_CALLEE.getName(), 9, "testGroup", false, false, TO_SERVICE_NAME + 2);
Rule rule = new Rule(FROM_SERVICE_NAME, SERVICE_TYPE, CheckerCategory.SLOW_COUNT_TO_CALLEE.getName(), 9, "testGroup", false, false, TO_SERVICE_NAME + 2);
SlowCountToCalleeChecker checker = new SlowCountToCalleeChecker(dataCollector, rule);
checker.check();
@@ -1,105 +1,106 @@
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm.checker;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.LinkedList;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import com.navercorp.pinpoint.common.trace.ServiceType;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory;
import com.navercorp.pinpoint.web.alarm.checker.SlowRateChecker;
import com.navercorp.pinpoint.web.alarm.collector.ResponseTimeDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram;
import com.navercorp.pinpoint.web.dao.MapResponseDao;
import com.navercorp.pinpoint.web.vo.Application;
import com.navercorp.pinpoint.web.vo.Range;
import com.navercorp.pinpoint.web.vo.ResponseTime;
public class SlowRateCheckerTest {
private static final String SERVICE_NAME = "local_service";
private static MapResponseDao mockMapResponseDAO;
@BeforeClass
public static void before() {
mockMapResponseDAO = new MapResponseDao() {
@Override
public List<ResponseTime> selectResponseTime(Application application, Range range) {
List<ResponseTime> list = new LinkedList<ResponseTime>();
long timeStamp = 1409814914298L;
ResponseTime responseTime = new ResponseTime(SERVICE_NAME, ServiceType.STAND_ALONE, timeStamp);
list.add(responseTime);
TimeHistogram histogram = null;
for (int i=0 ; i < 5; i++) {
for (int j=0 ; j < 5; j++) {
histogram = new TimeHistogram(ServiceType.STAND_ALONE, timeStamp);
histogram.addCallCountByElapsedTime(1000);
histogram.addCallCountByElapsedTime(3000);
histogram.addCallCountByElapsedTime(5000);
histogram.addCallCountByElapsedTime(6000);
histogram.addCallCountByElapsedTime(7000);
responseTime.addResponseTime("agent_" + i + "_" + j, histogram);
}
timeStamp += 1;
}
return list;
}
};
}
/*
* not satisfied with alert condition
*/
@Test
public void checkTest1() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), 300000);
Rule rule = new Rule(SERVICE_NAME, CheckerCategory.SLOW_RATE.getName(), 60, "testGroup", false, false, "");
SlowRateChecker filter = new SlowRateChecker(collector, rule);
filter.check();
assertTrue(filter.isDetected());
}
/*
* not satisfied with alert condition
*/
@Test
public void checkTest2() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), 300000);
Rule rule = new Rule(SERVICE_NAME, CheckerCategory.SLOW_RATE.getName(), 61, "testGroup", false, false, "");
SlowRateChecker filter = new SlowRateChecker(collector, rule);
filter.check();
assertFalse(filter.isDetected());
}
}
/*
* Copyright 2014 NAVER Corp.
*
* 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.
*/
package com.navercorp.pinpoint.web.alarm.checker;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.LinkedList;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
import com.navercorp.pinpoint.common.trace.ServiceType;
import com.navercorp.pinpoint.web.alarm.CheckerCategory;
import com.navercorp.pinpoint.web.alarm.DataCollectorFactory.DataCollectorCategory;
import com.navercorp.pinpoint.web.alarm.checker.SlowRateChecker;
import com.navercorp.pinpoint.web.alarm.collector.ResponseTimeDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
import com.navercorp.pinpoint.web.applicationmap.histogram.TimeHistogram;
import com.navercorp.pinpoint.web.dao.MapResponseDao;
import com.navercorp.pinpoint.web.vo.Application;
import com.navercorp.pinpoint.web.vo.Range;
import com.navercorp.pinpoint.web.vo.ResponseTime;
public class SlowRateCheckerTest {
private static final String SERVICE_NAME = "local_service";
private static final String SERVICE_TYPE = "tomcat";
private static MapResponseDao mockMapResponseDAO;
@BeforeClass
public static void before() {
mockMapResponseDAO = new MapResponseDao() {
@Override
public List<ResponseTime> selectResponseTime(Application application, Range range) {
List<ResponseTime> list = new LinkedList<ResponseTime>();
long timeStamp = 1409814914298L;
ResponseTime responseTime = new ResponseTime(SERVICE_NAME, ServiceType.STAND_ALONE, timeStamp);
list.add(responseTime);
TimeHistogram histogram = null;
for (int i=0 ; i < 5; i++) {
for (int j=0 ; j < 5; j++) {
histogram = new TimeHistogram(ServiceType.STAND_ALONE, timeStamp);
histogram.addCallCountByElapsedTime(1000);
histogram.addCallCountByElapsedTime(3000);
histogram.addCallCountByElapsedTime(5000);
histogram.addCallCountByElapsedTime(6000);
histogram.addCallCountByElapsedTime(7000);
responseTime.addResponseTime("agent_" + i + "_" + j, histogram);
}
timeStamp += 1;
}
return list;
}
};
}
/*
* not satisfied with alert condition
*/
@Test
public void checkTest1() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), 300000);
Rule rule = new Rule(SERVICE_NAME, SERVICE_TYPE, CheckerCategory.SLOW_RATE.getName(), 60, "testGroup", false, false, "");
SlowRateChecker filter = new SlowRateChecker(collector, rule);
filter.check();
assertTrue(filter.isDetected());
}
/*
* not satisfied with alert condition
*/
@Test
public void checkTest2() {
Application application = new Application(SERVICE_NAME, ServiceType.STAND_ALONE);
ResponseTimeDataCollector collector = new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mockMapResponseDAO, System.currentTimeMillis(), 300000);
Rule rule = new Rule(SERVICE_NAME, SERVICE_TYPE, CheckerCategory.SLOW_RATE.getName(), 61, "testGroup", false, false, "");
SlowRateChecker filter = new SlowRateChecker(collector, rule);
filter.check();
assertFalse(filter.isDetected());
}
}
@@ -44,6 +44,7 @@ public class SlowRateToCalleCheckerTest {
private static final String FROM_SERVICE_NAME = "from_local_service";
private static final String TO_SERVICE_NAME = "to_local_service";
private static final String SERVICE_TYPE = "tomcat";
public static MapStatisticsCallerDao dao;
@BeforeClass
@@ -85,7 +86,7 @@ public class SlowRateToCalleCheckerTest {
public void checkTest() {
Application application = new Application(FROM_SERVICE_NAME, ServiceType.STAND_ALONE);
MapStatisticsCallerDataCollector dataCollector = new MapStatisticsCallerDataCollector(DataCollectorCategory.CALLER_STAT, application, dao, System.currentTimeMillis(), 300000);
Rule rule = new Rule(FROM_SERVICE_NAME, CheckerCategory.SLOW_RATE_TO_CALLEE.getName(), 70, "testGroup", false, false, TO_SERVICE_NAME + 1);
Rule rule = new Rule(FROM_SERVICE_NAME, SERVICE_TYPE, CheckerCategory.SLOW_RATE_TO_CALLEE.getName(), 70, "testGroup", false, false, TO_SERVICE_NAME + 1);
SlowRateToCalleeChecker checker = new SlowRateToCalleeChecker(dataCollector, rule);
checker.check();
@@ -96,7 +97,7 @@ public class SlowRateToCalleCheckerTest {
public void checkTest2() {
Application application = new Application(FROM_SERVICE_NAME, ServiceType.STAND_ALONE);
MapStatisticsCallerDataCollector dataCollector = new MapStatisticsCallerDataCollector(DataCollectorCategory.CALLER_STAT, application, dao, System.currentTimeMillis(), 300000);
Rule rule = new Rule(FROM_SERVICE_NAME, CheckerCategory.SLOW_RATE_TO_CALLEE.getName(), 71, "testGroup", false, false, TO_SERVICE_NAME + 1);
Rule rule = new Rule(FROM_SERVICE_NAME, SERVICE_TYPE, CheckerCategory.SLOW_RATE_TO_CALLEE.getName(), 71, "testGroup", false, false, TO_SERVICE_NAME + 1);
SlowRateToCalleeChecker checker = new SlowRateToCalleeChecker(dataCollector, rule);
checker.check();
@@ -107,7 +108,7 @@ public class SlowRateToCalleCheckerTest {
public void checkTest3() {
Application application = new Application(FROM_SERVICE_NAME, ServiceType.STAND_ALONE);
MapStatisticsCallerDataCollector dataCollector = new MapStatisticsCallerDataCollector(DataCollectorCategory.CALLER_STAT, application, dao, System.currentTimeMillis(), 300000);
Rule rule = new Rule(FROM_SERVICE_NAME, CheckerCategory.SLOW_RATE_TO_CALLEE.getName(), 90, "testGroup", false, false, TO_SERVICE_NAME + 2);
Rule rule = new Rule(FROM_SERVICE_NAME, SERVICE_TYPE, CheckerCategory.SLOW_RATE_TO_CALLEE.getName(), 90, "testGroup", false, false, TO_SERVICE_NAME + 2);
SlowRateToCalleeChecker checker = new SlowRateToCalleeChecker(dataCollector, rule);
checker.check();
@@ -43,6 +43,7 @@ public class TotalCountToCalleCheckerTest {
private static final String FROM_SERVICE_NAME = "from_local_service";
private static final String TO_SERVICE_NAME = "to_local_service";
private static final String SERVICE_TYPE = "tomcat";
public static MapStatisticsCallerDao dao;
@BeforeClass
@@ -84,7 +85,7 @@ public class TotalCountToCalleCheckerTest {
public void checkTest() {
Application application = new Application(FROM_SERVICE_NAME, ServiceType.STAND_ALONE);
MapStatisticsCallerDataCollector dataCollector = new MapStatisticsCallerDataCollector(DataCollectorCategory.CALLER_STAT, application, dao, System.currentTimeMillis(), 300000);
Rule rule = new Rule(FROM_SERVICE_NAME, CheckerCategory.TOTAL_COUNT_TO_CALLEE.getName(), 10, "testGroup", false, false, TO_SERVICE_NAME + 1);
Rule rule = new Rule(FROM_SERVICE_NAME, SERVICE_TYPE, CheckerCategory.TOTAL_COUNT_TO_CALLEE.getName(), 10, "testGroup", false, false, TO_SERVICE_NAME + 1);
TotalCountToCalleeChecker checker = new TotalCountToCalleeChecker(dataCollector, rule);
checker.check();
@@ -95,7 +96,7 @@ public class TotalCountToCalleCheckerTest {
public void checkTest2() {
Application application = new Application(FROM_SERVICE_NAME, ServiceType.STAND_ALONE);
MapStatisticsCallerDataCollector dataCollector = new MapStatisticsCallerDataCollector(DataCollectorCategory.CALLER_STAT, application, dao, System.currentTimeMillis(), 300000);
Rule rule = new Rule(FROM_SERVICE_NAME, CheckerCategory.TOTAL_COUNT_TO_CALLEE.getName(), 11, "testGroup", false, false, TO_SERVICE_NAME + 1);
Rule rule = new Rule(FROM_SERVICE_NAME, SERVICE_TYPE, CheckerCategory.TOTAL_COUNT_TO_CALLEE.getName(), 11, "testGroup", false, false, TO_SERVICE_NAME + 1);
TotalCountToCalleeChecker checker = new TotalCountToCalleeChecker(dataCollector, rule);
checker.check();
@@ -106,7 +107,7 @@ public class TotalCountToCalleCheckerTest {
public void checkTest3() {
Application application = new Application(FROM_SERVICE_NAME, ServiceType.STAND_ALONE);
MapStatisticsCallerDataCollector dataCollector = new MapStatisticsCallerDataCollector(DataCollectorCategory.CALLER_STAT, application, dao, System.currentTimeMillis(), 300000);
Rule rule = new Rule(FROM_SERVICE_NAME, CheckerCategory.TOTAL_COUNT_TO_CALLEE.getName(), 10, "testGroup", false, false, TO_SERVICE_NAME + 2);
Rule rule = new Rule(FROM_SERVICE_NAME, SERVICE_TYPE, CheckerCategory.TOTAL_COUNT_TO_CALLEE.getName(), 10, "testGroup", false, false, TO_SERVICE_NAME + 2);
TotalCountToCalleeChecker checker = new TotalCountToCalleeChecker(dataCollector, rule);
checker.check();
@@ -59,6 +59,8 @@ import com.navercorp.pinpoint.web.dao.AlarmDao;
public class AlarmControllerTest {
private final static String APPLICATION_ID = "test-application";
private final static String APPLICATION_ID_UPDATED = "test-application-tomcat";
private final static String SERVICE_TYPE = "tomcat";
private final static String USER_GROUP_ID = "test-pinpoint_group";
private final static String USER_GROUP_ID_UPDATED = "test-pinpoint_team";
@@ -98,6 +100,7 @@ public class AlarmControllerTest {
public void insertAndSelectAndDeleteRule() throws Exception {
String jsonParm = "{" +
"\"applicationId\" : \"" + APPLICATION_ID + "\"," +
"\"serviceType\" : \"" + SERVICE_TYPE + "\"," +
"\"userGroupId\" : \"" + USER_GROUP_ID + "\"," +
"\"checkerName\" : \"" + CHECKER_NAME + "\"," +
"\"threshold\" : " + THRESHOLD + "," +
@@ -117,10 +120,11 @@ public class AlarmControllerTest {
Assert.assertEquals(resultMap.get("result"), "SUCCESS");
Assert.assertNotNull(resultMap.get("ruleId"));
this.mockMvc.perform(get("/alarmRule.pinpoint").contentType(MediaType.APPLICATION_JSON).content("{\"userGroupId\" : \"" + USER_GROUP_ID + "\"}"))
this.mockMvc.perform(get("/alarmRule.pinpoint?userGroupId=" + USER_GROUP_ID))
.andExpect(status().isOk())
.andExpect(content().contentType("application/json;charset=UTF-8"))
.andExpect(jsonPath("$[0]", hasKey("applicationId")))
.andExpect(jsonPath("$[0]", hasKey("serviceType")))
.andExpect(jsonPath("$[0]", hasKey("userGroupId")))
.andExpect(jsonPath("$[0]", hasKey("checkerName")))
.andExpect(jsonPath("$[0]", hasKey("threshold")))
@@ -142,6 +146,7 @@ public class AlarmControllerTest {
public void updateRule() throws Exception {
String jsonParm = "{" +
"\"applicationId\" : \"" + APPLICATION_ID + "\"," +
"\"serviceType\" : \"" + SERVICE_TYPE + "\"," +
"\"userGroupId\" : \"" + USER_GROUP_ID + "\"," +
"\"checkerName\" : \"" + CHECKER_NAME + "\"," +
"\"threshold\" : " + THRESHOLD + "," +
@@ -164,6 +169,7 @@ public class AlarmControllerTest {
String updatedJsonParm = "{" +
"\"ruleId\" : \"" + resultMap.get("ruleId") + "\"," +
"\"applicationId\" : \"" + APPLICATION_ID_UPDATED + "\"," +
"\"serviceType\" : \"" + SERVICE_TYPE + "\"," +
"\"userGroupId\" : \"" + USER_GROUP_ID_UPDATED + "\"," +
"\"checkerName\" : \"" + CHECKER_NAME_UPDATED + "\"," +
"\"threshold\" : " + THRESHOLD_UPDATED + "," +
@@ -179,12 +185,12 @@ public class AlarmControllerTest {
.andExpect(jsonPath("$.result").value("SUCCESS"))
.andReturn();
// this.mockMvc.perform(delete("/alarmRule.pinpoint").contentType(MediaType.APPLICATION_JSON).content("{\"ruleId\" : \"" + resultMap.get("ruleId") + "\"}"))
// .andExpect(status().isOk())
// .andExpect(content().contentType("application/json;charset=UTF-8"))
// .andExpect(jsonPath("$", hasKey("result")))
// .andExpect(jsonPath("$.result").value("SUCCESS"))
// .andReturn();
this.mockMvc.perform(delete("/alarmRule.pinpoint").contentType(MediaType.APPLICATION_JSON).content("{\"ruleId\" : \"" + resultMap.get("ruleId") + "\"}"))
.andExpect(status().isOk())
.andExpect(content().contentType("application/json;charset=UTF-8"))
.andExpect(jsonPath("$", hasKey("result")))
.andExpect(jsonPath("$.result").value("SUCCESS"))
.andReturn();
}
@Test
@@ -200,5 +206,4 @@ public class AlarmControllerTest {
List<String> checherList = objectMapper.readValue(content, List.class);
Assert.assertNotEquals(checherList.size(), 0);
}
}