Skip to content

Commit 49e3c61

Browse files
authored
JBDS-4469 Some servers added to runtime detection only with fuse tools (#790)
This fix: 1. Removes not deeded listeners for components required OpenJDK to be installed first, because install ordering is already taking care of it 2. Gets rid unit test errors under macOS 3. Introduces new message sent after all installers successfully finished installation, so whoever needs to do some configuration after installation can proceed 4. Gets rid of errors that occurs only when one test.js executed 5. Increases unit-tests code coverage for new code
1 parent 038309d commit 49e3c61

14 files changed

Lines changed: 292 additions & 311 deletions

File tree

browser/model/devstudio.js

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,13 @@ class DevstudioInstall extends InstallableItem {
3030
progress.setStatus('Installing');
3131
this.installGenerator = new DevstudioAutoInstallGenerator(this.installerDataSvc.devstudioDir(), this.installerDataSvc.jdkDir(), this.version, this.additionalLocations, this.additionalIus);
3232
let installer = new Installer(this.keyName, progress, success, failure);
33-
if(fs.existsSync(this.bundledFile)) {
34-
this.downloadedFile = this.bundledFile;
35-
}
3633
Logger.info(this.keyName + ' - Generate devstudio auto install file content');
3734
let data = this.installGenerator.fileContent();
3835
Logger.info(this.keyName + ' - Generate devstudio auto install file content SUCCESS');
3936

4037
return installer.writeFile(this.installConfigFile, data)
4138
.then((result) => {
42-
return this.postJDKInstall(installer, result);
39+
return this.headlessInstall(installer, result);
4340
})
4441
.then(() => {
4542
installer.succeed(true);
@@ -49,27 +46,6 @@ class DevstudioInstall extends InstallableItem {
4946
});
5047
}
5148

52-
postJDKInstall(installer, result) {
53-
return new Promise((resolve, reject) => {
54-
let jdkInstall = this.installerDataSvc.getInstallable(JdkInstall.KEY);
55-
56-
if (jdkInstall.isInstalled()) {
57-
return this.headlessInstall(installer, result)
58-
.then((res) => { resolve(res); })
59-
.catch((err) => { reject(err); });
60-
} else {
61-
Logger.info(this.keyName + ' - JDK has not finished installing, listener created to be called when it has.');
62-
this.ipcRenderer.on('installComplete', (event, arg) => {
63-
if (arg == JdkInstall.KEY) {
64-
return this.headlessInstall(installer, result)
65-
.then((res) => { resolve(res); })
66-
.catch((err) => { reject(err); });
67-
}
68-
});
69-
}
70-
});
71-
}
72-
7349
headlessInstall(installer) {
7450
Logger.info(this.keyName + ' - headlessInstall() called');
7551
let javaOpts = [

browser/model/jbosseap.js

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39,45 +39,22 @@ class JbosseapInstall extends InstallableItem {
3939
return Promise.resolve().then(()=> {
4040
return installer.writeFile(this.installConfigFile, data);
4141
}).then((result) => {
42-
return this.postJDKInstall(installer, result);
42+
return this.headlessInstall(installer, result);
4343
}).then(() => {
44-
let devstudio = this.installerDataSvc.getInstallable('devstudio');
45-
if(devstudio.installed) {
46-
devstudio.configureRuntimeDetection('jbosseap', this.installerDataSvc.jbosseapDir());
47-
} else {
48-
this.ipcRenderer.on('installComplete', (event, arg)=> {
49-
if(arg == 'devstudio') {
44+
this.ipcRenderer.on('installComplete', (event, arg)=> {
45+
if(arg == 'all') {
46+
let devstudio = this.installerDataSvc.getInstallable('devstudio');
47+
if(devstudio.installed) {
5048
devstudio.configureRuntimeDetection('jbosseap', this.installerDataSvc.jbosseapDir());
5149
}
52-
});
53-
}
50+
}
51+
});
5452
installer.succeed(true);
5553
}).catch((error) => {
5654
installer.fail(error);
5755
});
5856
}
5957

60-
postJDKInstall(installer, result) {
61-
return new Promise((resolve, reject) => {
62-
let jdkInstall = this.installerDataSvc.getInstallable(JdkInstall.KEY);
63-
64-
if (jdkInstall.isInstalled()) {
65-
return this.headlessInstall(installer, result)
66-
.then((res) => { resolve(res); })
67-
.catch((err) => { reject(err); });
68-
} else {
69-
Logger.info(this.keyName + ' - JDK has not finished installing, listener created to be called when it has.');
70-
this.ipcRenderer.on('installComplete', (event, arg) => {
71-
if (arg == JdkInstall.KEY) {
72-
return this.headlessInstall(installer, result)
73-
.then((res) => { resolve(res); })
74-
.catch((err) => { reject(err); });
75-
}
76-
});
77-
}
78-
});
79-
}
80-
8158
headlessInstall(installer) {
8259
Logger.info(this.keyName + ' - headlessInstall() called');
8360
let javaOpts = [

browser/model/jbossfuse.js

Lines changed: 27 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -73,83 +73,57 @@ class FusePlatformInstall extends InstallableItem {
7373
return Promise.resolve().then(()=> {
7474
return installer.writeFile(this.installConfigFile, installGenerator(this.installerDataSvc.fuseplatformDir()));
7575
}).then(()=> {
76-
return this.postJDKInstall(installer);
76+
return this.headlessEapInstall(installer);
7777
}).then(()=> {
78-
let devstudio = this.installerDataSvc.getInstallable('devstudio');
79-
if(devstudio.installed) {
80-
devstudio.configureRuntimeDetection('fuse-platform-on-eap', this.installerDataSvc.fuseplatformDir());
81-
} else {
82-
this.ipcRenderer.on('installComplete', (event, arg)=> {
83-
if(arg == 'fusetools') {
78+
return this.headlessInstall(installer);
79+
}).then(()=> {
80+
this.ipcRenderer.on('installComplete', (event, arg)=> {
81+
if(arg == 'all') {
82+
let devstudio = this.installerDataSvc.getInstallable('devstudio');
83+
if(devstudio.installed) {
8484
devstudio.configureRuntimeDetection('fuse-platform-on-eap', this.installerDataSvc.fuseplatformDir());
8585
}
86-
});
87-
}
86+
}
87+
});
88+
8889
installer.succeed(true);
8990
}).catch((error)=> {
9091
installer.fail(error);
9192
});
9293
}
9394

94-
postJDKInstall(installer) {
95-
return new Promise((resolve, reject) => {
96-
let jdkInstall = this.installerDataSvc.getInstallable(JdkInstall.KEY);
97-
if (jdkInstall.isInstalled()) {
98-
return Promise.resolve().then(()=> {
99-
return this.headlessEapInstall(installer);
100-
}).then(()=> {
101-
return this.headlessInstall(installer);
102-
}).then((res) => {
103-
resolve(res);
104-
}).catch((err) => {
105-
reject(err);
106-
});
107-
} else {
108-
Logger.info(this.keyName + ' - JDK has not finished installing, listener created to be called when it has.');
109-
this.ipcRenderer.on('installComplete', (event, arg) => {
110-
if (arg == JdkInstall.KEY) {
111-
return Promise.resolve().then(()=> {
112-
return this.headlessEapInstall(installer);
113-
}).then(()=> {
114-
return this.headlessInstall(installer);
115-
}).then((res) => {
116-
resolve(res);
117-
}).catch((err) => {
118-
reject(err);
119-
});
120-
}
121-
});
122-
}
123-
});
124-
}
125-
12695
headlessInstall(installer) {
12796
Logger.info(this.keyName + ' - headlessInstall() called');
128-
let javaOpts = [
129-
'-DTRACE=true',
97+
return installer.execFile(this.javaPath, this.installArgs, this.installOptions);
98+
}
99+
100+
get installOptions() {
101+
return {cwd: this.installerDataSvc.fuseplatformDir()};
102+
}
103+
104+
get installArgs() {
105+
return [
130106
'-jar',
131107
this.downloadedFile
132108
];
133-
let res = installer.execFile(
134-
path.join(this.installerDataSvc.jdkDir(), 'bin', 'java'), javaOpts, {cwd: this.installerDataSvc.fuseplatformDir()}
135-
);
136-
137-
return res;
138109
}
139110

140111
headlessEapInstall(installer) {
141112
Logger.info(this.keyName + ' - headlessEapInstall() called');
142-
let javaOpts = [
113+
return installer.execFile(this.javaPath, this.eapInstallArgs);
114+
}
115+
116+
get eapInstallArgs() {
117+
return [
143118
'-DTRACE=true',
144119
'-jar',
145120
this.jbeap.downloadedFile,
146121
this.installConfigFile
147122
];
148-
let res = installer.execFile(
149-
path.join(this.installerDataSvc.jdkDir(), 'bin', 'java'), javaOpts
150-
);
123+
}
151124

152-
return res;
125+
get javaPath() {
126+
return path.join(this.installerDataSvc.jdkDir(), 'bin', 'java');
153127
}
154128
}
155129

browser/model/jbossfusekaraf.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,14 @@ class FusePlatformInstallKaraf extends InstallableItem {
4343
resolve();
4444
});
4545
}).then(()=> {
46-
let devstudio = this.installerDataSvc.getInstallable('devstudio');
47-
if(devstudio.installed) {
48-
devstudio.configureRuntimeDetection('fuse-platform-on-karaf', this.installerDataSvc.fuseplatformkarafDir());
49-
} else {
50-
this.ipcRenderer.on('installComplete', (event, arg)=> {
51-
if(arg == 'fusetools') {
46+
this.ipcRenderer.on('installComplete', (event, arg)=> {
47+
if(arg == 'all') {
48+
let devstudio = this.installerDataSvc.getInstallable('devstudio');
49+
if(devstudio.installed) {
5250
devstudio.configureRuntimeDetection('fuse-platform-on-karaf', this.installerDataSvc.fuseplatformkarafDir());
5351
}
54-
});
55-
}
52+
}
53+
});
5654
installer.succeed(true);
5755
}).catch((error)=> {
5856
installer.fail(error);

browser/model/jdk-install.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class JdkInstall extends InstallableItem {
197197
}
198198

199199
isConfigured() {
200-
if (Platform.getOS() === 'darwin') {
200+
if (Platform.OS === 'darwin') {
201201
return this.isDetected() && this.option['detected'].valid;
202202
}
203203
return super.isConfigured();

browser/pages/confirm/controller.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,24 +67,26 @@ class ConfirmController {
6767
}
6868

6969
installWatchers() {
70-
let nodes = this.graph.overallOrder() ;
70+
let graph = this.graph;
71+
let nodes = graph.overallOrder() ;
72+
let checkboxModel = this.sc.checkboxModel;
7173
for (let node of nodes) {
72-
this.sc.checkboxModel[node].references=0;
74+
checkboxModel[node].references=0;
7375
}
7476
for (let node of nodes) {
75-
let watchComponent = ()=> {
76-
let installer = this.sc.checkboxModel[node];
77+
function watchComponent (){
78+
let installer = checkboxModel[node];
7779
if(installer.isSelected()) {
78-
for(let dep of this.graph.dependenciesOf(node)) {
79-
let depInstaller = this.sc.checkboxModel[dep];
80+
for(let dep of graph.dependenciesOf(node)) {
81+
let depInstaller = checkboxModel[dep];
8082
if(depInstaller.references==0 && depInstaller.isNotDetected()) {
8183
depInstaller.selectedOption = 'install';
8284
}
8385
depInstaller.references++;
8486
}
8587
} else {
86-
for(let dep of this.graph.dependenciesOf(node)) {
87-
let depInstaller = this.sc.checkboxModel[dep];
88+
for(let dep of graph.dependenciesOf(node)) {
89+
let depInstaller = checkboxModel[dep];
8890
depInstaller.references--;
8991
if(depInstaller.references==0) {
9092
depInstaller.selectedOption = 'detected';

browser/services/data.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ class InstallerDataService {
266266
if (!this.isDownloading() && this.toInstall.size == 0) {
267267
Logger.info('All installs complete');
268268
this.installing = false;
269+
this.ipcRenderer.send('installComplete', 'all');
269270
this.router.go('start');
270271
}
271272
}

test/unit/model/devstudio-test.js

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ describe('devstudio installer', function() {
3131
let failure = () => {};
3232

3333
function stubDataService() {
34-
let ds = sinon.stub(new InstallerDataService({}, {
34+
let reqsJson = {
3535
devstudio: {},
3636
jdk:{
3737
name: 'OpenJDK'
3838
}
39-
}));
39+
};
40+
let packageJson = {version: "X.0.0-GA"};
41+
let ds = sinon.stub(new InstallerDataService({}, reqsJson, packageJson));
4042
ds.getRequirementByName.restore();
4143
ds.tempDir.returns('tempDirectory');
4244
ds.installDir.returns('installationFolder');
@@ -233,7 +235,7 @@ describe('devstudio installer', function() {
233235

234236
it('should call success callback when installation is finished successfully', function() {
235237
sandbox.stub(Installer.prototype, 'writeFile').resolves();
236-
sandbox.stub(installer, 'postJDKInstall').resolves();
238+
sandbox.stub(installer, 'headlessInstall').resolves();
237239
sandbox.stub(Installer.prototype, 'succeed');
238240

239241
return installer.installAfterRequirements(
@@ -243,58 +245,6 @@ describe('devstudio installer', function() {
243245
});
244246
});
245247

246-
describe('postJDKInstall', function() {
247-
let helper, stubInstall, eventSpy;
248-
249-
beforeEach(function() {
250-
helper = new Installer('devstudio', fakeProgress, success, failure);
251-
stubInstall = sandbox.stub(installer, 'headlessInstall').resolves(true);
252-
eventSpy = installer.ipcRenderer.on;
253-
});
254-
255-
it('should wait for JDK install to complete', function() {
256-
return installer.postJDKInstall(helper, true)
257-
.then(() => {
258-
expect(eventSpy).calledOnce;
259-
});
260-
});
261-
262-
it('should wait for JDK install to complete and ignore other installed components', function() {
263-
installer.ipcRenderer.on = sinon.stub();
264-
installer.ipcRenderer.on.onFirstCall().yields({}, 'cdk');
265-
sandbox.stub(fakeInstall, 'isInstalled').returns(false);
266-
installer.postJDKInstall(helper, true);
267-
expect(installer.ipcRenderer.on).has.been.called;
268-
expect(stubInstall).has.not.been.called;
269-
});
270-
271-
it('should call headlessInstall if JDK is installed', function() {
272-
sandbox.stub(fakeInstall, 'isInstalled').returns(true);
273-
274-
return installer.postJDKInstall(
275-
helper
276-
).then(() => {
277-
expect(eventSpy).not.called;
278-
expect(stubInstall).calledOnce;
279-
});
280-
});
281-
282-
it('should reject promise if headlessInstall fails', function() {
283-
sandbox.stub(fakeInstall, 'isInstalled').returns(true);
284-
installer.headlessInstall.restore();
285-
stubInstall = sandbox.stub(installer, 'headlessInstall').rejects('Error');
286-
return installer.postJDKInstall(
287-
helper
288-
).then(() => {
289-
expect.fail();
290-
}).catch((error)=> {
291-
expect(eventSpy).not.called;
292-
expect(stubInstall).calledOnce;
293-
expect(error.name).to.be.equal('Error');
294-
});
295-
});
296-
});
297-
298248
describe('headlessInstall', function() {
299249
let helper;
300250
let child_process = require('child_process');

test/unit/model/fuseplatformkaraf-test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,12 @@ describe('jbossplaformkaraf nstaller', function() {
108108
let promise = fuseInstaller.installAfterRequirements(fakeProgress, success, failure);
109109
mockDevSuiteInstaller.emitEntries();
110110
return promise.then(()=>{
111-
let devstudioInstaller = fuseInstaller.installerDataSvc.getInstallable('fusetools');
111+
let devstudioInstaller = fuseInstaller.installerDataSvc.getInstallable('devstudio');
112112
expect(devstudioInstaller.configureRuntimeDetection).not.called;
113-
fuseInstaller.ipcRenderer.emit('installComplete', 'installComplete', 'jdk');
113+
fuseInstaller.ipcRenderer.emit('installComplete', 'installComplete', 'devstudio');
114114
expect(devstudioInstaller.configureRuntimeDetection).not.called;
115-
fuseInstaller.ipcRenderer.emit('installComplete', 'installComplete', 'fusetools');
115+
devstudioInstaller.installed = true;
116+
fuseInstaller.ipcRenderer.emit('installComplete', 'installComplete', 'all');
116117
expect(devstudioInstaller.configureRuntimeDetection).calledOnce;
117118
});
118119
});

0 commit comments

Comments
 (0)