Skip to content
This repository was archived by the owner on Jan 11, 2019. It is now read-only.

Commit 42ad351

Browse files
author
amccaskey
committed
Updated JobLauncherFormTester for new Docker DataComponent.
Signed-off-by: amccaskey <[email protected]>
1 parent 961a1f7 commit 42ad351

File tree

6 files changed

+55
-53
lines changed

6 files changed

+55
-53
lines changed

org.eclipse.ice.item.test/META-INF/MANIFEST.MF

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Bundle-Version: 2.1.8.20160208
66
Fragment-Host: org.eclipse.ice.item;bundle-version="1.0.0"
77
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
88
Import-Package: com.spotify.docker.client,
9+
org.apache.http.conn;version="4.3.4",
10+
org.bouncycastle.openssl;version="1.51.0",
911
org.eclipse.eavp.viz.service.mesh.datastructures,
1012
org.eclipse.ice.core.iCore,
1113
org.eclipse.ice.datastructures.entry,

org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/JobLauncherFormTester.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ public void checkMultipleInputFiles() {
643643

644644
// Check the number of Components in the JobLauncherForm. It should have
645645
// two, a DataComponent and an OutputComponent.
646-
assertEquals(2, jobLauncherForm.getNumberOfComponents());
646+
assertEquals(3, jobLauncherForm.getNumberOfComponents());
647647

648648
// Get the Entries
649649
ArrayList<IEntry> entries = ((DataComponent) jobLauncherForm

org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/JobLauncherTester.java

+19-19
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public void checkEnablingParallelism() {
174174

175175
// Get the MPI data component and the respective values
176176
form = (JobLauncherForm) jobLauncher.getForm();
177-
dataC = (DataComponent) form.getComponents().get(3);
177+
dataC = (DataComponent) form.getComponent(JobLauncherForm.parallelId);
178178
entry = dataC.retrieveAllEntries().get(1);
179179

180180
// Check values
@@ -187,7 +187,7 @@ public void checkEnablingParallelism() {
187187

188188
// Get the MPI data component and the respective values
189189
form = (JobLauncherForm) jobLauncher.getForm();
190-
dataC = (DataComponent) form.getComponents().get(3);
190+
dataC = (DataComponent) form.getComponent(JobLauncherForm.parallelId);
191191
entry = dataC.retrieveAllEntries().get(1);
192192

193193
// Check values
@@ -200,7 +200,7 @@ public void checkEnablingParallelism() {
200200

201201
// Get the MPI data component and the respective values
202202
form = (JobLauncherForm) jobLauncher.getForm();
203-
dataC = (DataComponent) form.getComponents().get(3);
203+
dataC = (DataComponent) form.getComponent(JobLauncherForm.parallelId);
204204
entry = dataC.retrieveAllEntries().get(1);
205205

206206
// Check values - nothing changed
@@ -213,7 +213,7 @@ public void checkEnablingParallelism() {
213213

214214
// Get the MPI data component and the respective values
215215
form = (JobLauncherForm) jobLauncher.getForm();
216-
dataC = (DataComponent) form.getComponents().get(3);
216+
dataC = (DataComponent) form.getComponent(JobLauncherForm.parallelId);
217217
entry = dataC.retrieveAllEntries().get(1);
218218

219219
// Check values - nothing changed
@@ -227,15 +227,15 @@ public void checkEnablingParallelism() {
227227
form = (JobLauncherForm) jobLauncher.getForm();
228228

229229
// Should not have MPI - total number of components should be 3
230-
assertEquals(form.getComponents().size(), 3);
230+
assertEquals(form.getComponents().size(), 4);
231231

232232
// disable again, see if it breaks
233233
jobLauncher.disableMPI();
234234
// Get the MPI data component and the respective values
235235
form = (JobLauncherForm) jobLauncher.getForm();
236236

237237
// Should not have MPI - total number of components should be 3
238-
assertEquals(form.getComponents().size(), 3);
238+
assertEquals(form.getComponents().size(), 4);
239239

240240
// check OpenMP
241241
// Just see if it crashes or not
@@ -244,7 +244,7 @@ public void checkEnablingParallelism() {
244244

245245
// Get the OpenMP data component and the respective values
246246
form = (JobLauncherForm) jobLauncher.getForm();
247-
dataC = (DataComponent) form.getComponents().get(3);
247+
dataC = (DataComponent) form.getComponent(JobLauncherForm.parallelId);
248248
entry = dataC.retrieveAllEntries().get(1);
249249

250250
// Check values
@@ -257,7 +257,7 @@ public void checkEnablingParallelism() {
257257

258258
// Get the OpenMP data component and the respective values
259259
form = (JobLauncherForm) jobLauncher.getForm();
260-
dataC = (DataComponent) form.getComponents().get(3);
260+
dataC = (DataComponent) form.getComponent(JobLauncherForm.parallelId);
261261
entry = dataC.retrieveAllEntries().get(1);
262262

263263
// Check values - nothing changed
@@ -270,7 +270,7 @@ public void checkEnablingParallelism() {
270270

271271
// Get the OpenMP data component and the respective values
272272
form = (JobLauncherForm) jobLauncher.getForm();
273-
dataC = (DataComponent) form.getComponents().get(3);
273+
dataC = (DataComponent) form.getComponent(JobLauncherForm.parallelId);
274274
entry = dataC.retrieveAllEntries().get(1);
275275

276276
// Check values - nothing changed
@@ -283,7 +283,7 @@ public void checkEnablingParallelism() {
283283

284284
// Get the OpenMP data component and the respective values
285285
form = (JobLauncherForm) jobLauncher.getForm();
286-
dataC = (DataComponent) form.getComponents().get(3);
286+
dataC = (DataComponent) form.getComponent(JobLauncherForm.parallelId);
287287
entry = dataC.retrieveAllEntries().get(1);
288288

289289
// Check values - nothing changed
@@ -299,15 +299,15 @@ public void checkEnablingParallelism() {
299299

300300
entry = dataC.retrieveAllEntries().get(0);
301301
// Should not have MPI - total number of components should be 3
302-
assertEquals(form.getComponents().size(), 3);
302+
assertEquals(form.getComponents().size(), 4);
303303

304304
// disable again, see if it breaks
305305
jobLauncher.disableOpenMP();
306306
// Get the OpenMP data component and the respective values
307307
form = (JobLauncherForm) jobLauncher.getForm();
308308

309309
// Should not have MPI - total number of components should be 3
310-
assertEquals(form.getComponents().size(), 3);
310+
assertEquals(form.getComponents().size(), 4);
311311

312312
jobLauncher = new TestJobLauncher(null);
313313
jobLauncher.setupForm();
@@ -319,7 +319,7 @@ public void checkEnablingParallelism() {
319319
// Check the dataComponent, see if they are both there
320320
// Get the OpenMP data component and the respective values
321321
form = (JobLauncherForm) jobLauncher.getForm();
322-
dataC = (DataComponent) form.getComponents().get(3);
322+
dataC = (DataComponent) form.getComponent(JobLauncherForm.parallelId);
323323
entry = dataC.retrieveAllEntries().get(1);
324324
assertNotNull(entry);
325325

@@ -330,7 +330,7 @@ public void checkEnablingParallelism() {
330330

331331
// Get the MPI data component and the respective values
332332
form = (JobLauncherForm) jobLauncher.getForm();
333-
dataC = (DataComponent) form.getComponents().get(3);
333+
dataC = (DataComponent) form.getComponent(JobLauncherForm.parallelId);
334334
entry = dataC.retrieveAllEntries().get(1);
335335

336336
// Check values - nothing changed
@@ -349,14 +349,14 @@ public void checkEnablingParallelism() {
349349
form = (JobLauncherForm) jobLauncher.getForm();
350350

351351
// Should not have MPI - total number of components should be 3
352-
assertEquals(form.getComponents().size(), 3);
352+
assertEquals(form.getComponents().size(), 4);
353353

354354
// Tests for TBB
355355
jobLauncher.enableTBB(1, 5, 3);
356356

357357
// Get the data component and the respective values
358358
form = (JobLauncherForm) jobLauncher.getForm();
359-
dataC = (DataComponent) form.getComponents().get(3);
359+
dataC = (DataComponent) form.getComponent(JobLauncherForm.parallelId);
360360
entry = dataC.retrieveAllEntries().get(1);
361361

362362
// Check values
@@ -371,7 +371,7 @@ public void checkEnablingParallelism() {
371371

372372
// Get the data component and the respective values
373373
form = (JobLauncherForm) jobLauncher.getForm();
374-
dataC = (DataComponent) form.getComponents().get(3);
374+
dataC = (DataComponent) form.getComponent(JobLauncherForm.parallelId);
375375
entry = dataC.retrieveEntry("Number of TBB Threads");
376376

377377
// Check values - TBB
@@ -396,7 +396,7 @@ public void checkEnablingParallelism() {
396396

397397
// Get the data component and the respective values
398398
form = (JobLauncherForm) jobLauncher.getForm();
399-
dataC = (DataComponent) form.getComponents().get(3);
399+
dataC = (DataComponent) form.getComponent(JobLauncherForm.parallelId);
400400
entry = dataC.retrieveEntry("Number of TBB Threads");
401401

402402
// Check values - TBB
@@ -418,7 +418,7 @@ public void checkEnablingParallelism() {
418418
jobLauncher.enableTBB(20, 10, 5);
419419
// Get the data component and the respective values
420420
form = (JobLauncherForm) jobLauncher.getForm();
421-
dataC = (DataComponent) form.getComponents().get(3);
421+
dataC = (DataComponent) form.getComponent(JobLauncherForm.parallelId);
422422
entry = dataC.retrieveEntry("Number of TBB Threads");
423423

424424
// Check values - TBB

org.eclipse.ice.item.test/src/org/eclipse/ice/item/test/JobProfileTester.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.eclipse.ice.datastructures.form.Form;
4040
import org.eclipse.ice.datastructures.form.ResourceComponent;
4141
import org.eclipse.ice.item.jobLauncher.JobLauncher;
42+
import org.eclipse.ice.item.jobLauncher.JobLauncherForm;
4243
import org.eclipse.ice.item.jobprofile.JobProfile;
4344
import org.junit.Test;
4445

@@ -173,14 +174,14 @@ public void checkProfileWriting() throws NullPointerException, JAXBException, IO
173174
assertEquals("JobProfile", form.getName());
174175
assertEquals("This operation will execute JobProfile",
175176
form.getDescription());
176-
assertEquals(3, form.getComponents().size());
177+
assertEquals(4, form.getComponents().size());
177178

178179
// Enable OpenMP and MPI on the launcher
179180
launcher.enableMPI(1, 512000, 1);
180181
launcher.enableOpenMP(1, 16, 1);
181182

182183
// Verify they were set correctly
183-
DataComponent component = (DataComponent) form.getComponents().get(3);
184+
DataComponent component = (DataComponent) form.getComponent(JobLauncherForm.parallelId);
184185
IEntry mpiEntry = component.retrieveAllEntries().get(1);
185186
IEntry openMPEntry = component.retrieveAllEntries().get(2);
186187
assertEquals("1", mpiEntry.getValue());

org.eclipse.ice.item/src/org/eclipse/ice/item/jobLauncher/DockerClientFactory.java

+27-28
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
import com.spotify.docker.client.DockerClient;
2424

2525
/**
26-
* This class provides a factory method for creating
27-
* the DefaultDockerClient in a way that is OS independent.
26+
* This class provides a factory method for creating the DefaultDockerClient in
27+
* a way that is OS independent.
2828
*
29-
* @author Alex McCAskey
29+
* @author Alex McCAskey
3030
*
3131
*/
3232
public class DockerClientFactory {
@@ -49,7 +49,7 @@ public DockerClient getDockerClient() throws DockerCertificateException, IOExcep
4949

5050
// If this is not Linux, then we have to find DOCKER_HOST
5151
if (!Platform.getOS().equals(Platform.OS_LINUX)) {
52-
52+
5353
// See if we can get the DOCKER_HOST environment variaable
5454
String dockerHost = System.getenv("DOCKER_HOST");
5555
if (dockerHost == null) {
@@ -58,11 +58,11 @@ public DockerClient getDockerClient() throws DockerCertificateException, IOExcep
5858
File script = getDockerConnectionScript();
5959
String[] scriptExec = null;
6060
if (Platform.getOS().equals(Platform.OS_MACOSX)) {
61-
scriptExec = new String[]{script.getAbsolutePath()};
61+
scriptExec = new String[] { script.getAbsolutePath() };
6262
} else if (Platform.getOS().equals(Platform.OS_WIN32)) {
63-
scriptExec = new String[]{"cmd.exe", "/C", script.getAbsolutePath()};
63+
scriptExec = new String[] { "cmd.exe", "/C", script.getAbsolutePath() };
6464
}
65-
65+
6666
// Execute the script to get the DOCKER vars.
6767
Process process = new ProcessBuilder(scriptExec).start();
6868
process.waitFor();
@@ -73,7 +73,7 @@ public DockerClient getDockerClient() throws DockerCertificateException, IOExcep
7373
InputStream processInputStream = process.getInputStream();
7474
Properties dockerSettings = new Properties();
7575
dockerSettings.load(processInputStream);
76-
76+
7777
// Create the Builder object that wil build the DockerClient
7878
Builder builder = new Builder();
7979

@@ -85,12 +85,12 @@ public DockerClient getDockerClient() throws DockerCertificateException, IOExcep
8585
DockerCertificates certs = DockerCertificates.builder().dockerCertPath(dockerCertPath).build();
8686

8787
// Set the data need for the builder.
88-
final String stripped = endpoint.replaceAll(".*://", "");
89-
final HostAndPort hostAndPort = HostAndPort.fromString(stripped);
90-
final String hostText = hostAndPort.getHostText();
91-
final String scheme = certs != null ? "https" : "http";
92-
final int port = hostAndPort.getPortOrDefault(2375);
93-
final String address = hostText;
88+
String stripped = endpoint.replaceAll(".*://", "");
89+
HostAndPort hostAndPort = HostAndPort.fromString(stripped);
90+
String hostText = hostAndPort.getHostText();
91+
String scheme = certs != null ? "https" : "http";
92+
int port = hostAndPort.getPortOrDefault(2375);
93+
String address = hostText;
9494
builder.uri(scheme + "://" + address + ":" + port);
9595
if (certs != null) {
9696
builder.dockerCertificates(certs);
@@ -109,14 +109,17 @@ public DockerClient getDockerClient() throws DockerCertificateException, IOExcep
109109
} else {
110110
client = DefaultDockerClient.fromEnv().build();
111111
}
112+
} else {
113+
// It was equal to Linux, so just use the default stuff.
114+
client = DefaultDockerClient.fromEnv().build();
112115
}
113116

114117
return client;
115118
}
116119

117120
/**
118-
* This method gets the script file for finding the Docker
119-
* environment variables.
121+
* This method gets the script file for finding the Docker environment
122+
* variables.
120123
*
121124
* @return
122125
*/
@@ -127,19 +130,14 @@ private File getDockerConnectionScript() {
127130
} else if (Platform.getOS().equals(Platform.OS_WIN32)) {
128131
scriptName = "script.bat";
129132
}
130-
133+
131134
Bundle bundle = Platform.getBundle("org.eclipse.ice.item");
132-
final File script = bundle
133-
.getDataFile(scriptName);
134-
135+
final File script = bundle.getDataFile(scriptName);
136+
135137
// if the script file does not exist or is outdated.
136-
if (script != null
137-
&& (!script.exists() || script.lastModified() < bundle.getLastModified())) {
138-
try (final FileOutputStream output = new FileOutputStream(
139-
script);
140-
final InputStream is = DockerClientFactory.class
141-
.getResourceAsStream(
142-
"/resources/" + scriptName)) {
138+
if (script != null && (!script.exists() || script.lastModified() < bundle.getLastModified())) {
139+
try (final FileOutputStream output = new FileOutputStream(script);
140+
final InputStream is = DockerClientFactory.class.getResourceAsStream("/resources/" + scriptName)) {
143141
byte[] buff = new byte[1024];
144142
int n;
145143
while ((n = is.read(buff)) > 0) {
@@ -152,9 +150,10 @@ private File getDockerConnectionScript() {
152150
}
153151
return script;
154152
}
155-
153+
156154
/**
157155
* Private utility for getting string from InputStream.
156+
*
158157
* @param stream
159158
* @return
160159
*/

org.eclipse.ice.item/src/org/eclipse/ice/item/jobLauncher/JobLauncher.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1397,7 +1397,7 @@ public void enableMPI(int minProcesses, int maxProcesses, int defaultProcesses)
13971397
((JobLauncherForm) form).enableMPI(minProcesses, maxProcesses, defaultProcesses);
13981398

13991399
// If the components are not greater than 2, then it is false
1400-
if (form.getComponents().size() > 3) {
1400+
if (form.getComponents().size() > 4) {
14011401
DataComponent dataC = (DataComponent) form.getComponent(JobLauncherForm.parallelId);
14021402
IEntry entry = dataC.retrieveEntry("Number of MPI Processes");
14031403
if (entry != null) {
@@ -1462,7 +1462,7 @@ public void enableOpenMP(int minThreads, int maxThreads, int defaultThreads) {
14621462
((JobLauncherForm) form).enableOpenMP(minThreads, maxThreads, defaultThreads);
14631463

14641464
// If the components are not greater than 2, then it is false
1465-
if (form.getComponents().size() > 3) {
1465+
if (form.getComponents().size() > 4) {
14661466
DataComponent dataC = (DataComponent) form.getComponent(JobLauncherForm.parallelId);
14671467
IEntry entry = dataC.retrieveEntry("Number of OpenMP Threads");
14681468
if (entry != null) {
@@ -1537,7 +1537,7 @@ public void enableTBB(int minThreads, int maxThreads, int defaultThreads) {
15371537
JobLauncherForm form = (JobLauncherForm) this.getForm();
15381538

15391539
// If there are more than 3 components, then parallelism is enabled.
1540-
if (form.getComponents().size() > 3) {
1540+
if (form.getComponents().size() > 4) {
15411541
DataComponent dataC = (DataComponent) form.getComponent(JobLauncherForm.parallelId);
15421542
IEntry entry = dataC.retrieveEntry("Number of TBB Threads");
15431543
if (entry != null) {

0 commit comments

Comments
 (0)