Commit 5d3bcebe authored by danielng's avatar danielng Committed by Commit Bot

crostini: Adding extra logging and promise resolution to flaky test

It appears that the test is failing in between tests, which implies
that there may be errors in the setup/teardown. Adding extra logging
to see if the teardown completes successfully and also adding some
extra functionality to reject any unresolved promises at the end of
each test, as the unresolved tests may be causing mocha to hang. Also
added some extra logging to the js code itself, to help identify which
promises are being unresolved.

Bug: 1082027
Change-Id: I4eaefe54aaffd8a513bd158f713e4d1fa963f4af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2245574
Commit-Queue: Daniel Ng <danielng@google.com>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#778622}
parent b3030525
......@@ -148,6 +148,8 @@ Polymer({
const selectedIndex = this.$$('#diskSlider').value;
const size = this.diskSizeTicks_[selectedIndex].value;
this.resizeState_ = ResizeState.RESIZING;
console.log(
'crostini_disk_resize_dialog.js: calling \'resizeCrostiniDisk\'');
settings.CrostiniBrowserProxyImpl.getInstance()
.resizeCrostiniDisk('termina', size)
.then(
......@@ -158,10 +160,16 @@ Polymer({
} else {
this.resizeState_ = ResizeState.ERROR;
}
console.log(
'crostini_disk_resize_dialog.js: ' +
'resolved \'resizeCrostiniDisk\'');
},
(reason) => {
console.log(`Unable to resize disk: ${reason}`);
this.resizeState_ = ResizeState.ERROR;
console.log(
'crostini_disk_resize_dialog.js: ' +
'resolved \'resizeCrostiniDisk\'');
});
},
......
......@@ -226,7 +226,7 @@ Polymer({
settings.CrostiniBrowserProxyImpl.getInstance()
.getCrostiniMicSharingEnabled()
.then(this.onCrostiniMicSharingEnabledChanged_.bind(this));
this.loadDiskInfo_();
this.loadDiskInfo_('attached');
},
ready() {
......@@ -250,7 +250,7 @@ Polymer({
if (enabled) {
// The disk size or type could have changed due to the user reinstalling
// Crostini, update our info.
this.loadDiskInfo_();
this.loadDiskInfo_('onCrostiniEnabledChanged_');
}
},
......@@ -271,10 +271,16 @@ Polymer({
settings.routes.CROSTINI_ANDROID_ADB);
},
/** @private */
loadDiskInfo_() {
/**
* @param {string} callerName
* @private
*/
loadDiskInfo_(callerName) {
// TODO(davidmunro): No magic 'termina' string.
const vmName = 'termina';
console.log(
'crostini_subpage.js: ' + callerName +
' callling \'getCrostiniDiskInfo\'');
settings.CrostiniBrowserProxyImpl.getInstance()
.getCrostiniDiskInfo(vmName, /*requestFullInfo=*/ false)
.then(
......@@ -282,9 +288,15 @@ Polymer({
if (diskInfo.succeeded) {
this.setResizeLabels_(diskInfo);
}
console.log(
'crostini_subpage.js: ' + callerName +
' resolved \'getCrostiniDiskInfo\'');
},
reason => {
console.log(`Unable to get info: ${reason}`);
console.log(
'crostini_subpage.js: ' + callerName +
' resolved \'getCrostiniDiskInfo\'');
});
},
......@@ -333,7 +345,7 @@ Polymer({
this.showDiskResizeDialog_ = false;
this.diskResizeConfirmationState_ = ConfirmationState.NOT_CONFIRMED;
// DiskInfo could have changed.
this.loadDiskInfo_();
this.loadDiskInfo_('onDiskResizeDialogClose_');
},
/** @private */
......
......@@ -49,7 +49,9 @@ suite('CrostiniPageTests', function() {
});
teardown(function() {
console.log('Teardown has begun.');
crostiniPage.remove();
console.log('Teardown has ended.');
});
function flushAsync() {
......@@ -714,6 +716,9 @@ suite('CrostiniPageTests', function() {
assertEquals(
subpage.$$('#diskSizeDescription').innerText,
loadTimeData.getString('crostiniDiskResizeNotSupportedSubtext'));
console.log('Rejecting promises.');
await crostiniBrowserProxy.rejectAllPromises(
['getCrostiniDiskInfo', 'resizeCrostiniDisk']);
console.log(`Finished test ${this.test.title}`);
});
......@@ -728,6 +733,9 @@ suite('CrostiniPageTests', function() {
button.innerText,
loadTimeData.getString('crostiniDiskResizeShowButton'));
assertEquals(subtext.innerText, 'label 100');
console.log('Rejecting promises.');
await crostiniBrowserProxy.rejectAllPromises(
['getCrostiniDiskInfo', 'resizeCrostiniDisk']);
console.log(`Finished test ${this.test.title}`);
});
......@@ -745,6 +753,9 @@ suite('CrostiniPageTests', function() {
subtext.innerText,
loadTimeData.getString(
'crostiniDiskResizeDynamicallyAllocatedSubtext'));
console.log('Rejecting promises.');
await crostiniBrowserProxy.rejectAllPromises(
['getCrostiniDiskInfo', 'resizeCrostiniDisk']);
console.log(`Finished test ${this.test.title}`);
});
......@@ -758,6 +769,9 @@ suite('CrostiniPageTests', function() {
assertTrue(isVisible(dialog.$$('#recommended-size')));
assertFalse(isVisible(dialog.$$('#recommended-size-warning')));
console.log('Rejecting promises.');
await crostiniBrowserProxy.rejectAllPromises(
['getCrostiniDiskInfo', 'resizeCrostiniDisk']);
console.log(`Finished test ${this.test.title}`);
});
......@@ -772,6 +786,9 @@ suite('CrostiniPageTests', function() {
assertFalse(isVisible(dialog.$$('#recommended-size')));
assertTrue(isVisible(dialog.$$('#recommended-size-warning')));
console.log('Rejecting promises.');
await crostiniBrowserProxy.rejectAllPromises(
['getCrostiniDiskInfo', 'resizeCrostiniDisk']);
console.log(`Finished test ${this.test.title}`);
});
......@@ -807,6 +824,9 @@ suite('CrostiniPageTests', function() {
assertTrue(dialog.$$('#resize').disabled);
assertFalse(dialog.$$('#cancel').disabled);
console.log('Rejecting promises.');
await crostiniBrowserProxy.rejectAllPromises(
['getCrostiniDiskInfo', 'resizeCrostiniDisk']);
console.log(`Finished test ${this.test.title}`);
});
......@@ -820,6 +840,9 @@ suite('CrostiniPageTests', function() {
assertVisibleBlockIs('#unsupported');
assertTrue(dialog.$$('#resize').disabled);
assertFalse(dialog.$$('#cancel').disabled);
console.log('Rejecting promises.');
await crostiniBrowserProxy.rejectAllPromises(
['getCrostiniDiskInfo', 'resizeCrostiniDisk']);
console.log(`Finished test ${this.test.title}`);
});
......@@ -837,6 +860,9 @@ suite('CrostiniPageTests', function() {
assertFalse(dialog.$$('#resize').disabled);
assertFalse(dialog.$$('#cancel').disabled);
console.log('Rejecting promises.');
await crostiniBrowserProxy.rejectAllPromises(
['getCrostiniDiskInfo', 'resizeCrostiniDisk']);
console.log(`Finished test ${this.test.title}`);
});
......@@ -855,6 +881,9 @@ suite('CrostiniPageTests', function() {
assertTrue(isVisible(dialog.$$('#resizing')));
assertFalse(isVisible(dialog.$$('#resize-error')));
assertTrue(dialog.$$('#cancel').disabled);
console.log('Rejecting promises.');
await crostiniBrowserProxy.rejectAllPromises(
['getCrostiniDiskInfo', 'resizeCrostiniDisk']);
console.log(`Finished test ${this.test.title}`);
});
......@@ -873,6 +902,9 @@ suite('CrostiniPageTests', function() {
assertFalse(isVisible(dialog.$$('#resizing')));
assertTrue(isVisible(dialog.$$('#resize-error')));
assertFalse(dialog.$$('#cancel').disabled);
console.log('Rejecting promises.');
await crostiniBrowserProxy.rejectAllPromises(
['getCrostiniDiskInfo', 'resizeCrostiniDisk']);
console.log(`Finished test ${this.test.title}`);
});
......@@ -889,6 +921,9 @@ suite('CrostiniPageTests', function() {
// Dialog should close itself.
console.log('Awaiting close');
await test_util.eventToPromise('close', dialog);
console.log('Rejecting promises.');
await crostiniBrowserProxy.rejectAllPromises(
['getCrostiniDiskInfo', 'resizeCrostiniDisk']);
console.log(`Finished test ${this.test.title}`);
});
......@@ -934,6 +969,9 @@ suite('CrostiniPageTests', function() {
assertTrue(!!dialog);
assertTrue(isVisible(dialog.$$('#resize')));
assertTrue(isVisible(dialog.$$('#cancel')));
console.log('Rejecting promises.');
await crostiniBrowserProxy.rejectAllPromises(
['getCrostiniDiskInfo', 'resizeCrostiniDisk']);
console.log(`Finished test ${this.test.title}`);
});
......@@ -953,6 +991,9 @@ suite('CrostiniPageTests', function() {
await test_util.eventToPromise('close', confirmationDialog);
assertFalse(!!subpage.$$('settings-crostini-disk-resize-dialog'));
console.log('Rejecting promises.');
await crostiniBrowserProxy.rejectAllPromises(
['getCrostiniDiskInfo', 'resizeCrostiniDisk']);
console.log(`Finished test ${this.test.title}`);
});
});
......
......@@ -72,6 +72,22 @@ class TestCrostiniBrowserProxy extends TestBrowserProxy {
this.methodCalls_[name] = [];
}
async rejectAllPromises(names) {
for (name of names) {
if (this.methodCalls_[name] == null) {
console.log('\'' + name + '\' wasn\'t called during this test.');
continue;
}
console.log(
'Rejecting ' + this.methodCalls_[name].length + ' \'' + name +
'\' promises.');
for (const o of this.methodCalls_[name]) {
await o.reject();
}
this.methodCalls_[name] = [];
}
}
/** @override */
requestCrostiniInstallerView() {
this.methodCalled('requestCrostiniInstallerView');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment