Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix regression on appEngine detection #1109

Merged
merged 3 commits into from
May 2, 2018
Merged

Conversation

jeanbza
Copy link
Member

@jeanbza jeanbza commented Apr 24, 2018

No description provided.

@jeanbza
Copy link
Member Author

jeanbza commented Apr 25, 2018

@mattwhisenhunt PTAL

Your commit 75ba03c causes a regression in some tests we don't have here. I'd like to either fully rollback that change (close out this PR, start a new PR) or go ahead with having both logic.

Which do you think is better? And could you explain 75ba03c? I don't have the context for that unfortunately.

@mattwhisenhunt
Copy link
Contributor

I didn't know at the time there was another source of truth of this repo so I didn't squash my CL. This started out as a bit of a vague issue that Les and I used a couple of PRs as a back and forth to come to the result we wanted.

Copy link
Contributor

@mattwhisenhunt mattwhisenhunt left a comment

Choose a reason for hiding this comment

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

LGTM

return false;
Class<?> systemPropertyClass = null;
try {
systemPropertyClass = forName("com.google.appengine.api.utils.SystemProperty");

This comment was marked as spam.

@lesv
Copy link

lesv commented Apr 25, 2018

There are 3 cases: Java 7 on std, Java 8 on std, and Java compat .

The change you are bringing back will look to see if the GAE libraries have been included. That won't always be the case.

It's better to use the environment variables as that will tell you reality, that always work for local development.

Typically, your trying to find out if you need to use the metadata server, or he GAE api's to get a credential. (Java 7)

(ie. what is the issue you are really trying to fix)

@jeanbza
Copy link
Member Author

jeanbza commented Apr 25, 2018

@lesv Thanks for the context. In that case, I'd like to go forward with this, since there are internal users that depend on the old case and it sounds like we're trying to convince external users to use the new environment variable case. Does that sound appropriate to you?

@ejona86
Copy link
Contributor

ejona86 commented Apr 26, 2018

@jadekler, go ahead and start an internal email thread and share the log results from the internal failing test. The test may be incorrect and should maybe be updated instead.

@lesv
Copy link

lesv commented Apr 26, 2018

Note - I should have mentioned above that there are 3 GAE cases, there are of course, other cases.
On Java 7 - the environment variables are, and if true, credentials should be gotten through the code you are adding:
GAE_ENV=standard
GAE_RUNTIME=java7

On Java 8 - Credentials should be gotten from the Metadata server:
GAE_ENV=standard
GAE_RUNTIME=java8

Flexible runtime - use Metadata server
GAE_ENV and GAE_RUNTIME are NOT SET

Locally - there should not be these environment variables set, you should get them from the normal DefaultAuth or ADC algorithm.

All other GCP runtimes should use the ADC algorithm that checks for GOOGLE_APPLICATION_CREDENTIALS, a local file, or the Metadata server.

@jeanbza jeanbza requested review from lesv and ejona86 April 26, 2018 18:02
@ejona86
Copy link
Contributor

ejona86 commented Apr 26, 2018

It's not clear to me what case is being solved by this change. @lesv, you said "credentials should be gotten through the code you are adding". But the adds are only in the detection part, not in actually retrieving the credentials.

Is this fixing Flex? Although it sounds like Flex should enable the Environment.COMPUTE_ENGINE flow. It would seem Java 8 could also use the COMPUTE_ENGINE flow, but APP_ENGINE_CREDENTIAL_CLASS may be smart enough to do the right thing (so it doesn't matter).

Copy link

@lesv lesv left a comment

Choose a reason for hiding this comment

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

My suggestions are ugly, please feel free to convert to decent reading code. They look like they should work, but once you've got it changed, I'll build something and test it. Basically, I'm telling things to prefer the metadata server if it's available.

return false;
Class<?> systemPropertyClass = null;
try {
systemPropertyClass = forName("com.google.appengine.api.utils.SystemProperty");

This comment was marked as spam.

@@ -256,7 +258,6 @@ private GoogleCredential getCredentialUsingWellKnownFile(
}
}


private boolean runningOnAppEngine() {

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@@ -256,7 +258,6 @@ private GoogleCredential getCredentialUsingWellKnownFile(
}
}


private boolean runningOnAppEngine() {
if (getEnvEquals("GAE_ENV", "standard")) {

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@@ -271,7 +272,38 @@ private boolean runningOnAppEngine() {
return true;

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Object environmentValueValue = valueMethod.invoke(environmentValue);
return (environmentValueValue != null);
} catch (NoSuchFieldException exception) {
cause = exception;

This comment was marked as spam.

This comment was marked as spam.

@jeanbza
Copy link
Member Author

jeanbza commented May 1, 2018

@lesv PTAL - incorporated your fixes

@@ -256,7 +258,6 @@ private GoogleCredential getCredentialUsingWellKnownFile(
}
}


private boolean runningOnAppEngine() {
if (getEnvEquals("GAE_ENV", "standard")) {

This comment was marked as spam.

@@ -256,7 +258,6 @@ private GoogleCredential getCredentialUsingWellKnownFile(
}
}


private boolean runningOnAppEngine() {

This comment was marked as spam.

Object environmentValueValue = valueMethod.invoke(environmentValue);
return (environmentValueValue != null);
} catch (NoSuchFieldException exception) {
cause = exception;

This comment was marked as spam.

@@ -271,7 +272,38 @@ private boolean runningOnAppEngine() {
return true;

This comment was marked as spam.

@jeanbza
Copy link
Member Author

jeanbza commented May 1, 2018

@lesv PTAL

private boolean runningOnAppEngine() {
if (getEnvEquals("GAE_ENV", "standard")) {
private boolean useGAEStandardAPI() {
if (getEnvEquals("GAE_ENV", "standard") && getEnvEquals("GAE_RUNTIME", "java7")) {
return true;

This comment was marked as spam.

This comment was marked as spam.

return (environmentValueValue != null);
} catch (NoSuchFieldException ignored) {
// If the field does not exist then we treat it as false.
} catch (SecurityException exception) {

This comment was marked as spam.

This comment was marked as spam.

return true;

if (cause != null) {
throw OAuth2Utils.exceptionWithCause(new RuntimeException(String.format(

This comment was marked as spam.

This comment was marked as spam.


if (cause != null) {
throw OAuth2Utils.exceptionWithCause(new RuntimeException(String.format(
"Unexpcted error trying to determine if runnning on Google App Engine: %s",

This comment was marked as spam.

This comment was marked as spam.

if (getEnvEquals("GAE_RUNTIME", "java8")) {
return true;
Exception cause = null;
Field environmentField;

This comment was marked as spam.

This comment was marked as spam.

@eamonnmcmanus
Copy link

LGTM

@lesv
Copy link

lesv commented May 1, 2018

You might wish to look at the tests.

java.io.IOException: MockRequestCountingTransport request failed.
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProviderTest$MockRequestUrlRecordingTransport$1.execute(DefaultCredentialProviderTest.java:584)
	at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:998)
	at com.google.api.client.googleapis.auth.oauth2.OAuth2Utils.runningOnComputeEngine(OAuth2Utils.java:86)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.detectEnvironment(DefaultCredentialProvider.java:183)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.getDefaultCredentialUnsynchronized(DefaultCredentialProvider.java:110)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.getDefaultCredential(DefaultCredentialProvider.java:91)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProviderTest.testDefaultCredentialComputeCachesFailureAfterFixedNumberOfRetries(DefaultCredentialProviderTest.java:219)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
May 01, 2018 8:00:59 PM com.google.api.client.googleapis.auth.oauth2.OAuth2Utils runningOnComputeEngine
WARNING: Failed to detect whether we are running on Google Compute Engine.
java.io.IOException: MockRequestCountingTransport request failed.
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProviderTest$MockRequestUrlRecordingTransport$1.execute(DefaultCredentialProviderTest.java:584)
	at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:998)
	at com.google.api.client.googleapis.auth.oauth2.OAuth2Utils.runningOnComputeEngine(OAuth2Utils.java:86)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.detectEnvironment(DefaultCredentialProvider.java:183)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.getDefaultCredentialUnsynchronized(DefaultCredentialProvider.java:110)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.getDefaultCredential(DefaultCredentialProvider.java:91)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProviderTest.testDefaultCredentialComputeCachesFailureAfterFixedNumberOfRetries(DefaultCredentialProviderTest.java:219)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
May 01, 2018 8:00:59 PM com.google.api.client.googleapis.auth.oauth2.OAuth2Utils runningOnComputeEngine
WARNING: Failed to detect whether we are running on Google Compute Engine.
java.io.IOException: MockRequestCountingTransport request failed.
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProviderTest$MockRequestUrlRecordingTransport$1.execute(DefaultCredentialProviderTest.java:584)
	at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:998)
	at com.google.api.client.googleapis.auth.oauth2.OAuth2Utils.runningOnComputeEngine(OAuth2Utils.java:86)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.detectEnvironment(DefaultCredentialProvider.java:183)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.getDefaultCredentialUnsynchronized(DefaultCredentialProvider.java:110)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.getDefaultCredential(DefaultCredentialProvider.java:91)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProviderTest.testDefaultCredentialComputeCachesFailureAfterFixedNumberOfRetries(DefaultCredentialProviderTest.java:219)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
May 01, 2018 8:00:59 PM com.google.api.client.googleapis.auth.oauth2.OAuth2Utils runningOnComputeEngine
WARNING: Failed to detect whether we are running on Google Compute Engine.
java.io.IOException: MockRequestCountingTransport request failed.
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProviderTest$MockRequestUrlRecordingTransport$1.execute(DefaultCredentialProviderTest.java:584)
	at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:998)
	at com.google.api.client.googleapis.auth.oauth2.OAuth2Utils.runningOnComputeEngine(OAuth2Utils.java:86)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.detectEnvironment(DefaultCredentialProvider.java:183)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.getDefaultCredentialUnsynchronized(DefaultCredentialProvider.java:110)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.getDefaultCredential(DefaultCredentialProvider.java:91)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProviderTest.testDefaultCredentialWithCustomMetadataServerAddress(DefaultCredentialProviderTest.java:253)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
May 01, 2018 8:00:59 PM com.google.api.client.googleapis.auth.oauth2.OAuth2Utils runningOnComputeEngine
WARNING: Failed to detect whether we are running on Google Compute Engine.
java.io.IOException: MockRequestCountingTransport request failed.
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProviderTest$MockRequestUrlRecordingTransport$1.execute(DefaultCredentialProviderTest.java:584)
	at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:998)
	at com.google.api.client.googleapis.auth.oauth2.OAuth2Utils.runningOnComputeEngine(OAuth2Utils.java:86)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.detectEnvironment(DefaultCredentialProvider.java:183)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.getDefaultCredentialUnsynchronized(DefaultCredentialProvider.java:110)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.getDefaultCredential(DefaultCredentialProvider.java:91)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProviderTest.testDefaultCredentialWithCustomMetadataServerAddress(DefaultCredentialProviderTest.java:253)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
May 01, 2018 8:00:59 PM com.google.api.client.googleapis.auth.oauth2.OAuth2Utils runningOnComputeEngine
WARNING: Failed to detect whether we are running on Google Compute Engine.
java.io.IOException: MockRequestCountingTransport request failed.
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProviderTest$MockRequestUrlRecordingTransport$1.execute(DefaultCredentialProviderTest.java:584)
	at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:998)
	at com.google.api.client.googleapis.auth.oauth2.OAuth2Utils.runningOnComputeEngine(OAuth2Utils.java:86)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.detectEnvironment(DefaultCredentialProvider.java:183)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.getDefaultCredentialUnsynchronized(DefaultCredentialProvider.java:110)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.getDefaultCredential(DefaultCredentialProvider.java:91)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProviderTest.testDefaultCredentialWithCustomMetadataServerAddress(DefaultCredentialProviderTest.java:253)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Tests run: 19, Failures: 1, Errors: 2, Skipped: 0, Time elapsed: 0.136 sec <<< FAILURE!
testDefaultCredentialAppEngineDeployed(com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProviderTest)  Time elapsed: 0.009 sec  <<< ERROR!
java.io.IOException: The Application Default Credentials are not available. They are available if running on Google App Engine, Google Compute Engine, or Google Cloud Shell. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.getDefaultCredential(DefaultCredentialProvider.java:98)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProviderTest.testDefaultCredentialAppEngineDeployed(DefaultCredentialProviderTest.java:85)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
testDefaultCredentialAppEngineWithoutDependencyThrowsHelpfulLoadError(com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProviderTest)  Time elapsed: 0.002 sec  <<< FAILURE!
junit.framework.AssertionFailedError: null
	at junit.framework.Assert.fail(Assert.java:47)
	at junit.framework.Assert.assertTrue(Assert.java:20)
	at junit.framework.Assert.assertFalse(Assert.java:34)
	at junit.framework.Assert.assertFalse(Assert.java:41)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProviderTest.testDefaultCredentialAppEngineWithoutDependencyThrowsHelpfulLoadError(DefaultCredentialProviderTest.java:121)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
testDefaultCredentialCaches(com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProviderTest)  Time elapsed: 0.002 sec  <<< ERROR!
java.io.IOException: The Application Default Credentials are not available. They are available if running on Google App Engine, Google Compute Engine, or Google Cloud Shell. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProvider.getDefaultCredential(DefaultCredentialProvider.java:98)
	at com.google.api.client.googleapis.auth.oauth2.DefaultCredentialProviderTest.testDefaultCredentialCaches(DefaultCredentialProviderTest.java:134)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at junit.framework.TestCase.runTest(TestCase.java:168)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:110)
	at junit.framework.TestResult.runProtected(TestResult.java:128)
	at junit.framework.TestResult.run(TestResult.java:113)
	at junit.framework.TestCase.run(TestCase.java:124)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

Copy link

@lesv lesv left a comment

Choose a reason for hiding this comment

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

I'm happy, but tests are failing, so something needs to be changed.

@jeanbza
Copy link
Member Author

jeanbza commented May 1, 2018

@lesv PTAL

Copy link
Contributor

@mattwhisenhunt mattwhisenhunt left a comment

Choose a reason for hiding this comment

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

LGTM.

I added these lines the same time I removed the reflection based app engine check. Now that its back these can go away.

@mattwhisenhunt
Copy link
Contributor

And the tests pass. 😁

@jeanbza
Copy link
Member Author

jeanbza commented May 1, 2018

Ahh ok, thanks @mattwhisenhunt that's good context 👍

@jeanbza
Copy link
Member Author

jeanbza commented May 1, 2018

Will merge this tomorrow if tap train gives thumbs up.

@jeanbza jeanbza merged commit 98c160e into googleapis:dev May 2, 2018
jeanbza added a commit to jeanbza/google-api-java-client that referenced this pull request Jul 5, 2018
The method runningOnAppEngine was recently renamed to useGAEStandardAPI, and
its logic was changed in
googleapis#1109 and
googleapis@75ba03c.

This commit reverts back to the original logic before either of those commits.

The reason for the revert is that several deployments failed with this change internally. See b/111173267, b/111149869.
jeanbza added a commit that referenced this pull request Jul 9, 2018
The method runningOnAppEngine was recently renamed to useGAEStandardAPI, and
its logic was changed in
#1109 and
75ba03c.

This commit reverts back to the original logic before either of those commits.

The reason for the revert is that several deployments failed with this change internally. See b/111173267, b/111149869.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants