Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
czzxueyang
skywalking
提交
4c99480f
S
skywalking
项目概览
czzxueyang
/
skywalking
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
skywalking
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4c99480f
编写于
12月 19, 2019
作者:
Z
zhang-wei
提交者:
kezhenxu94
12月 19, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add relation metrics verification in e2e test (#4080)
上级
23387441
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
249 addition
and
161 deletion
+249
-161
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/ServiceInstanceInventory.java
...ng/oap/server/core/register/ServiceInstanceInventory.java
+4
-4
test/e2e/e2e-base/src/main/java/org/apache/skywalking/e2e/metrics/MetricsMatcher.java
...ava/org/apache/skywalking/e2e/metrics/MetricsMatcher.java
+71
-0
test/e2e/e2e-base/src/main/java/org/apache/skywalking/e2e/metrics/MetricsQuery.java
.../java/org/apache/skywalking/e2e/metrics/MetricsQuery.java
+32
-0
test/e2e/e2e-cluster-with-gateway/e2e-cluster-with-gateway-test-runner/src/test/java/org/apache/skywalking/e2e/ClusterVerificationITCase.java
.../org/apache/skywalking/e2e/ClusterVerificationITCase.java
+38
-77
test/e2e/e2e-cluster/e2e-cluster-test-runner/src/test/java/org/apache/skywalking/e2e/ClusterVerificationITCase.java
.../org/apache/skywalking/e2e/ClusterVerificationITCase.java
+38
-74
test/e2e/e2e-mysql/src/test/java/org/apache/skywalking/e2e/SampleVerificationITCase.java
...a/org/apache/skywalking/e2e/SampleVerificationITCase.java
+33
-3
test/e2e/e2e-single-service/src/test/java/org/apache/skywalking/e2e/SampleVerificationITCase.java
...a/org/apache/skywalking/e2e/SampleVerificationITCase.java
+33
-3
未找到文件。
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/ServiceInstanceInventory.java
浏览文件 @
4c99480f
...
...
@@ -55,7 +55,7 @@ public class ServiceInstanceInventory extends RegisterSource {
public
static
final
String
IS_ADDRESS
=
"is_address"
;
private
static
final
String
ADDRESS_ID
=
"address_id"
;
public
static
final
String
NODE_TYPE
=
"node_type"
;
public
static
final
String
MAPPING_SERVICE_ID
=
"mapping_service_instance_id"
;
public
static
final
String
MAPPING_SERVICE_I
NSTANCE_I
D
=
"mapping_service_instance_id"
;
public
static
final
String
PROPERTIES
=
"properties"
;
private
static
final
Gson
GSON
=
new
Gson
();
...
...
@@ -65,7 +65,7 @@ public class ServiceInstanceInventory extends RegisterSource {
@Setter
@Getter
@Column
(
columnName
=
IS_ADDRESS
)
private
int
isAddress
;
@Setter
@Getter
@Column
(
columnName
=
ADDRESS_ID
)
private
int
addressId
;
@Setter
(
AccessLevel
.
PRIVATE
)
@Getter
(
AccessLevel
.
PACKAGE
)
@Column
(
columnName
=
NODE_TYPE
)
private
int
nodeType
;
@Setter
@Getter
@Column
(
columnName
=
MAPPING_SERVICE_ID
)
private
int
mappingServiceInstanceId
;
@Setter
@Getter
@Column
(
columnName
=
MAPPING_SERVICE_I
NSTANCE_I
D
)
private
int
mappingServiceInstanceId
;
@Getter
(
AccessLevel
.
PRIVATE
)
@Column
(
columnName
=
PROPERTIES
)
private
String
prop
;
@Getter
private
JsonObject
properties
;
...
...
@@ -239,7 +239,7 @@ public class ServiceInstanceInventory extends RegisterSource {
inventory
.
setLastUpdateTime
(((
Number
)
dbMap
.
get
(
LAST_UPDATE_TIME
)).
longValue
());
inventory
.
setNodeType
(((
Number
)
dbMap
.
get
(
NODE_TYPE
)).
intValue
());
inventory
.
setMappingServiceInstanceId
(((
Number
)
dbMap
.
get
(
MAPPING_SERVICE_ID
)).
intValue
());
inventory
.
setMappingServiceInstanceId
(((
Number
)
dbMap
.
get
(
MAPPING_SERVICE_I
NSTANCE_I
D
)).
intValue
());
inventory
.
setName
((
String
)
dbMap
.
get
(
NAME
));
inventory
.
setInstanceUUID
((
String
)
dbMap
.
get
(
INSTANCE_UUID
));
...
...
@@ -259,7 +259,7 @@ public class ServiceInstanceInventory extends RegisterSource {
map
.
put
(
LAST_UPDATE_TIME
,
storageData
.
getLastUpdateTime
());
map
.
put
(
NODE_TYPE
,
storageData
.
getNodeType
());
map
.
put
(
MAPPING_SERVICE_ID
,
storageData
.
getMappingServiceInstanceId
());
map
.
put
(
MAPPING_SERVICE_I
NSTANCE_I
D
,
storageData
.
getMappingServiceInstanceId
());
map
.
put
(
NAME
,
storageData
.
getName
());
map
.
put
(
INSTANCE_UUID
,
storageData
.
getInstanceUUID
());
...
...
test/e2e/e2e-base/src/main/java/org/apache/skywalking/e2e/metrics/MetricsMatcher.java
0 → 100644
浏览文件 @
4c99480f
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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
org.apache.skywalking.e2e.metrics
;
import
org.apache.skywalking.e2e.SimpleQueryClient
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.time.LocalDateTime
;
import
java.time.ZoneOffset
;
/**
* @author zhangwei
*/
public
class
MetricsMatcher
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
MetricsMatcher
.
class
);
public
static
void
verifyMetrics
(
SimpleQueryClient
queryClient
,
String
metricName
,
String
id
,
final
LocalDateTime
minutesAgo
)
throws
Exception
{
verifyMetrics
(
queryClient
,
metricName
,
id
,
minutesAgo
,
0
,
null
);
}
public
static
void
verifyMetrics
(
SimpleQueryClient
queryClient
,
String
metricName
,
String
id
,
final
LocalDateTime
minutesAgo
,
long
retryInterval
,
Runnable
generateTraffic
)
throws
Exception
{
boolean
valid
=
false
;
while
(!
valid
)
{
Metrics
metrics
=
queryClient
.
metrics
(
new
MetricsQuery
()
.
stepByMinute
()
.
metricsName
(
metricName
)
.
start
(
minutesAgo
)
.
end
(
LocalDateTime
.
now
(
ZoneOffset
.
UTC
).
plusMinutes
(
1
))
.
id
(
id
)
);
LOGGER
.
info
(
"{}: {}"
,
metricName
,
metrics
);
AtLeastOneOfMetricsMatcher
instanceRespTimeMatcher
=
new
AtLeastOneOfMetricsMatcher
();
MetricsValueMatcher
greaterThanZero
=
new
MetricsValueMatcher
();
greaterThanZero
.
setValue
(
"gt 0"
);
instanceRespTimeMatcher
.
setValue
(
greaterThanZero
);
try
{
instanceRespTimeMatcher
.
verify
(
metrics
);
valid
=
true
;
}
catch
(
Throwable
e
)
{
if
(
generateTraffic
!=
null
)
{
generateTraffic
.
run
();
Thread
.
sleep
(
retryInterval
);
}
else
{
throw
e
;
}
}
}
}
}
test/e2e/e2e-base/src/main/java/org/apache/skywalking/e2e/metrics/MetricsQuery.java
浏览文件 @
4c99480f
...
...
@@ -61,6 +61,38 @@ public class MetricsQuery extends AbstractQuery<MetricsQuery> {
SERVICE_INSTANCE_SLA
};
public
static
String
SERVICE_RELATION_CLIENT_CPM
=
"service_relation_client_cpm"
;
public
static
String
SERVICE_RELATION_SERVER_CPM
=
"service_relation_server_cpm"
;
public
static
String
SERVICE_RELATION_CLIENT_CALL_SLA
=
"service_relation_client_call_sla"
;
public
static
String
SERVICE_RELATION_SERVER_CALL_SLA
=
"service_relation_server_call_sla"
;
public
static
String
SERVICE_RELATION_CLIENT_RESP_TIME
=
"service_relation_client_resp_time"
;
public
static
String
SERVICE_RELATION_SERVER_RESP_TIME
=
"service_relation_server_resp_time"
;
public
static
String
SERVICE_RELATION_CLIENT_P99
=
"service_relation_client_p99"
;
public
static
String
SERVICE_RELATION_SERVER_P99
=
"service_relation_server_p99"
;
public
static
String
[]
ALL_SERVICE_RELATION_CLIENT_METRICS
=
{
SERVICE_RELATION_CLIENT_CPM
};
public
static
String
[]
ALL_SERVICE_RELATION_SERVER_METRICS
=
{
SERVICE_RELATION_SERVER_CPM
};
public
static
String
SERVICE_INSTANCE_RELATION_CLIENT_CPM
=
"service_instance_relation_client_cpm"
;
public
static
String
SERVICE_INSTANCE_RELATION_SERVER_CPM
=
"service_instance_relation_server_cpm"
;
public
static
String
SERVICE_INSTANCE_RELATION_CLIENT_CALL_SLA
=
"service_instance_relation_client_call_sla"
;
public
static
String
SERVICE_INSTANCE_RELATION_SERVER_CALL_SLA
=
"service_instance_relation_server_call_sla"
;
public
static
String
SERVICE_INSTANCE_RELATION_CLIENT_RESP_TIME
=
"service_instance_relation_client_resp_time"
;
public
static
String
SERVICE_INSTANCE_RELATION_SERVER_RESP_TIME
=
"service_instance_relation_server_resp_time"
;
public
static
String
SERVICE_INSTANCE_RELATION_CLIENT_P99
=
"service_instance_relation_client_p99"
;
public
static
String
SERVICE_INSTANCE_RELATION_SERVER_P99
=
"service_instance_relation_server_p99"
;
public
static
String
[]
ALL_SERVICE_INSTANCE_RELATION_CLIENT_METRICS
=
{
SERVICE_INSTANCE_RELATION_CLIENT_CPM
};
public
static
String
[]
ALL_SERVICE_INSTANCE_RELATION_SERVER_METRICS
=
{
SERVICE_INSTANCE_RELATION_SERVER_CPM
};
private
String
id
;
private
String
metricsName
;
...
...
test/e2e/e2e-cluster-with-gateway/e2e-cluster-with-gateway-test-runner/src/test/java/org/apache/skywalking/e2e/ClusterVerificationITCase.java
浏览文件 @
4c99480f
...
...
@@ -18,10 +18,6 @@
package
org.apache.skywalking.e2e
;
import
org.apache.skywalking.e2e.metrics.AtLeastOneOfMetricsMatcher
;
import
org.apache.skywalking.e2e.metrics.Metrics
;
import
org.apache.skywalking.e2e.metrics.MetricsQuery
;
import
org.apache.skywalking.e2e.metrics.MetricsValueMatcher
;
import
org.apache.skywalking.e2e.service.Service
;
import
org.apache.skywalking.e2e.service.ServicesMatcher
;
import
org.apache.skywalking.e2e.service.ServicesQuery
;
...
...
@@ -58,6 +54,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
static
org
.
apache
.
skywalking
.
e2e
.
metrics
.
MetricsMatcher
.
verifyMetrics
;
import
static
org
.
apache
.
skywalking
.
e2e
.
metrics
.
MetricsQuery
.*;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
fail
;
...
...
@@ -137,6 +134,8 @@ public class ClusterVerificationITCase {
final
TopoMatcher
topoMatcher
=
yaml
.
loadAs
(
expectedInputStream
,
TopoMatcher
.
class
);
topoMatcher
.
verify
(
topoData
);
verifyServiceRelationMetrics
(
topoData
.
getCalls
(),
minutesAgo
);
valid
=
true
;
for
(
Node
node
:
topoData
.
getNodes
())
{
if
(
gateWayName
.
equals
(
node
.
getName
()))
{
...
...
@@ -176,6 +175,8 @@ public class ClusterVerificationITCase {
new
ClassPathResource
(
"expected-data/org.apache.skywalking.e2e.ClusterVerificationITCase.serviceInstanceTopo.yml"
).
getInputStream
();
final
ServiceInstanceTopoMatcher
topoMatcher
=
yaml
.
loadAs
(
expectedInputStream
,
ServiceInstanceTopoMatcher
.
class
);
topoMatcher
.
verify
(
topoData
);
verifyServiceInstanceRelationMetrics
(
topoData
.
getCalls
(),
minutesAgo
);
valid
=
true
;
}
catch
(
Throwable
t
){
LOGGER
.
warn
(
t
.
getMessage
(),
t
);
...
...
@@ -278,31 +279,8 @@ public class ClusterVerificationITCase {
for
(
Instance
instance
:
instances
.
getInstances
())
{
for
(
String
metricsName
:
ALL_INSTANCE_METRICS
)
{
LOGGER
.
info
(
"verifying service instance response time: {}"
,
instance
);
boolean
valid
=
false
;
while
(!
valid
)
{
LOGGER
.
warn
(
"instanceMetrics is null, will retry to query"
);
Metrics
instanceMetrics
=
queryClient
.
metrics
(
new
MetricsQuery
()
.
stepByMinute
()
.
metricsName
(
metricsName
)
.
start
(
minutesAgo
)
.
end
(
LocalDateTime
.
now
(
ZoneOffset
.
UTC
).
plusMinutes
(
1
))
.
id
(
instance
.
getKey
())
);
AtLeastOneOfMetricsMatcher
instanceRespTimeMatcher
=
new
AtLeastOneOfMetricsMatcher
();
MetricsValueMatcher
greaterThanZero
=
new
MetricsValueMatcher
();
greaterThanZero
.
setValue
(
"gt 0"
);
instanceRespTimeMatcher
.
setValue
(
greaterThanZero
);
try
{
instanceRespTimeMatcher
.
verify
(
instanceMetrics
);
valid
=
true
;
}
catch
(
Throwable
ignored
)
{
generateTraffic
();
Thread
.
sleep
(
retryInterval
);
}
LOGGER
.
info
(
"{}: {}"
,
metricsName
,
instanceMetrics
);
}
LOGGER
.
warn
(
"instanceMetrics is null, will retry to query"
);
verifyMetrics
(
queryClient
,
metricsName
,
instance
.
getKey
(),
minutesAgo
,
retryInterval
,
this
::
generateTraffic
);
}
}
}
...
...
@@ -314,30 +292,7 @@ public class ClusterVerificationITCase {
}
for
(
String
metricName
:
ALL_ENDPOINT_METRICS
)
{
LOGGER
.
info
(
"verifying endpoint {}, metrics: {}"
,
endpoint
,
metricName
);
boolean
valid
=
false
;
while
(!
valid
)
{
Metrics
endpointMetrics
=
queryClient
.
metrics
(
new
MetricsQuery
()
.
stepByMinute
()
.
metricsName
(
metricName
)
.
start
(
minutesAgo
)
.
end
(
LocalDateTime
.
now
(
ZoneOffset
.
UTC
))
.
id
(
endpoint
.
getKey
())
);
AtLeastOneOfMetricsMatcher
instanceRespTimeMatcher
=
new
AtLeastOneOfMetricsMatcher
();
MetricsValueMatcher
greaterThanZero
=
new
MetricsValueMatcher
();
greaterThanZero
.
setValue
(
"gt 0"
);
instanceRespTimeMatcher
.
setValue
(
greaterThanZero
);
try
{
instanceRespTimeMatcher
.
verify
(
endpointMetrics
);
valid
=
true
;
}
catch
(
Throwable
ignored
)
{
generateTraffic
();
Thread
.
sleep
(
retryInterval
);
}
LOGGER
.
info
(
"{}: {}"
,
metricName
,
endpointMetrics
);
}
verifyMetrics
(
queryClient
,
metricName
,
endpoint
.
getKey
(),
minutesAgo
,
retryInterval
,
this
::
generateTraffic
);
}
}
}
...
...
@@ -345,30 +300,7 @@ public class ClusterVerificationITCase {
private
void
verifyServiceMetrics
(
Service
service
,
final
LocalDateTime
minutesAgo
)
throws
Exception
{
for
(
String
metricName
:
ALL_SERVICE_METRICS
)
{
LOGGER
.
info
(
"verifying service {}, metrics: {}"
,
service
,
metricName
);
boolean
valid
=
false
;
while
(!
valid
)
{
Metrics
serviceMetrics
=
queryClient
.
metrics
(
new
MetricsQuery
()
.
stepByMinute
()
.
metricsName
(
metricName
)
.
start
(
minutesAgo
)
.
end
(
LocalDateTime
.
now
(
ZoneOffset
.
UTC
))
.
id
(
service
.
getKey
())
);
AtLeastOneOfMetricsMatcher
instanceRespTimeMatcher
=
new
AtLeastOneOfMetricsMatcher
();
MetricsValueMatcher
greaterThanZero
=
new
MetricsValueMatcher
();
greaterThanZero
.
setValue
(
"gt 0"
);
instanceRespTimeMatcher
.
setValue
(
greaterThanZero
);
try
{
instanceRespTimeMatcher
.
verify
(
serviceMetrics
);
valid
=
true
;
}
catch
(
Throwable
ignored
)
{
generateTraffic
();
Thread
.
sleep
(
retryInterval
);
}
LOGGER
.
info
(
"{}: {}"
,
metricName
,
serviceMetrics
);
}
verifyMetrics
(
queryClient
,
metricName
,
service
.
getKey
(),
minutesAgo
,
retryInterval
,
this
::
generateTraffic
);
}
}
...
...
@@ -393,6 +325,35 @@ public class ClusterVerificationITCase {
tracesMatcher
.
verifyLoosely
(
traces
);
}
private
void
verifyServiceInstanceRelationMetrics
(
List
<
Call
>
calls
,
final
LocalDateTime
minutesAgo
)
throws
Exception
{
verifyRelationMetrics
(
calls
,
minutesAgo
,
ALL_SERVICE_INSTANCE_RELATION_CLIENT_METRICS
,
ALL_SERVICE_INSTANCE_RELATION_SERVER_METRICS
);
}
private
void
verifyServiceRelationMetrics
(
List
<
Call
>
calls
,
final
LocalDateTime
minutesAgo
)
throws
Exception
{
verifyRelationMetrics
(
calls
,
minutesAgo
,
ALL_SERVICE_RELATION_CLIENT_METRICS
,
ALL_SERVICE_RELATION_SERVER_METRICS
);
}
private
void
verifyRelationMetrics
(
List
<
Call
>
calls
,
final
LocalDateTime
minutesAgo
,
String
[]
relationClientMetrics
,
String
[]
relationServerMetrics
)
throws
Exception
{
for
(
Call
call
:
calls
)
{
for
(
String
detectPoint
:
call
.
getDetectPoints
())
{
switch
(
detectPoint
)
{
case
"CLIENT"
:
{
for
(
String
metricName
:
relationClientMetrics
)
{
verifyMetrics
(
queryClient
,
metricName
,
call
.
getId
(),
minutesAgo
,
retryInterval
,
this
::
generateTraffic
);
}
break
;
}
case
"SERVER"
:
{
for
(
String
metricName
:
relationServerMetrics
)
{
verifyMetrics
(
queryClient
,
metricName
,
call
.
getId
(),
minutesAgo
,
retryInterval
,
this
::
generateTraffic
);
}
break
;
}
}
}
}
}
private
void
generateTraffic
()
{
try
{
final
Map
<
String
,
String
>
user
=
new
HashMap
<>();
...
...
test/e2e/e2e-cluster/e2e-cluster-test-runner/src/test/java/org/apache/skywalking/e2e/ClusterVerificationITCase.java
浏览文件 @
4c99480f
...
...
@@ -18,10 +18,6 @@
package
org.apache.skywalking.e2e
;
import
org.apache.skywalking.e2e.metrics.AtLeastOneOfMetricsMatcher
;
import
org.apache.skywalking.e2e.metrics.Metrics
;
import
org.apache.skywalking.e2e.metrics.MetricsQuery
;
import
org.apache.skywalking.e2e.metrics.MetricsValueMatcher
;
import
org.apache.skywalking.e2e.service.Service
;
import
org.apache.skywalking.e2e.service.ServicesMatcher
;
import
org.apache.skywalking.e2e.service.ServicesQuery
;
...
...
@@ -58,6 +54,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
static
org
.
apache
.
skywalking
.
e2e
.
metrics
.
MetricsMatcher
.
verifyMetrics
;
import
static
org
.
apache
.
skywalking
.
e2e
.
metrics
.
MetricsQuery
.*;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
fail
;
...
...
@@ -136,6 +133,8 @@ public class ClusterVerificationITCase {
final
TopoMatcher
topoMatcher
=
yaml
.
loadAs
(
expectedInputStream
,
TopoMatcher
.
class
);
topoMatcher
.
verify
(
topoData
);
verifyServiceRelationMetrics
(
topoData
.
getCalls
(),
minutesAgo
);
valid
=
true
;
for
(
Node
node
:
topoData
.
getNodes
())
{
if
(
node
.
getName
().
equals
(
providerName
))
{
...
...
@@ -174,6 +173,7 @@ public class ClusterVerificationITCase {
new
ClassPathResource
(
"expected-data/org.apache.skywalking.e2e.ClusterVerificationITCase.serviceInstanceTopo.yml"
).
getInputStream
();
final
ServiceInstanceTopoMatcher
topoMatcher
=
yaml
.
loadAs
(
expectedInputStream
,
ServiceInstanceTopoMatcher
.
class
);
topoMatcher
.
verify
(
topoData
);
verifyServiceInstanceRelationMetrics
(
topoData
.
getCalls
(),
minutesAgo
);
valid
=
true
;
}
catch
(
Throwable
t
)
{
LOGGER
.
warn
(
t
.
getMessage
(),
t
);
...
...
@@ -277,30 +277,8 @@ public class ClusterVerificationITCase {
for
(
String
metricsName
:
ALL_INSTANCE_METRICS
)
{
LOGGER
.
info
(
"verifying service instance response time: {}"
,
instance
);
boolean
valid
=
false
;
while
(!
valid
)
{
LOGGER
.
warn
(
"instanceMetrics is null, will retry to query"
);
Metrics
instanceMetrics
=
queryClient
.
metrics
(
new
MetricsQuery
()
.
stepByMinute
()
.
metricsName
(
metricsName
)
.
start
(
minutesAgo
)
.
end
(
LocalDateTime
.
now
(
ZoneOffset
.
UTC
).
plusMinutes
(
1
))
.
id
(
instance
.
getKey
())
);
AtLeastOneOfMetricsMatcher
instanceRespTimeMatcher
=
new
AtLeastOneOfMetricsMatcher
();
MetricsValueMatcher
greaterThanZero
=
new
MetricsValueMatcher
();
greaterThanZero
.
setValue
(
"gt 0"
);
instanceRespTimeMatcher
.
setValue
(
greaterThanZero
);
try
{
instanceRespTimeMatcher
.
verify
(
instanceMetrics
);
valid
=
true
;
}
catch
(
Throwable
ignored
)
{
generateTraffic
();
Thread
.
sleep
(
retryInterval
);
}
LOGGER
.
info
(
"{}: {}"
,
metricsName
,
instanceMetrics
);
}
LOGGER
.
warn
(
"instanceMetrics is null, will retry to query"
);
verifyMetrics
(
queryClient
,
metricsName
,
instance
.
getKey
(),
minutesAgo
,
retryInterval
,
this
::
generateTraffic
);
}
}
}
...
...
@@ -313,29 +291,7 @@ public class ClusterVerificationITCase {
for
(
String
metricName
:
ALL_ENDPOINT_METRICS
)
{
LOGGER
.
info
(
"verifying endpoint {}, metrics: {}"
,
endpoint
,
metricName
);
boolean
valid
=
false
;
while
(!
valid
)
{
Metrics
endpointMetrics
=
queryClient
.
metrics
(
new
MetricsQuery
()
.
stepByMinute
()
.
metricsName
(
metricName
)
.
start
(
minutesAgo
)
.
end
(
LocalDateTime
.
now
(
ZoneOffset
.
UTC
))
.
id
(
endpoint
.
getKey
())
);
AtLeastOneOfMetricsMatcher
instanceRespTimeMatcher
=
new
AtLeastOneOfMetricsMatcher
();
MetricsValueMatcher
greaterThanZero
=
new
MetricsValueMatcher
();
greaterThanZero
.
setValue
(
"gt 0"
);
instanceRespTimeMatcher
.
setValue
(
greaterThanZero
);
try
{
instanceRespTimeMatcher
.
verify
(
endpointMetrics
);
valid
=
true
;
}
catch
(
Throwable
ignored
)
{
generateTraffic
();
Thread
.
sleep
(
retryInterval
);
}
LOGGER
.
info
(
"{}: {}"
,
metricName
,
endpointMetrics
);
}
verifyMetrics
(
queryClient
,
metricName
,
endpoint
.
getKey
(),
minutesAgo
,
retryInterval
,
this
::
generateTraffic
);
}
}
}
...
...
@@ -344,29 +300,7 @@ public class ClusterVerificationITCase {
for
(
String
metricName
:
ALL_SERVICE_METRICS
)
{
LOGGER
.
info
(
"verifying service {}, metrics: {}"
,
service
,
metricName
);
boolean
valid
=
false
;
while
(!
valid
)
{
Metrics
serviceMetrics
=
queryClient
.
metrics
(
new
MetricsQuery
()
.
stepByMinute
()
.
metricsName
(
metricName
)
.
start
(
minutesAgo
)
.
end
(
LocalDateTime
.
now
(
ZoneOffset
.
UTC
))
.
id
(
service
.
getKey
())
);
AtLeastOneOfMetricsMatcher
instanceRespTimeMatcher
=
new
AtLeastOneOfMetricsMatcher
();
MetricsValueMatcher
greaterThanZero
=
new
MetricsValueMatcher
();
greaterThanZero
.
setValue
(
"gt 0"
);
instanceRespTimeMatcher
.
setValue
(
greaterThanZero
);
try
{
instanceRespTimeMatcher
.
verify
(
serviceMetrics
);
valid
=
true
;
}
catch
(
Throwable
ignored
)
{
generateTraffic
();
Thread
.
sleep
(
retryInterval
);
}
LOGGER
.
info
(
"{}: {}"
,
metricName
,
serviceMetrics
);
}
verifyMetrics
(
queryClient
,
metricName
,
service
.
getKey
(),
minutesAgo
,
retryInterval
,
this
::
generateTraffic
);
}
}
...
...
@@ -391,6 +325,36 @@ public class ClusterVerificationITCase {
tracesMatcher
.
verifyLoosely
(
traces
);
}
private
void
verifyServiceInstanceRelationMetrics
(
List
<
Call
>
calls
,
final
LocalDateTime
minutesAgo
)
throws
Exception
{
verifyRelationMetrics
(
calls
,
minutesAgo
,
ALL_SERVICE_INSTANCE_RELATION_CLIENT_METRICS
,
ALL_SERVICE_INSTANCE_RELATION_SERVER_METRICS
);
}
private
void
verifyServiceRelationMetrics
(
List
<
Call
>
calls
,
final
LocalDateTime
minutesAgo
)
throws
Exception
{
verifyRelationMetrics
(
calls
,
minutesAgo
,
ALL_SERVICE_RELATION_CLIENT_METRICS
,
ALL_SERVICE_RELATION_SERVER_METRICS
);
}
private
void
verifyRelationMetrics
(
List
<
Call
>
calls
,
final
LocalDateTime
minutesAgo
,
String
[]
relationClientMetrics
,
String
[]
relationServerMetrics
)
throws
Exception
{
for
(
Call
call
:
calls
)
{
for
(
String
detectPoint
:
call
.
getDetectPoints
())
{
switch
(
detectPoint
)
{
case
"CLIENT"
:
{
for
(
String
metricName
:
relationClientMetrics
)
{
verifyMetrics
(
queryClient
,
metricName
,
call
.
getId
(),
minutesAgo
,
retryInterval
,
this
::
generateTraffic
);
}
break
;
}
case
"SERVER"
:
{
for
(
String
metricName
:
relationServerMetrics
)
{
verifyMetrics
(
queryClient
,
metricName
,
call
.
getId
(),
minutesAgo
,
retryInterval
,
this
::
generateTraffic
);
}
break
;
}
}
}
}
}
private
void
generateTraffic
()
{
try
{
final
Map
<
String
,
String
>
user
=
new
HashMap
<>();
...
...
test/e2e/e2e-mysql/src/test/java/org/apache/skywalking/e2e/SampleVerificationITCase.java
浏览文件 @
4c99480f
...
...
@@ -57,9 +57,8 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
static
org
.
apache
.
skywalking
.
e2e
.
metrics
.
MetricsQuery
.
ALL_ENDPOINT_METRICS
;
import
static
org
.
apache
.
skywalking
.
e2e
.
metrics
.
MetricsQuery
.
ALL_INSTANCE_METRICS
;
import
static
org
.
apache
.
skywalking
.
e2e
.
metrics
.
MetricsQuery
.
ALL_SERVICE_METRICS
;
import
static
org
.
apache
.
skywalking
.
e2e
.
metrics
.
MetricsMatcher
.
verifyMetrics
;
import
static
org
.
apache
.
skywalking
.
e2e
.
metrics
.
MetricsQuery
.*;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
...
...
@@ -164,6 +163,7 @@ public class SampleVerificationITCase {
final
TopoMatcher
topoMatcher
=
new
Yaml
().
loadAs
(
expectedInputStream
,
TopoMatcher
.
class
);
topoMatcher
.
verify
(
topoData
);
verifyServiceRelationMetrics
(
topoData
.
getCalls
(),
minutesAgo
);
}
private
void
verifyServiceInstanceTopo
(
LocalDateTime
minutesAgo
)
throws
Exception
{
...
...
@@ -184,6 +184,7 @@ public class SampleVerificationITCase {
final
ServiceInstanceTopoMatcher
topoMatcher
=
new
Yaml
().
loadAs
(
expectedInputStream
,
ServiceInstanceTopoMatcher
.
class
);
topoMatcher
.
verify
(
topoData
);
verifyServiceInstanceRelationMetrics
(
topoData
.
getCalls
(),
minutesAgo
);
}
private
void
verifyServices
(
LocalDateTime
minutesAgo
)
throws
Exception
{
...
...
@@ -329,6 +330,35 @@ public class SampleVerificationITCase {
tracesMatcher
.
verify
(
traces
);
}
private
void
verifyServiceInstanceRelationMetrics
(
List
<
Call
>
calls
,
final
LocalDateTime
minutesAgo
)
throws
Exception
{
verifyRelationMetrics
(
calls
,
minutesAgo
,
ALL_SERVICE_INSTANCE_RELATION_CLIENT_METRICS
,
ALL_SERVICE_INSTANCE_RELATION_SERVER_METRICS
);
}
private
void
verifyServiceRelationMetrics
(
List
<
Call
>
calls
,
final
LocalDateTime
minutesAgo
)
throws
Exception
{
verifyRelationMetrics
(
calls
,
minutesAgo
,
ALL_SERVICE_RELATION_CLIENT_METRICS
,
ALL_SERVICE_RELATION_SERVER_METRICS
);
}
private
void
verifyRelationMetrics
(
List
<
Call
>
calls
,
final
LocalDateTime
minutesAgo
,
String
[]
relationClientMetrics
,
String
[]
relationServerMetrics
)
throws
Exception
{
for
(
Call
call
:
calls
)
{
for
(
String
detectPoint
:
call
.
getDetectPoints
())
{
switch
(
detectPoint
)
{
case
"CLIENT"
:
{
for
(
String
metricName
:
relationClientMetrics
)
{
verifyMetrics
(
queryClient
,
metricName
,
call
.
getId
(),
minutesAgo
);
}
break
;
}
case
"SERVER"
:
{
for
(
String
metricName
:
relationServerMetrics
)
{
verifyMetrics
(
queryClient
,
metricName
,
call
.
getId
(),
minutesAgo
);
}
break
;
}
}
}
}
}
private
void
doRetryableVerification
(
Runnable
runnable
)
throws
InterruptedException
{
while
(
true
)
{
try
{
...
...
test/e2e/e2e-single-service/src/test/java/org/apache/skywalking/e2e/SampleVerificationITCase.java
浏览文件 @
4c99480f
...
...
@@ -57,9 +57,8 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
static
org
.
apache
.
skywalking
.
e2e
.
metrics
.
MetricsQuery
.
ALL_ENDPOINT_METRICS
;
import
static
org
.
apache
.
skywalking
.
e2e
.
metrics
.
MetricsQuery
.
ALL_INSTANCE_METRICS
;
import
static
org
.
apache
.
skywalking
.
e2e
.
metrics
.
MetricsQuery
.
ALL_SERVICE_METRICS
;
import
static
org
.
apache
.
skywalking
.
e2e
.
metrics
.
MetricsMatcher
.
verifyMetrics
;
import
static
org
.
apache
.
skywalking
.
e2e
.
metrics
.
MetricsQuery
.*;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
...
...
@@ -164,6 +163,7 @@ public class SampleVerificationITCase {
final
TopoMatcher
topoMatcher
=
new
Yaml
().
loadAs
(
expectedInputStream
,
TopoMatcher
.
class
);
topoMatcher
.
verify
(
topoData
);
verifyServiceRelationMetrics
(
topoData
.
getCalls
(),
minutesAgo
);
}
private
void
verifyServiceInstanceTopo
(
LocalDateTime
minutesAgo
)
throws
Exception
{
...
...
@@ -184,6 +184,7 @@ public class SampleVerificationITCase {
final
ServiceInstanceTopoMatcher
topoMatcher
=
new
Yaml
().
loadAs
(
expectedInputStream
,
ServiceInstanceTopoMatcher
.
class
);
topoMatcher
.
verify
(
topoData
);
verifyServiceInstanceRelationMetrics
(
topoData
.
getCalls
(),
minutesAgo
);
}
private
void
verifyServices
(
LocalDateTime
minutesAgo
)
throws
Exception
{
...
...
@@ -329,6 +330,35 @@ public class SampleVerificationITCase {
tracesMatcher
.
verify
(
traces
);
}
private
void
verifyServiceInstanceRelationMetrics
(
List
<
Call
>
calls
,
final
LocalDateTime
minutesAgo
)
throws
Exception
{
verifyRelationMetrics
(
calls
,
minutesAgo
,
ALL_SERVICE_INSTANCE_RELATION_CLIENT_METRICS
,
ALL_SERVICE_INSTANCE_RELATION_SERVER_METRICS
);
}
private
void
verifyServiceRelationMetrics
(
List
<
Call
>
calls
,
final
LocalDateTime
minutesAgo
)
throws
Exception
{
verifyRelationMetrics
(
calls
,
minutesAgo
,
ALL_SERVICE_RELATION_CLIENT_METRICS
,
ALL_SERVICE_RELATION_SERVER_METRICS
);
}
private
void
verifyRelationMetrics
(
List
<
Call
>
calls
,
final
LocalDateTime
minutesAgo
,
String
[]
relationClientMetrics
,
String
[]
relationServerMetrics
)
throws
Exception
{
for
(
Call
call
:
calls
)
{
for
(
String
detectPoint
:
call
.
getDetectPoints
())
{
switch
(
detectPoint
)
{
case
"CLIENT"
:
{
for
(
String
metricName
:
relationClientMetrics
)
{
verifyMetrics
(
queryClient
,
metricName
,
call
.
getId
(),
minutesAgo
);
}
break
;
}
case
"SERVER"
:
{
for
(
String
metricName
:
relationServerMetrics
)
{
verifyMetrics
(
queryClient
,
metricName
,
call
.
getId
(),
minutesAgo
);
}
break
;
}
}
}
}
}
private
void
doRetryableVerification
(
Runnable
runnable
)
throws
InterruptedException
{
while
(
true
)
{
try
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录