Skip to content

Conversation

@briandealwis
Copy link
Member

@briandealwis briandealwis commented Jun 9, 2017

I originally tried to detect this unpublished changes situation and tried to force publishing the changes. The code was becoming sufficiently icky that I punted and instead detect the situation and prompt the user whether to continue.

The fix uses the Platform/Debug prompting framework, which is somewhat baroque as you'll see. It uses a Status's plugin ID and error-code to lookup a status handler. We use the prompter status handler and ask it to punt to our custom stale-resources handler to prompt the user, returning a boolean.

screen shot 2017-06-09 at 3 59 00 pm

Fixes #1832
Fixes #1897 too

@briandealwis briandealwis requested a review from elharo June 9, 2017 20:08
SERVER_ALREADY_RUNNING_IN_MODE=Server is already running in "{0}" mode
UNABLE_TO_LAUNCH=Unable to launch App Engine server
STALE_RESOURCES_DETECTED=Stale resources detected
STALE_RESOURCES_LAUNCH_CONFIRMATION=Some recently-changed resources have not been published yet. Continue with launch?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not yet been published?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no hyphen in "recently changed".
"yet" feels redundant. I suggest deleting it completely.

point="org.eclipse.debug.core.statusHandlers">
<statusHandler
class="com.google.cloud.tools.eclipse.appengine.localserver.ui.StaleResourcesStatusHandler"
code="255"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a comment for "255" might be helpful

SERVER_ALREADY_RUNNING_IN_MODE=Server is already running in "{0}" mode
UNABLE_TO_LAUNCH=Unable to launch App Engine server
STALE_RESOURCES_DETECTED=Stale resources detected
STALE_RESOURCES_LAUNCH_CONFIRMATION=Some recently-changed resources have not been published yet. Continue with launch?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One space after period. Is it really "Recently changed" or is it "Unsaved changes"?

"Recently changed resources have not been published yet." or "Unsaved changes have not been published."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recently changed. These stale resources are usually from the user having saved their unsaved changes, which haven't been published yet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

One space after period.

@briandealwis
Copy link
Member Author

I've decided to make a few more changes.

static final int STALE_RESOURCES_CODE = 255;

/** The status object to pass into the debug prompter */
public static final IStatus CONTINUE_LAUNCH_REQUEST = new Status(IStatus.INFO,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StatusUtil.info()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a specially crafted status message; I'll add to the comment.

if (source instanceof ILaunchConfiguration) {
ILaunchConfiguration config = (ILaunchConfiguration) source;
if (DebugUITools.isPrivate(config)) {
return Boolean.FALSE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does a "private" config mean? So, if it's private, does this stop launching?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I gather, it's used for launches that aren't visible to the user. Like Ant builds or Maven builds. We could conceivably usr launches for our staging, etc. The advantage being that it's tracked and managed by the launch info.

* Check if there are pending changes to be published: this is a nasty condition that can occur if
* the user saves changes as part of launching the server.
*/
private boolean hasPendingChangesToPublish() {
Copy link
Contributor

@chanseokoh chanseokoh Jun 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just wondering if this method can be called before some ResourceChangeJob is actually scheduled?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. It may not… It should be safe to join on the AUTOBUILD job.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. However, I'm fine with the current status if that turns out too complex or not really worth.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After experimenting, we need to join on the auto build job to ensure the workspace's resource changes happen, so that we see that there are pending events for publishing.

- Change behaviour to check if there are pending changes to be published
  and prompt the user whether to continue
@briandealwis
Copy link
Member Author

PTAL @elharo @chanseokoh

chanseokoh
chanseokoh previously approved these changes Jun 12, 2017

@Override
protected void publishFinish(IProgressMonitor monitor) throws CoreException {
boolean allpublished = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allPublished

boolean allpublished = true;
IServer server = getServer();
IModule[] modules = server.getModules();
for (int i = 0; i < modules.length; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (IModule module : modules) will probably work.

@chanseokoh
Copy link
Contributor

The test failures seem very interesting. It always fails with #1897 (cf. #1975). This may shed some light on #1897.

@chanseokoh chanseokoh dismissed their stale review June 12, 2017 20:46

Dismissed until test failures are fixed.

@briandealwis
Copy link
Member Author

testDebugLaunch(com.google.cloud.tools.eclipse.integration.appengine.DebugNativeAppEngineStandardProjectTest)  Time elapsed: 28.184 sec  <<< FAILURE!
java.lang.AssertionError: No App Engine launch found
Expected: a string containing "App Engine Standard at localhost"
     but: was "<terminated>testapp [Run on Server]"
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
	at org.junit.Assert.assertThat(Assert.java:956)
	at com.google.cloud.tools.eclipse.integration.appengine.DebugNativeAppEngineStandardProjectTest.testDebugLaunch(DebugNativeAppEngineStandardProjectTest.java:107)

I improved the test to use Hamcrest's Matchers.containsString(), and what's shown is
<terminated>testapp [Run on Server]. I reproduced it locally, and the Debug view shows:
debug view

We should remove all terminated processes, I guess.

@briandealwis
Copy link
Member Author

PTAL @chanseokoh

@briandealwis briandealwis merged commit 2b18352 into master Jun 15, 2017
@briandealwis briandealwis deleted the i1832 branch June 15, 2017 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test on Kokoro Windows: DebugNativeAppEngineStandardProjectTest.testDebugLaunch() Autosave before run does not recompile

4 participants