Skip to content

Commit 29d6edf

Browse files
committed
Avoid session test customization instantiation in remote execution #903
Currently, the SessionTestExtension with all its customizations is not only instantiated in the test-executing host application but also in every remote Eclipse application that is started to run a test case in an isolated session. Even though the current implementation already considers this during execution of the extensions and accesses to the customizations, it would be preferable to even only instantiate them if required. This change introduces dummy implementations for the session test customizations that are used during remote execution to avoid unnecessary overhead. Contributes to #903
1 parent c7b3002 commit 29d6edf

File tree

5 files changed

+130
-1
lines changed

5 files changed

+130
-1
lines changed

runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/session/CustomSessionConfiguration.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*******************************************************************************/
1111
package org.eclipse.core.tests.harness.session;
1212

13+
import java.io.IOException;
1314
import java.nio.file.Path;
1415
import org.eclipse.core.tests.harness.session.customization.SessionCustomization;
1516
import org.osgi.framework.Bundle;
@@ -20,6 +21,11 @@
2021
*/
2122
public interface CustomSessionConfiguration extends SessionCustomization {
2223

24+
/**
25+
* {@return the path of the used configuration directory}
26+
*/
27+
public Path getConfigurationDirectory() throws IOException;
28+
2329
/**
2430
* Sets the given configuration directory. If not called, a temporary folder is
2531
* used as the configuration directory.

runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/session/SessionTestExtension.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
import java.util.Objects;
1515
import java.util.Set;
1616
import org.eclipse.core.runtime.Platform;
17+
import org.eclipse.core.tests.harness.session.customization.CustomSessionConfigurationDummy;
1718
import org.eclipse.core.tests.harness.session.customization.CustomSessionConfigurationImpl;
19+
import org.eclipse.core.tests.harness.session.customization.CustomSessionWorkspaceDummy;
1820
import org.eclipse.core.tests.harness.session.customization.CustomSessionWorkspaceImpl;
1921
import org.eclipse.core.tests.harness.session.customization.SessionCustomization;
2022
import org.eclipse.core.tests.harness.session.samples.SampleSessionTests;
@@ -186,6 +188,9 @@ public SessionTestExtension create() {
186188
* folder to store the workspace files}
187189
*/
188190
public static CustomSessionWorkspace createCustomWorkspace() {
191+
if (RemoteTestExecutor.isRemoteExecution()) {
192+
return new CustomSessionWorkspaceDummy();
193+
}
189194
return new CustomSessionWorkspaceImpl();
190195
}
191196

@@ -194,6 +199,9 @@ public static CustomSessionWorkspace createCustomWorkspace() {
194199
* temporary folder to store the configuration files}
195200
*/
196201
public static CustomSessionConfiguration createCustomConfiguration() {
202+
if (RemoteTestExecutor.isRemoteExecution()) {
203+
return new CustomSessionConfigurationDummy();
204+
}
197205
return new CustomSessionConfigurationImpl();
198206
}
199207

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 Vector Informatik GmbH and others.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License v2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*******************************************************************************/
11+
package org.eclipse.core.tests.harness.session.customization;
12+
13+
import java.nio.file.Path;
14+
import org.eclipse.core.tests.harness.session.CustomSessionConfiguration;
15+
import org.eclipse.core.tests.session.Setup;
16+
import org.osgi.framework.Bundle;
17+
18+
public class CustomSessionConfigurationDummy implements CustomSessionConfiguration {
19+
20+
private Path configurationDirectory;
21+
22+
public CustomSessionConfigurationDummy() {
23+
}
24+
25+
@Override
26+
public CustomSessionConfiguration setCascaded() {
27+
return this;
28+
}
29+
30+
@Override
31+
public CustomSessionConfiguration setReadOnly() {
32+
return this;
33+
}
34+
35+
@Override
36+
public Path getConfigurationDirectory() {
37+
return configurationDirectory;
38+
}
39+
40+
@Override
41+
public CustomSessionConfiguration setConfigurationDirectory(Path configurationDirectory) {
42+
this.configurationDirectory = configurationDirectory;
43+
return this;
44+
}
45+
46+
@Override
47+
public void prepareSession(Setup setup) {
48+
// Do nothing
49+
}
50+
51+
@Override
52+
public void cleanupSession(Setup setup) {
53+
// Do nothing
54+
}
55+
56+
@Override
57+
public CustomSessionConfiguration addBundle(Class<?> classFromBundle) {
58+
return this;
59+
}
60+
61+
@Override
62+
public CustomSessionConfiguration addBundle(Bundle bundle) {
63+
return this;
64+
}
65+
66+
}

runtime/tests/org.eclipse.core.tests.harness/src/org/eclipse/core/tests/harness/session/customization/CustomSessionConfigurationImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ public CustomSessionConfiguration setConfigurationDirectory(Path configurationDi
142142
return this;
143143
}
144144

145-
private Path getConfigurationDirectory() throws IOException {
145+
@Override
146+
public Path getConfigurationDirectory() throws IOException {
146147
if (configurationDirectory == null) {
147148
setConfigurationDirectory(Files.createTempDirectory(TEMP_DIR_PREFIX));
148149
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 Vector Informatik GmbH and others.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License v2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*******************************************************************************/
11+
package org.eclipse.core.tests.harness.session.customization;
12+
13+
import java.nio.file.Path;
14+
import org.eclipse.core.tests.harness.session.CustomSessionWorkspace;
15+
import org.eclipse.core.tests.session.Setup;
16+
17+
/**
18+
* A session customization to use a custom workspace directory.
19+
*/
20+
public class CustomSessionWorkspaceDummy implements CustomSessionWorkspace {
21+
private Path workspaceDirectory;
22+
23+
public CustomSessionWorkspaceDummy() {
24+
// nothing to initialize
25+
}
26+
27+
@Override
28+
public CustomSessionWorkspace setWorkspaceDirectory(Path workspaceDirectory) {
29+
this.workspaceDirectory = workspaceDirectory;
30+
return this;
31+
}
32+
33+
@Override
34+
public Path getWorkspaceDirectory() {
35+
return workspaceDirectory;
36+
}
37+
38+
@Override
39+
public void prepareSession(Setup setup) throws Exception {
40+
// do nothing
41+
}
42+
43+
@Override
44+
public void cleanupSession(Setup setup) throws Exception {
45+
// do nothing
46+
}
47+
48+
}

0 commit comments

Comments
 (0)