Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
山不在高_有仙则灵
SkyWalking
提交
2af29ed5
S
SkyWalking
项目概览
山不在高_有仙则灵
/
SkyWalking
与 Fork 源项目一致
Fork自
apache / SkyWalking
通知
12
Star
0
Fork
2
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
2af29ed5
编写于
7月 07, 2017
作者:
wu-sheng
提交者:
GitHub
7月 07, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #274 from ascrutae/zhangxin/fix/support-test-case
fix issue that project cycle dependency
上级
408d5709
f81a66bf
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
216 addition
and
24 deletion
+216
-24
apm-sniffer/apm-agent-core/pom.xml
apm-sniffer/apm-agent-core/pom.xml
+0
-6
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/TraceSegmentRef.java
...walking/apm/agent/core/context/trace/TraceSegmentRef.java
+2
-2
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/ContextManagerTest.java
...skywalking/apm/agent/core/context/ContextManagerTest.java
+6
-12
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/IgnoredTracerContextTest.java
...king/apm/agent/core/context/IgnoredTracerContextTest.java
+3
-3
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/util/AbstractTracingSpanHelper.java
...pm/agent/core/context/util/AbstractTracingSpanHelper.java
+26
-0
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/util/FieldGetter.java
...g/skywalking/apm/agent/core/context/util/FieldGetter.java
+19
-0
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/util/SegmentHelper.java
...skywalking/apm/agent/core/context/util/SegmentHelper.java
+17
-0
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/util/SegmentStorage.java
...kywalking/apm/agent/core/context/util/SegmentStorage.java
+32
-0
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/util/SegmentStoragePoint.java
...king/apm/agent/core/context/util/SegmentStoragePoint.java
+11
-0
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/util/TraceSegmentRefHelper.java
...ng/apm/agent/core/context/util/TraceSegmentRefHelper.java
+14
-0
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/util/TracingSegmentRunner.java
...ing/apm/agent/core/context/util/TracingSegmentRunner.java
+86
-0
apm-sniffer/apm-test-tools/src/main/java/org/skywalking/apm/agent/test/helper/AbstractTracingSpanHelper.java
...king/apm/agent/test/helper/AbstractTracingSpanHelper.java
+0
-1
未找到文件。
apm-sniffer/apm-agent-core/pom.xml
浏览文件 @
2af29ed5
...
...
@@ -77,12 +77,6 @@
<version>
${jetty.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.skywalking
</groupId>
<artifactId>
apm-test-tools
</artifactId>
<version>
${project.version}
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
<build>
<extensions>
...
...
apm-sniffer/apm-agent-core/src/main/java/org/skywalking/apm/agent/core/context/trace/TraceSegmentRef.java
浏览文件 @
2af29ed5
...
...
@@ -69,7 +69,7 @@ public class TraceSegmentRef {
public
TraceSegmentReference
transform
()
{
TraceSegmentReference
.
Builder
refBuilder
=
TraceSegmentReference
.
newBuilder
();
if
(
SegmentRefType
.
CROSS_PROCESS
.
equals
(
type
))
{
if
(
SegmentRefType
.
CROSS_PROCESS
.
equals
(
type
))
{
refBuilder
.
setRefType
(
RefType
.
CrossProcess
);
refBuilder
.
setParentApplicationInstanceId
(
applicationInstanceId
);
if
(
peerId
==
DictionaryUtil
.
nullValue
())
{
...
...
@@ -82,7 +82,7 @@ public class TraceSegmentRef {
}
else
{
refBuilder
.
setEntryServiceId
(
operationId
);
}
}
else
{
}
else
{
refBuilder
.
setRefType
(
RefType
.
CrossThread
);
}
refBuilder
.
setParentTraceSegmentId
(
traceSegmentId
);
...
...
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/ContextManagerTest.java
浏览文件 @
2af29ed5
package
org.skywalking.apm.agent.core.context
;
import
java.lang.reflect.Field
;
import
java.util.List
;
import
java.util.Map
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
...
...
@@ -17,14 +15,13 @@ import org.skywalking.apm.agent.core.context.trace.LogDataEntity;
import
org.skywalking.apm.agent.core.context.trace.SpanLayer
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegment
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegmentRef
;
import
org.skywalking.apm.agent.core.context.util.AbstractTracingSpanHelper
;
import
org.skywalking.apm.agent.core.context.util.SegmentHelper
;
import
org.skywalking.apm.agent.core.context.util.SegmentStorage
;
import
org.skywalking.apm.agent.core.context.util.SegmentStoragePoint
;
import
org.skywalking.apm.agent.core.context.util.TraceSegmentRefHelper
;
import
org.skywalking.apm.agent.core.context.util.TracingSegmentRunner
;
import
org.skywalking.apm.agent.core.dictionary.DictionaryUtil
;
import
org.skywalking.apm.agent.core.dictionary.OperationNameDictionary
;
import
org.skywalking.apm.agent.test.helper.AbstractTracingSpanHelper
;
import
org.skywalking.apm.agent.test.helper.SegmentHelper
;
import
org.skywalking.apm.agent.test.helper.TraceSegmentRefHelper
;
import
org.skywalking.apm.agent.test.tools.SegmentStorage
;
import
org.skywalking.apm.agent.test.tools.SegmentStoragePoint
;
import
org.skywalking.apm.agent.test.tools.TracingSegmentRunner
;
import
org.skywalking.apm.network.trace.component.ComponentsDefine
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
...
...
@@ -128,7 +125,6 @@ public class ContextManagerTest {
assertThat
(
injectContextCarrier
.
getSpanId
(),
is
(
1
));
assertThat
(
injectContextCarrier
.
getEntryOperationName
(),
is
(
"#/portal/"
));
assertThat
(
injectContextCarrier
.
getApplicationId
(),
is
(
1
));
assertThat
(
injectContextCarrier
.
getPeerHost
(),
is
(
"#127.0.0.1:12800"
));
}
...
...
@@ -175,12 +171,10 @@ public class ContextManagerTest {
assertThat
(
AbstractTracingSpanHelper
.
getParentSpanId
(
actualEntrySpan
),
is
(-
1
));
assertThat
(
firstExitSpanContextCarrier
.
getPeerHost
(),
is
(
"#127.0.0.1:8080"
));
assertThat
(
firstExitSpanContextCarrier
.
getApplicationId
(),
is
(
1
));
assertThat
(
firstExitSpanContextCarrier
.
getSpanId
(),
is
(
1
));
assertThat
(
firstExitSpanContextCarrier
.
getEntryOperationName
(),
is
(
"#/testEntrySpan"
));
assertThat
(
secondExitSpanContextCarrier
.
getPeerHost
(),
is
(
"#127.0.0.1:8080"
));
assertThat
(
secondExitSpanContextCarrier
.
getApplicationId
(),
is
(
1
));
assertThat
(
secondExitSpanContextCarrier
.
getSpanId
(),
is
(
1
));
assertThat
(
secondExitSpanContextCarrier
.
getEntryOperationName
(),
is
(
"#/testEntrySpan"
));
...
...
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/IgnoredTracerContextTest.java
浏览文件 @
2af29ed5
...
...
@@ -10,9 +10,9 @@ import org.skywalking.apm.agent.core.conf.Config;
import
org.skywalking.apm.agent.core.conf.RemoteDownstreamConfig
;
import
org.skywalking.apm.agent.core.context.trace.AbstractSpan
;
import
org.skywalking.apm.agent.core.context.trace.NoopSpan
;
import
org.skywalking.apm.agent.
test.tools
.SegmentStorage
;
import
org.skywalking.apm.agent.
test.tools
.SegmentStoragePoint
;
import
org.skywalking.apm.agent.
test.tools
.TracingSegmentRunner
;
import
org.skywalking.apm.agent.
core.context.util
.SegmentStorage
;
import
org.skywalking.apm.agent.
core.context.util
.SegmentStoragePoint
;
import
org.skywalking.apm.agent.
core.context.util
.TracingSegmentRunner
;
import
static
junit
.
framework
.
TestCase
.
assertNull
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
...
...
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/util/AbstractTracingSpanHelper.java
0 → 100644
浏览文件 @
2af29ed5
package
org.skywalking.apm.agent.core.context.util
;
import
java.util.Collections
;
import
java.util.List
;
import
org.skywalking.apm.agent.core.context.trace.AbstractTracingSpan
;
import
org.skywalking.apm.agent.core.context.trace.LogDataEntity
;
public
class
AbstractTracingSpanHelper
{
public
static
int
getParentSpanId
(
AbstractTracingSpan
tracingSpan
)
{
try
{
return
FieldGetter
.
getParentFieldValue
(
tracingSpan
,
"parentSpanId"
);
}
catch
(
Exception
e
)
{
}
return
-
9999
;
}
public
static
List
<
LogDataEntity
>
getLogs
(
AbstractTracingSpan
tracingSpan
)
{
try
{
return
FieldGetter
.
getParentFieldValue
(
tracingSpan
,
"logs"
);
}
catch
(
Exception
e
)
{
}
return
Collections
.
emptyList
();
}
}
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/util/FieldGetter.java
0 → 100644
浏览文件 @
2af29ed5
package
org.skywalking.apm.agent.core.context.util
;
import
java.lang.reflect.Field
;
public
class
FieldGetter
{
public
static
<
T
>
T
getValue
(
Object
instance
,
String
fieldName
)
throws
IllegalAccessException
,
NoSuchFieldException
{
Field
field
=
instance
.
getClass
().
getDeclaredField
(
fieldName
);
field
.
setAccessible
(
true
);
return
(
T
)
field
.
get
(
instance
);
}
public
static
<
T
>
T
getParentFieldValue
(
Object
instance
,
String
fieldName
)
throws
IllegalAccessException
,
NoSuchFieldException
{
Field
field
=
instance
.
getClass
().
getSuperclass
().
getDeclaredField
(
fieldName
);
field
.
setAccessible
(
true
);
return
(
T
)
field
.
get
(
instance
);
}
}
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/util/SegmentHelper.java
0 → 100644
浏览文件 @
2af29ed5
package
org.skywalking.apm.agent.core.context.util
;
import
java.util.List
;
import
org.skywalking.apm.agent.core.context.trace.AbstractTracingSpan
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegment
;
public
class
SegmentHelper
{
public
static
List
<
AbstractTracingSpan
>
getSpan
(
TraceSegment
traceSegment
)
{
try
{
return
FieldGetter
.
getValue
(
traceSegment
,
"spans"
);
}
catch
(
Exception
e
)
{
}
return
null
;
}
}
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/util/SegmentStorage.java
0 → 100644
浏览文件 @
2af29ed5
package
org.skywalking.apm.agent.core.context.util
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.skywalking.apm.agent.core.context.IgnoredTracerContext
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegment
;
public
class
SegmentStorage
{
private
LinkedList
<
TraceSegment
>
traceSegments
;
private
LinkedList
<
IgnoredTracerContext
>
ignoredTracerContexts
;
SegmentStorage
()
{
traceSegments
=
new
LinkedList
<
TraceSegment
>();
ignoredTracerContexts
=
new
LinkedList
<
IgnoredTracerContext
>();
}
void
addTraceSegment
(
TraceSegment
segment
)
{
traceSegments
.
add
(
segment
);
}
public
List
<
TraceSegment
>
getTraceSegments
()
{
return
traceSegments
;
}
void
addIgnoreTraceContext
(
IgnoredTracerContext
context
)
{
this
.
ignoredTracerContexts
.
add
(
context
);
}
public
LinkedList
<
IgnoredTracerContext
>
getIgnoredTracerContexts
()
{
return
ignoredTracerContexts
;
}
}
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/util/SegmentStoragePoint.java
0 → 100644
浏览文件 @
2af29ed5
package
org.skywalking.apm.agent.core.context.util
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
(
ElementType
.
FIELD
)
public
@interface
SegmentStoragePoint
{
}
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/util/TraceSegmentRefHelper.java
0 → 100644
浏览文件 @
2af29ed5
package
org.skywalking.apm.agent.core.context.util
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegmentRef
;
public
class
TraceSegmentRefHelper
{
public
static
String
getPeerHost
(
TraceSegmentRef
ref
)
{
try
{
return
FieldGetter
.
getValue
(
ref
,
"peerHost"
);
}
catch
(
Exception
e
)
{
}
return
null
;
}
}
apm-sniffer/apm-agent-core/src/test/java/org/skywalking/apm/agent/core/context/util/TracingSegmentRunner.java
0 → 100644
浏览文件 @
2af29ed5
package
org.skywalking.apm.agent.core.context.util
;
import
java.lang.reflect.Field
;
import
org.junit.runner.Description
;
import
org.junit.runner.notification.Failure
;
import
org.junit.runner.notification.RunNotifier
;
import
org.junit.runners.BlockJUnit4ClassRunner
;
import
org.junit.runners.model.InitializationError
;
import
org.skywalking.apm.agent.core.context.IgnoreTracerContextListener
;
import
org.skywalking.apm.agent.core.context.IgnoredTracerContext
;
import
org.skywalking.apm.agent.core.context.TracingContext
;
import
org.skywalking.apm.agent.core.context.TracingContextListener
;
import
org.skywalking.apm.agent.core.context.trace.TraceSegment
;
public
class
TracingSegmentRunner
extends
BlockJUnit4ClassRunner
{
private
TracingContextListener
tracingContextListener
;
private
IgnoreTracerContextListener
ignoreTracerContextListener
;
private
Field
field
;
private
Object
targetObject
;
private
SegmentStorage
tracingData
;
public
TracingSegmentRunner
(
Class
<?>
klass
)
throws
InitializationError
{
super
(
klass
);
for
(
Field
field
:
klass
.
getDeclaredFields
())
{
if
(
field
.
isAnnotationPresent
(
SegmentStoragePoint
.
class
)
&&
field
.
getType
().
equals
(
SegmentStorage
.
class
))
{
this
.
field
=
field
;
this
.
field
.
setAccessible
(
true
);
break
;
}
}
}
@Override
protected
Object
createTest
()
throws
Exception
{
targetObject
=
super
.
createTest
();
return
targetObject
;
}
@Override
public
void
run
(
RunNotifier
notifier
)
{
notifier
.
addListener
(
new
RunListener
());
super
.
run
(
notifier
);
}
class
RunListener
extends
org
.
junit
.
runner
.
notification
.
RunListener
{
@Override
public
void
testStarted
(
Description
description
)
throws
Exception
{
if
(
field
!=
null
)
{
try
{
tracingData
=
new
SegmentStorage
();
field
.
set
(
targetObject
,
tracingData
);
}
catch
(
IllegalAccessException
e
)
{
}
}
tracingContextListener
=
new
TracingContextListener
()
{
@Override
public
void
afterFinished
(
TraceSegment
traceSegment
)
{
tracingData
.
addTraceSegment
(
traceSegment
);
}
};
ignoreTracerContextListener
=
new
IgnoreTracerContextListener
()
{
@Override
public
void
afterFinished
(
IgnoredTracerContext
tracerContext
)
{
tracingData
.
addIgnoreTraceContext
(
tracerContext
);
}
};
TracingContext
.
ListenerManager
.
add
(
tracingContextListener
);
IgnoredTracerContext
.
ListenerManager
.
add
(
ignoreTracerContextListener
);
super
.
testStarted
(
description
);
}
@Override
public
void
testFinished
(
Description
description
)
throws
Exception
{
super
.
testFinished
(
description
);
TracingContext
.
ListenerManager
.
remove
(
tracingContextListener
);
IgnoredTracerContext
.
ListenerManager
.
remove
(
ignoreTracerContextListener
);
}
@Override
public
void
testFailure
(
Failure
failure
)
throws
Exception
{
super
.
testFailure
(
failure
);
TracingContext
.
ListenerManager
.
remove
(
tracingContextListener
);
}
}
}
apm-sniffer/apm-test-tools/src/main/java/org/skywalking/apm/agent/test/helper/AbstractTracingSpanHelper.java
浏览文件 @
2af29ed5
...
...
@@ -4,7 +4,6 @@ import java.util.Collections;
import
java.util.List
;
import
org.skywalking.apm.agent.core.context.trace.AbstractTracingSpan
;
import
org.skywalking.apm.agent.core.context.trace.LogDataEntity
;
import
org.skywalking.apm.agent.core.context.util.KeyValuePair
;
public
class
AbstractTracingSpanHelper
{
public
static
int
getParentSpanId
(
AbstractTracingSpan
tracingSpan
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录