Skip to content

Commit

Permalink
[server] Stop creating separate trace instances when generating posti…
Browse files Browse the repository at this point in the history
…ng traces

A separate trace instance was created to provide metadata info when a trace
is queried. This commit removed the creation of that separate instance and
open provide metadata info when the experiment is created.
  • Loading branch information
Siwei Zhang authored and bhufmann committed Oct 4, 2024
1 parent 149d2d7 commit 96d0cd5
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 76 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023 Ericsson
* Copyright (c) 2023, 2024 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License 2.0 which
Expand Down Expand Up @@ -256,7 +256,7 @@ public void testXmlDataProvider() {
TmfConfigurationStub config = response.readEntity(CONFIGURATION);
validateConfig(config);
}
ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_KERNEL_STUB.getName(), CONTEXT_SWITCHES_KERNEL_STUB);
ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB.getName(), CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB);
WebTarget xmlProviderPath = getXYTreeEndpoint(exp.getUUID().toString(), "org.eclipse.linuxtools.tmf.analysis.xml.core.tests.xy");
Map<String, Object> parameters = new HashMap<>();
try (Response xmlTree = xmlProviderPath.request().post(Entity.json(new QueryParameters(parameters, Collections.emptyList())))) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2021 Ericsson and others
* Copyright (c) 2018, 2024 Ericsson and others
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License 2.0 which
Expand Down Expand Up @@ -125,7 +125,7 @@ public class DataProviderServiceTest extends RestServerTest {
*/
@Test
public void testProviders() {
ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_STUB.getName(), CONTEXT_SWITCHES_UST_STUB);
ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB.getName(), CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB);

WebTarget experiments = getApplicationEndpoint().path(EXPERIMENTS);
WebTarget providers = experiments.path(exp.getUUID().toString())
Expand All @@ -142,7 +142,7 @@ public void testProviders() {
*/
@Test
public void testCallStackDataProvider() {
ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_STUB.getName(), CONTEXT_SWITCHES_UST_STUB);
ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB.getName(), CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB);

WebTarget callstackTree = getTimeGraphTreeEndpoint(exp.getUUID().toString(), CALL_STACK_DATAPROVIDER_ID);

Expand All @@ -168,7 +168,7 @@ public void testXYDataProvider() throws InterruptedException {
long start = 1412670961211260539L;
long end = 1412670967217750839L;
try {
ExperimentModelStub exp = assertPostExperiment(ARM_64_KERNEL_STUB.getName(), ARM_64_KERNEL_STUB);
ExperimentModelStub exp = assertPostExperiment(ARM_64_KERNEL_NOT_INITIALIZED_STUB.getName(), ARM_64_KERNEL_NOT_INITIALIZED_STUB);

// Test getting the tree endpoint for an XY chart
WebTarget xyTree = getXYTreeEndpoint(exp.getUUID().toString(), XY_DATAPROVIDER_ID);
Expand Down Expand Up @@ -250,7 +250,7 @@ public void testHistogramDataProvider() throws InterruptedException {
long start = 1412670961211260539L;
long end = 1412670967217750839L;
try {
ExperimentModelStub exp = assertPostExperiment(ARM_64_KERNEL_STUB.getName(), ARM_64_KERNEL_STUB);
ExperimentModelStub exp = assertPostExperiment(ARM_64_KERNEL_NOT_INITIALIZED_STUB.getName(), ARM_64_KERNEL_NOT_INITIALIZED_STUB);

// Test getting the tree endpoint for an XY chart
WebTarget xyTree = getXYTreeEndpoint(exp.getUUID().toString(), XY_HISTOGRAM_DATAPROVIDER_ID);
Expand Down Expand Up @@ -312,7 +312,7 @@ public void testDataTreeDataProvider() throws InterruptedException {
long start = 1450193697034689597L;
long end = 1450193745774189602L;
try {
ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_STUB.getName(), CONTEXT_SWITCHES_UST_STUB);
ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB.getName(), CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB);

// Test getting the time graph tree
WebTarget dataTree = getDataTreeEndpoint(exp.getUUID().toString(), STATISTICS_DATAPROVIDER_ID);
Expand Down Expand Up @@ -363,7 +363,7 @@ public void testTimeGraphDataProvider() throws InterruptedException {
long start = 1450193697034689597L;
long end = 1450193745774189602L;
try {
ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_STUB.getName(), CONTEXT_SWITCHES_UST_STUB);
ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB.getName(), CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB);

// Test getting the time graph tree
WebTarget callstackTree = getTimeGraphTreeEndpoint(exp.getUUID().toString(), CALL_STACK_DATAPROVIDER_ID);
Expand Down Expand Up @@ -534,7 +534,7 @@ public void testTableDataProvider() throws InterruptedException {
long start = 1412670961211260539L;
long end = 1412670967217750839L;
try {
ExperimentModelStub exp = assertPostExperiment(ARM_64_KERNEL_STUB.getName(), ARM_64_KERNEL_STUB);
ExperimentModelStub exp = assertPostExperiment(ARM_64_KERNEL_NOT_INITIALIZED_STUB.getName(), ARM_64_KERNEL_NOT_INITIALIZED_STUB);

// Test getting the tree endpoint for an XY chart
WebTarget tableColumns = getTableColumnsEndpoint(exp.getUUID().toString(), EVENTS_TABLE_DATAPROVIDER_ID);
Expand Down Expand Up @@ -605,7 +605,7 @@ public void testTableDataProvider() throws InterruptedException {
public void testTimeGraphMetaDataSerializer() {
Response treeResponse = null;
try {
ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_STUB.getName(), CONTEXT_SWITCHES_UST_STUB);
ExperimentModelStub exp = assertPostExperiment(CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB.getName(), CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB);

// Test getting the time graph tree
WebTarget callstackTree = getTimeGraphTreeEndpoint(exp.getUUID().toString(), TestDataProviderService.INVALID_ENTRY_METADATA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class ExperimentManagerServiceTest extends RestServerTest {

private static final String TEST = "test";
private static final @NonNull ImmutableSet<TraceModelStub> CONTEXT_SWITCH_SET = ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_STUB, CONTEXT_SWITCHES_UST_STUB);
private static final @NonNull ImmutableSet<TraceModelStub> CONTEXT_SWITCH_NOT_INITIALIZED_SET = ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB, CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB);
private static final @NonNull ExperimentModelStub EXPECTED = new ExperimentModelStub(TEST, CONTEXT_SWITCH_SET);

/**
Expand All @@ -71,9 +72,9 @@ public void testExperiment() {
WebTarget traces = application.path(TRACES);
WebTarget expTarget = application.path(EXPERIMENTS);

TraceModelStub ustStub = assertPost(traces, CONTEXT_SWITCHES_UST_STUB);
TraceModelStub kernelStub = assertPost(traces, CONTEXT_SWITCHES_KERNEL_STUB);
assertEquals(CONTEXT_SWITCH_SET, getTraces(traces));
TraceModelStub ustStub = assertPost(traces, CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB);
TraceModelStub kernelStub = assertPost(traces, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB);
assertEquals(CONTEXT_SWITCH_NOT_INITIALIZED_SET, getTraces(traces));

assertEquals("experiment set should be empty at this point", Collections.emptySet(), getExperiments(expTarget));

Expand All @@ -89,12 +90,12 @@ public void testExperiment() {
ExperimentModelStub expStub = response.readEntity(ExperimentModelStub.class);
assertEquals("Failed to POST the experiment", EXPECTED, expStub);
assertEquals("Failed to add experiment to set of experiments", Collections.singleton(EXPECTED), getExperiments(expTarget));
assertEquals("Adding an experiment should not change the trace set", CONTEXT_SWITCH_SET, getTraces(traces));
assertEquals("Adding an experiment should not change the trace set", CONTEXT_SWITCH_NOT_INITIALIZED_SET, getTraces(traces));
assertEquals("Failed to get the experiment by its UUID", EXPECTED, expTarget.path(expStub.getUUID().toString()).request().get(ExperimentModelStub.class));

assertEquals("Failed to DELETE the experiment", EXPECTED, expTarget.path(expStub.getUUID().toString()).request().delete().readEntity(ExperimentModelStub.class));
assertEquals("experiment set should be empty at this point", Collections.emptySet(), getExperiments(expTarget));
assertEquals("Deleting an experiment should not change the trace set", CONTEXT_SWITCH_SET, getTraces(traces));
assertEquals("Deleting an experiment should not change the trace set", CONTEXT_SWITCH_NOT_INITIALIZED_SET, getTraces(traces));
response.close();
}

Expand All @@ -107,9 +108,9 @@ public void testRePost() {
WebTarget traces = application.path(TRACES);
WebTarget expTarget = application.path(EXPERIMENTS);

TraceModelStub ustStub = assertPost(traces, CONTEXT_SWITCHES_UST_STUB);
TraceModelStub kernelStub = assertPost(traces, CONTEXT_SWITCHES_KERNEL_STUB);
assertEquals(null, CONTEXT_SWITCH_SET, getTraces(traces));
TraceModelStub ustStub = assertPost(traces, CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB);
TraceModelStub kernelStub = assertPost(traces, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB);
assertEquals(CONTEXT_SWITCH_NOT_INITIALIZED_SET, getTraces(traces));

assertEquals("experiment set should be empty at this point", Collections.emptySet(), getExperiments(expTarget));

Expand All @@ -125,7 +126,7 @@ public void testRePost() {
ExperimentModelStub expStub = response.readEntity(ExperimentModelStub.class);
assertEquals("Failed to POST the experiment", EXPECTED, expStub);
assertEquals("Failed to add experiment to set of experiments", Collections.singleton(EXPECTED), getExperiments(expTarget));
assertEquals("Adding an experiment should not change the trace set", CONTEXT_SWITCH_SET, getTraces(traces));
assertEquals("Adding an experiment should not change the trace set", CONTEXT_SWITCH_NOT_INITIALIZED_SET, getTraces(traces));
assertEquals("Failed to get the experiment by its UUID", EXPECTED, expTarget.path(expStub.getUUID().toString()).request().get(ExperimentModelStub.class));
response.close();

Expand All @@ -135,13 +136,13 @@ public void testRePost() {
assertEquals("Status of second post", Status.OK.getStatusCode(), response2.getStatus());
assertEquals("Failed to POST the experiment a second time", EXPECTED, expStub2);
assertEquals("There should still be only one experiment", Collections.singleton(EXPECTED), getExperiments(expTarget));
assertEquals("Adding an experiment should not change the trace set", CONTEXT_SWITCH_SET, getTraces(traces));
assertEquals("Adding an experiment should not change the trace set", CONTEXT_SWITCH_NOT_INITIALIZED_SET, getTraces(traces));
assertEquals("Failed to get the experiment by its UUID", EXPECTED, expTarget.path(expStub2.getUUID().toString()).request().get(ExperimentModelStub.class));
response2.close();

assertEquals("Failed to DELETE the experiment", EXPECTED, expTarget.path(expStub.getUUID().toString()).request().delete().readEntity(ExperimentModelStub.class));
assertEquals("experiment set should be empty at this point", Collections.emptySet(), getExperiments(expTarget));
assertEquals("Deleting an experiment should not change the trace set", CONTEXT_SWITCH_SET, getTraces(traces));
assertEquals("Deleting an experiment should not change the trace set", CONTEXT_SWITCH_NOT_INITIALIZED_SET, getTraces(traces));

}

Expand All @@ -154,10 +155,10 @@ public void testPostConflicts() {
WebTarget traces = application.path(TRACES);
WebTarget expTarget = application.path(EXPERIMENTS);

TraceModelStub ustStub = assertPost(traces, CONTEXT_SWITCHES_UST_STUB);
TraceModelStub kernelStub = assertPost(traces, CONTEXT_SWITCHES_KERNEL_STUB);
TraceModelStub arm64Stub = assertPost(traces, ARM_64_KERNEL_STUB);
ImmutableSet<TraceModelStub> traceSet = ImmutableSet.of(CONTEXT_SWITCHES_UST_STUB, CONTEXT_SWITCHES_KERNEL_STUB, ARM_64_KERNEL_STUB);
TraceModelStub ustStub = assertPost(traces, CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB);
TraceModelStub kernelStub = assertPost(traces, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB);
TraceModelStub arm64Stub = assertPost(traces, ARM_64_KERNEL_NOT_INITIALIZED_STUB);
ImmutableSet<TraceModelStub> traceSet = ImmutableSet.of(CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB, ARM_64_KERNEL_NOT_INITIALIZED_STUB);
assertEquals(null, traceSet, getTraces(traces));

assertEquals("experiment set should be empty at this point", Collections.emptySet(), getExperiments(expTarget));
Expand Down Expand Up @@ -226,8 +227,8 @@ public void testWorkspaceStructure() throws CoreException, IOException {
WebTarget tracesTarget = applicationTarget.path(TRACES);
WebTarget experimentsTarget = applicationTarget.path(EXPERIMENTS);

TraceModelStub ustStub = assertPost(tracesTarget, CONTEXT_SWITCHES_UST_STUB);
TraceModelStub kernelStub = assertPost(tracesTarget, CONTEXT_SWITCHES_KERNEL_STUB);
TraceModelStub ustStub = assertPost(tracesTarget, CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB);
TraceModelStub kernelStub = assertPost(tracesTarget, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB);

List<String> traceUUIDs = new ArrayList<>();
traceUUIDs.add(ustStub.getUUID().toString());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2020 Ericsson
* Copyright (c) 2018, 2024 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License 2.0 which
Expand Down Expand Up @@ -57,17 +57,17 @@ public void testWithOneTrace() {

assertTrue("Expected empty set of traces", getTraces(traces).isEmpty());

TraceModelStub kernelStub = assertPost(traces, CONTEXT_SWITCHES_KERNEL_STUB);
TraceModelStub kernelStub = assertPost(traces, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB);

assertEquals(CONTEXT_SWITCHES_KERNEL_STUB, traces.path(kernelStub.getUUID().toString()).request().get(TraceModelStub.class));
assertEquals(CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB, traces.path(kernelStub.getUUID().toString()).request().get(TraceModelStub.class));

assertEquals("Expected set of traces to contain trace2 stub",
Collections.singleton(CONTEXT_SWITCHES_KERNEL_STUB), getTraces(traces));
Collections.singleton(CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB), getTraces(traces));

Response deleteResponse = traces.path(kernelStub.getUUID().toString()).request().delete();
int deleteCode = deleteResponse.getStatus();
assertEquals("Failed to DELETE trace2, error code=" + deleteCode, 200, deleteCode);
assertEquals(CONTEXT_SWITCHES_KERNEL_STUB, deleteResponse.readEntity(TraceModelStub.class));
assertEquals(CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB, deleteResponse.readEntity(TraceModelStub.class));

assertEquals("Trace should have been deleted", Collections.emptySet(), getTraces(traces));
}
Expand All @@ -79,10 +79,10 @@ public void testWithOneTrace() {
public void testWithTwoTraces() {
WebTarget traces = getApplicationEndpoint().path(TRACES);

assertPost(traces, CONTEXT_SWITCHES_KERNEL_STUB);
assertPost(traces, CONTEXT_SWITCHES_UST_STUB);
assertPost(traces, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB);
assertPost(traces, CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB);

assertEquals(ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_STUB, CONTEXT_SWITCHES_UST_STUB), getTraces(traces));
assertEquals(ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB, CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB), getTraces(traces));
}

/**
Expand All @@ -93,17 +93,17 @@ public void testWithTwoTraces() {
public void testConflictingTraces() throws IOException {
WebTarget traces = getApplicationEndpoint().path(TRACES);

assertPost(traces, CONTEXT_SWITCHES_KERNEL_STUB);
assertEquals(ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_STUB), getTraces(traces));
assertPost(traces, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB);
assertEquals(ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB), getTraces(traces));

// Post the trace a second time
assertPost(traces, CONTEXT_SWITCHES_KERNEL_STUB);
assertEquals(ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_STUB), getTraces(traces));
assertPost(traces, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB);
assertEquals(ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB), getTraces(traces));

// Post a trace with the same name but another path, the name does not
// matter if the path is different, the trace will be added
assertPost(traces, ARM_64_KERNEL_STUB);
assertEquals(ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_STUB, ARM_64_KERNEL_STUB), getTraces(traces));
assertPost(traces, ARM_64_KERNEL_NOT_INITIALIZED_STUB);
assertEquals(ImmutableSet.of(CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB, ARM_64_KERNEL_NOT_INITIALIZED_STUB), getTraces(traces));
}

/**
Expand All @@ -118,8 +118,8 @@ public void testConflictingTraces() throws IOException {
public void testWorkspaceStructure() throws CoreException, IOException {
WebTarget traces = getApplicationEndpoint().path(TRACES);

assertPost(traces, CONTEXT_SWITCHES_KERNEL_STUB);
assertPost(traces, CONTEXT_SWITCHES_UST_STUB);
assertPost(traces, CONTEXT_SWITCHES_KERNEL_NOT_INITIALIZED_STUB);
assertPost(traces, CONTEXT_SWITCHES_UST_NOT_INITIALIZED_STUB);

IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

Expand Down
Loading

0 comments on commit 96d0cd5

Please sign in to comment.