Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gdyjdao
SkyWalking
提交
060afcb5
S
SkyWalking
项目概览
gdyjdao
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
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,发现更多精彩内容 >>
提交
060afcb5
编写于
6月 06, 2016
作者:
A
ascrutae
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.完善测试API
2. 增加SDK的数据的测试
上级
7b741cc2
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
285 addition
and
83 deletion
+285
-83
skywalking-api/pom.xml
skywalking-api/pom.xml
+3
-3
skywalking-api/src/main/java/com/ai/cloud/skywalking/buffer/BufferGroup.java
...main/java/com/ai/cloud/skywalking/buffer/BufferGroup.java
+1
-0
skywalking-api/src/main/java/com/ai/cloud/skywalking/buffer/ContextBuffer.java
...in/java/com/ai/cloud/skywalking/buffer/ContextBuffer.java
+1
-0
skywalking-api/src/test/java/test/ai/cloud/assertspandata/TraceTreeAssertTest.java
...ava/test/ai/cloud/assertspandata/TraceTreeAssertTest.java
+25
-0
skywalking-api/src/test/resources/sky-walking.auth
skywalking-api/src/test/resources/sky-walking.auth
+1
-1
test/skywalking-agent-test/redis-test/pom.xml
test/skywalking-agent-test/redis-test/pom.xml
+37
-32
test/skywalking-agent-test/redis-test/src/main/java/com/ai/cloud/skywalking/agent/test/RedisPluginTest.java
...a/com/ai/cloud/skywalking/agent/test/RedisPluginTest.java
+5
-0
test/skywalking-agent-test/redis-test/src/main/resources/sky-walking.auth
...agent-test/redis-test/src/main/resources/sky-walking.auth
+2
-2
test/skywalking-test-api/pom.xml
test/skywalking-test-api/pom.xml
+1
-1
test/skywalking-test-api/src/main/java/test/com/ai/skywalking/api/TraceTreeAssert.java
...main/java/test/com/ai/skywalking/api/TraceTreeAssert.java
+0
-32
test/skywalking-test-api/src/main/java/test/com/ai/skywalking/api/TraceTreeDataAcquirer.java
...ava/test/com/ai/skywalking/api/TraceTreeDataAcquirer.java
+0
-12
test/skywalking-test-api/src/main/java/test/com/ai/skywalking/test/api/TraceTreeAssert.java
...java/test/com/ai/skywalking/test/api/TraceTreeAssert.java
+102
-0
test/skywalking-test-api/src/main/java/test/com/ai/skywalking/test/api/TraceTreeDataAcquirer.java
...est/com/ai/skywalking/test/api/TraceTreeDataAcquirer.java
+60
-0
test/skywalking-test-api/src/main/java/test/com/ai/skywalking/test/api/config/Config.java
...n/java/test/com/ai/skywalking/test/api/config/Config.java
+12
-0
test/skywalking-test-api/src/test/java/test/com/ai/skywalking/reflect/SubClassReflect.java
.../java/test/com/ai/skywalking/reflect/SubClassReflect.java
+25
-0
test/skywalking-test-api/src/test/java/test/com/ai/skywalking/reflect/TestClass.java
...c/test/java/test/com/ai/skywalking/reflect/TestClass.java
+10
-0
未找到文件。
skywalking-api/pom.xml
浏览文件 @
060afcb5
...
...
@@ -46,9 +46,9 @@
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.12
</version>
<groupId>
com.ai.cloud
</groupId>
<artifactId>
skywalking-test-api
</artifactId>
<version>
1.0-Final
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
...
...
skywalking-api/src/main/java/com/ai/cloud/skywalking/buffer/BufferGroup.java
浏览文件 @
060afcb5
...
...
@@ -16,6 +16,7 @@ import static com.ai.cloud.skywalking.conf.Config.Consumer.*;
public
class
BufferGroup
{
private
static
Logger
logger
=
LogManager
.
getLogger
(
BufferGroup
.
class
);
private
String
groupName
;
//注意: 修改这个变量名,需要修改test-api工程的Config类中的SPAN_ARRAY_FIELD_NAME变量
private
Span
[]
dataBuffer
=
new
Span
[
BUFFER_MAX_SIZE
];
AtomicRangeInteger
index
=
new
AtomicRangeInteger
(
0
,
BUFFER_MAX_SIZE
);
...
...
skywalking-api/src/main/java/com/ai/cloud/skywalking/buffer/ContextBuffer.java
浏览文件 @
060afcb5
...
...
@@ -28,6 +28,7 @@ public class ContextBuffer {
static
class
BufferPool
{
// 注意: 这个变量名如果改变需要改变test-api工程中的Config变量
private
static
BufferGroup
[]
bufferGroups
=
new
BufferGroup
[
POOL_SIZE
];
static
{
for
(
int
i
=
0
;
i
<
POOL_SIZE
;
i
++)
{
...
...
skywalking-api/src/test/java/test/ai/cloud/assertspandata/TraceTreeAssertTest.java
0 → 100644
浏览文件 @
060afcb5
package
test.ai.cloud.assertspandata
;
import
com.ai.cloud.skywalking.buffer.ContextBuffer
;
import
com.ai.cloud.skywalking.conf.Config
;
import
com.ai.cloud.skywalking.protocol.Span
;
import
org.junit.Test
;
import
test.com.ai.skywalking.test.api.TraceTreeAssert
;
/**
* Created by xin on 16-6-6.
*/
public
class
TraceTreeAssertTest
{
@Test
public
void
traceTreeAssertTest
()
{
Config
.
Consumer
.
MAX_CONSUMER
=
0
;
Span
testSpan
=
new
Span
(
"1.0b.1465224457414.7e57f54.22905.61.2691"
,
""
,
0
,
"test-application"
,
"5"
);
testSpan
.
setViewPointId
(
"http://hire.asiainfo.com/Aisse-Mobile-Web/aisseWorkPage/submitReimbursement"
);
ContextBuffer
.
save
(
testSpan
);
TraceTreeAssert
.
assertEquals
(
new
String
[][]{
{
null
,
"0"
,
"http://hire.asiainfo.com/Aisse-Mobile-Web/aisseWorkPage/submitReimbursement"
,
null
}
});
}
}
skywalking-api/src/test/resources/sky-walking.auth
浏览文件 @
060afcb5
...
...
@@ -31,7 +31,7 @@ sender.is_off=false
#最大消费线程数
consumer.max_consumer=
2
consumer.max_consumer=
0
#消费者最大等待时间
consumer.max_wait_time=5
#发送失败等待时间
...
...
test/skywalking-agent-test/redis-test/pom.xml
浏览文件 @
060afcb5
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<groupId>
com.ai.cloud
</groupId>
<artifactId>
skywalking-agent-test
</artifactId>
<version>
1.0-Final
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<groupId>
com.ai.cloud
</groupId>
<artifactId>
skywalking-agent-test
</artifactId>
<version>
1.0-Final
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
redis-test
</artifactId>
<packaging>
jar
</packaging>
<artifactId>
redis-test
</artifactId>
<packaging>
jar
</packaging>
<name>
redis-test
</name>
<url>
http://maven.apache.org
</url>
<name>
redis-test
</name>
<url>
http://maven.apache.org
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.12
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-core
</artifactId>
<version>
2.4.1
</version>
</dependency>
<dependency>
<groupId>
redis.clients
</groupId>
<artifactId>
jedis
</artifactId>
<version>
2.8.1
</version>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.12
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.apache.logging.log4j
</groupId>
<artifactId>
log4j-core
</artifactId>
<version>
2.4.1
</version>
</dependency>
<dependency>
<groupId>
com.ai.cloud
</groupId>
<artifactId>
skywalking-test-api
</artifactId>
<version>
1.0-Final
</version>
</dependency>
<dependency>
<groupId>
redis.clients
</groupId>
<artifactId>
jedis
</artifactId>
<version>
2.8.1
</version>
</dependency>
</dependencies>
</project>
test/skywalking-agent-test/redis-test/src/main/java/com/ai/cloud/skywalking/agent/test/RedisPluginTest.java
浏览文件 @
060afcb5
package
com.ai.cloud.skywalking.agent.test
;
import
test.com.ai.skywalking.reflect.api.TraceTreeAssert
;
public
class
RedisPluginTest
{
public
static
void
main
(
String
[]
args
)
{
RedisOperator
.
setData
(
"key1"
,
"value1"
);
TraceTreeAssert
.
assertEquals
(
new
String
[][]{
{
null
,
"0"
,
"127.0.0.1:6379 set"
,
"key=key1"
},
});
}
}
test/skywalking-agent-test/redis-test/src/main/resources/sky-walking.auth
浏览文件 @
060afcb5
...
...
@@ -4,9 +4,9 @@ buriedpoint.businesskey_max_length=300
sender.retry_get_sender_wait_interval=2000
buffer.pool_size=5
senderchecker.check_polling_time=200
sender.is_off=
tru
e
sender.is_off=
fals
e
sender.max_send_length=20000
consumer.max_consumer=
2
consumer.max_consumer=
0
consumer.max_wait_time=5
sender.max_copy_num=2
skywalking.application_code=redis-plugin-test
...
...
test/skywalking-test-api/pom.xml
浏览文件 @
060afcb5
...
...
@@ -22,7 +22,7 @@
<dependencies>
<dependency>
<groupId>
com.ai.cloud
</groupId>
<artifactId>
skywalking-
api
</artifactId>
<artifactId>
skywalking-
protocol
</artifactId>
<version>
${parent.version}
</version>
</dependency>
</dependencies>
...
...
test/skywalking-test-api/src/main/java/test/com/ai/skywalking/api/TraceTreeAssert.java
已删除
100644 → 0
浏览文件 @
7b741cc2
package
test.com.ai.skywalking.api
;
import
com.ai.cloud.skywalking.protocol.Span
;
import
java.util.List
;
public
class
TraceTreeAssert
{
public
static
void
assertEquals
(
String
[][]
assertTraceTree
)
{
List
<
Span
>
bufferTraceSpanList
=
TraceTreeDataAcquirer
.
acquireCurrentTraceSpanData
();
validateTraceId
(
bufferTraceSpanList
);
validateTraceSpanSize
(
bufferTraceSpanList
.
size
(),
assertTraceTree
.
length
);
validateSpanData
(
bufferTraceSpanList
,
assertTraceTree
);
}
private
static
void
validateTraceSpanSize
(
int
actualSpanSize
,
int
expectedSpanSize
)
{
if
(
actualSpanSize
!=
expectedSpanSize
)
{
throw
new
RuntimeException
(
"expected span size : "
+
expectedSpanSize
+
"\n actual span size : "
+
actualSpanSize
);
}
}
private
static
void
validateSpanData
(
List
<
Span
>
traceSpanList
,
String
[][]
traceTree
)
{
}
private
static
void
validateTraceId
(
List
<
Span
>
traceSpanList
)
{
String
traceId
=
null
;
for
(
Span
span
:
traceSpanList
)
{
}
}
}
test/skywalking-test-api/src/main/java/test/com/ai/skywalking/api/TraceTreeDataAcquirer.java
已删除
100644 → 0
浏览文件 @
7b741cc2
package
test.com.ai.skywalking.api
;
import
com.ai.cloud.skywalking.protocol.Span
;
import
java.util.List
;
public
class
TraceTreeDataAcquirer
{
public
static
List
<
Span
>
acquireCurrentTraceSpanData
()
{
return
null
;
}
}
test/skywalking-test-api/src/main/java/test/com/ai/skywalking/test/api/TraceTreeAssert.java
0 → 100644
浏览文件 @
060afcb5
package
test.com.ai.skywalking.test.api
;
import
com.ai.cloud.skywalking.protocol.Span
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
public
class
TraceTreeAssert
{
public
static
void
assertEquals
(
String
[][]
expectedTraceTree
)
{
List
<
Span
>
spanDataInBuffer
=
TraceTreeDataAcquirer
.
acquireCurrentTraceSpanData
();
validateTraceId
(
spanDataInBuffer
);
Set
<
String
>
assertSpanData
=
distinctAndConvertSpanData
(
spanDataInBuffer
);
Set
<
String
>
expectedSpanData
=
distinctAndConvertSpanData
(
expectedTraceTree
);
validateTraceSpanSize
(
expectedSpanData
.
size
(),
assertSpanData
.
size
());
validateSpanData
(
expectedSpanData
,
assertSpanData
);
}
private
static
Set
<
String
>
distinctAndConvertSpanData
(
List
<
Span
>
assertSpanData
)
{
Set
<
String
>
resultSpanData
=
new
HashSet
<>();
for
(
Span
span
:
assertSpanData
)
{
StringBuffer
tmpSpanDataStr
=
new
StringBuffer
(
jointTraceLevelId
(
span
.
getParentLevel
(),
span
.
getLevelId
()
+
" "
));
tmpSpanDataStr
.
append
(
span
.
getViewPointId
().
trim
()
+
" "
)
.
append
(
span
.
getBusinessKey
().
trim
()
+
" "
);
resultSpanData
.
add
(
tmpSpanDataStr
.
toString
());
}
return
resultSpanData
;
}
private
static
String
jointTraceLevelId
(
String
parentLevelId
,
String
levelId
)
{
String
traceLevelId
=
""
;
if
(
parentLevelId
!=
null
&&
parentLevelId
.
length
()
>
0
)
{
traceLevelId
=
parentLevelId
+
"."
;
}
traceLevelId
+=
levelId
;
return
traceLevelId
;
}
private
static
Set
<
String
>
distinctAndConvertSpanData
(
String
[][]
assertTraceTree
)
{
Set
<
String
>
resultSpanData
=
new
HashSet
<
String
>();
for
(
String
[]
spanDataArray
:
assertTraceTree
)
{
if
(
spanDataArray
.
length
!=
4
)
{
throw
new
IllegalArgumentException
(
"assert trace tree is illegal, "
+
"Format :\tParentLevelId\t|\tlevelId\t|\tviewPoint\t|\tbusinesskey"
);
}
StringBuffer
tmpSpanDataStr
=
new
StringBuffer
(
jointTraceLevelId
(
spanDataArray
[
0
],
spanDataArray
[
1
])
+
" "
);
tmpSpanDataStr
.
append
(
spanDataArray
[
2
]
==
null
?
" "
:
spanDataArray
[
2
].
trim
()
+
" "
)
.
append
(
spanDataArray
[
3
]
==
null
?
" "
:
spanDataArray
[
3
].
trim
()
+
" "
);
resultSpanData
.
add
(
tmpSpanDataStr
.
toString
());
}
return
resultSpanData
;
}
private
static
void
validateTraceSpanSize
(
int
actualSpanSize
,
int
expectedSpanSize
)
{
if
(
actualSpanSize
!=
expectedSpanSize
)
{
throw
new
RuntimeException
(
"expected span size : "
+
expectedSpanSize
+
"\n actual span size : "
+
actualSpanSize
);
}
}
private
static
void
validateSpanData
(
Set
<
String
>
expectedSpanData
,
Set
<
String
>
assertTraceTree
)
{
for
(
String
assertSpanDataStr
:
assertTraceTree
)
{
if
(
expectedSpanData
.
contains
(
assertSpanDataStr
))
{
expectedSpanData
.
remove
(
assertSpanDataStr
);
}
}
if
(
expectedSpanData
.
size
()
!=
0
)
{
StringBuffer
stringBuffer
=
new
StringBuffer
();
for
(
String
expectedSpan
:
expectedSpanData
)
{
stringBuffer
.
append
(
expectedSpan
+
"\n"
);
}
throw
new
RuntimeException
(
"actual trace tree is not contain those span as follow:\n"
+
stringBuffer
);
}
}
private
static
void
validateTraceId
(
List
<
Span
>
traceSpanList
)
{
String
traceId
=
null
;
for
(
Span
span
:
traceSpanList
)
{
if
(
traceId
==
null
)
{
traceId
=
span
.
getTraceId
();
}
if
(!
traceId
.
equals
(
span
.
getTraceId
()))
{
throw
new
RuntimeException
(
"trace id is not all the same.trace id :"
+
traceId
+
",Error trace id :"
+
span
.
getTraceId
());
}
}
}
}
test/skywalking-test-api/src/main/java/test/com/ai/skywalking/test/api/TraceTreeDataAcquirer.java
0 → 100644
浏览文件 @
060afcb5
package
test.com.ai.skywalking.test.api
;
import
com.ai.cloud.skywalking.protocol.Span
;
import
test.com.ai.skywalking.test.api.config.Config
;
import
java.lang.reflect.Field
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
TraceTreeDataAcquirer
{
public
static
List
<
Span
>
acquireCurrentTraceSpanData
()
{
List
<
Span
>
resultSpan
=
new
ArrayList
<
Span
>();
Object
[]
bufferGroupObjectArray
=
acquireBufferGroupObjectArrayByClassLoader
();
for
(
Object
bufferGroup
:
bufferGroupObjectArray
)
{
Span
[]
spanList
=
acquireSpanData
(
bufferGroup
);
for
(
Span
span
:
spanList
)
{
if
(
span
!=
null
)
{
resultSpan
.
add
(
span
);
}
}
}
return
resultSpan
;
}
private
static
Span
[]
acquireSpanData
(
Object
bufferGroup
)
{
try
{
Class
bufferGroupClass
=
Thread
.
currentThread
().
getContextClassLoader
()
.
loadClass
(
Config
.
BUFFER_GROUP_CLASS_NAME
);
Field
spanArrayField
=
bufferGroupClass
.
getDeclaredField
(
Config
.
SPAN_ARRAY_FIELD_NAME
);
spanArrayField
.
setAccessible
(
true
);
return
(
Span
[])
spanArrayField
.
get
(
bufferGroup
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"Failed to acquire span array"
,
e
);
}
}
private
static
Object
[]
acquireBufferGroupObjectArrayByClassLoader
()
{
try
{
Class
bufferPoolClass
=
fetchBufferPoolClass
();
Field
field
=
fetchBufferPoolObject
(
bufferPoolClass
);
return
(
Object
[])
field
.
get
(
bufferPoolClass
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"Failed to acquire buffer group object array"
,
e
);
}
}
private
static
Field
fetchBufferPoolObject
(
Class
bufferPoolClass
)
throws
NoSuchFieldException
{
Field
field
=
bufferPoolClass
.
getDeclaredField
(
Config
.
BUFFER_GROUP_FIELD_NAME
);
field
.
setAccessible
(
true
);
return
field
;
}
private
static
Class
fetchBufferPoolClass
()
throws
ClassNotFoundException
{
ClassLoader
classLoader
=
Thread
.
currentThread
().
getContextClassLoader
();
return
classLoader
.
loadClass
(
Config
.
BUFFER_POOL_CLASS_NAME
);
}
}
test/skywalking-test-api/src/main/java/test/com/ai/skywalking/test/api/config/Config.java
0 → 100644
浏览文件 @
060afcb5
package
test.com.ai.skywalking.test.api.config
;
public
class
Config
{
public
static
String
BUFFER_POOL_CLASS_NAME
=
"com.ai.cloud.skywalking.buffer.ContextBuffer$BufferPool"
;
public
static
String
BUFFER_GROUP_FIELD_NAME
=
"bufferGroups"
;
public
static
String
BUFFER_GROUP_CLASS_NAME
=
"com.ai.cloud.skywalking.buffer.BufferGroup"
;
public
static
String
SPAN_ARRAY_FIELD_NAME
=
"dataBuffer"
;
}
test/skywalking-test-api/src/test/java/test/com/ai/skywalking/reflect/SubClassReflect.java
0 → 100644
浏览文件 @
060afcb5
package
test.com.ai.skywalking.reflect
;
import
org.junit.Test
;
import
java.lang.reflect.Field
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
/**
* Created by xin on 16-6-6.
*/
public
class
SubClassReflect
{
@Test
public
void
fetchSubClassField
()
throws
ClassNotFoundException
,
NoSuchFieldException
,
IllegalAccessException
{
ClassLoader
loader
=
Thread
.
currentThread
().
getContextClassLoader
();
Class
testSubClass
=
loader
.
loadClass
(
"test.com.ai.skywalking.reflect.TestClass$TestSubClass"
);
Field
field
=
testSubClass
.
getDeclaredField
(
"testStringArray"
);
assertNotNull
(
field
);
field
.
setAccessible
(
true
);
Object
[]
objects
=
(
Object
[])
field
.
get
(
testSubClass
);
assertEquals
(
5
,
objects
.
length
);
}
}
test/skywalking-test-api/src/test/java/test/com/ai/skywalking/reflect/TestClass.java
0 → 100644
浏览文件 @
060afcb5
package
test.com.ai.skywalking.reflect
;
public
class
TestClass
{
private
static
TestSubClass
testSubClass
=
new
TestSubClass
();
static
class
TestSubClass
{
private
static
String
[]
testStringArray
=
new
String
[
5
];
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录