-
Notifications
You must be signed in to change notification settings - Fork 83
adding test case for HTRACE-363 #9
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* 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.htrace.core; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class TestNewScopeWithParentID { | ||
|
||
@Test | ||
public void testNewScopeWithParentID() throws Exception { | ||
|
||
Tracer tracer = new Tracer.Builder(). | ||
name("testNewScopeWithParentID"). | ||
tracerPool(new TracerPool("testNewScopeWithParentID")). | ||
conf(HTraceConfiguration.fromKeyValuePairs( | ||
"sampler.classes", "AlwaysSampler")).build(); | ||
TraceScope activeScope = tracer.newScope("CurrentActiveScope"); | ||
SpanId parentID = new SpanId(100L, 200L); | ||
TraceScope childScope = tracer. | ||
newScope("ChildScope", parentID); | ||
Assert.assertNotNull(childScope); | ||
Assert.assertEquals(childScope.getSpan().getParents().length, 2); | ||
Assert.assertEquals(childScope.getSpan().getParents()[1].getHigh(), 100L); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Would prefer comparing against There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the order guaranteed? I'm not sure that it is, rather than being an implementation detail in this case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I debugged the code it always goes through this lines looks like there is order at least for this two parent case, private TraceScope newScopeImpl(ThreadContext context, String description, |
||
Assert.assertEquals(childScope.getSpan().getParents()[1].getLow(), 200L); | ||
//SpanID generated by invoking fromRandom() | ||
Assert.assertNotNull(childScope.getSpan().getParents()[0].getHigh()); | ||
Assert.assertNotNull(childScope.getSpan().getParents()[0].getLow()); | ||
Assert.assertEquals(childScope.getSpan().getParents()[0].getHigh(), | ||
activeScope.getSpan().getSpanId().getHigh()); | ||
Assert.assertEquals(childScope.getSpan().getParents()[0].getLow(), | ||
activeScope.getSpan().getSpanId().getLow()); | ||
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use the form of assert that takes a descriptive message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review. I will add those.