Repository navigation
Closed
Labels
api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.
Description
Hi,
I try to create some basic testing for Google Cloud Storage. I followed the instructions and tried to create a new bucket.
Storage storage = LocalStorageHelper.getOptions().getService();
storage.create(BucketInfo.newBuilder(BUCKET_NAME).build());
This throws:
com.google.cloud.storage.StorageException: java.lang.UnsupportedOperationException
at com.google.cloud.storage.StorageException.translateAndThrow(StorageException.java:71)
at com.google.cloud.storage.StorageImpl.create(StorageImpl.java:114)
at DbAnalyzerTest.testAnalyzer(DbAnalyzerTest.java:48)
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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:643)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:820)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1128)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:782)
at org.testng.TestRunner.run(TestRunner.java:632)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
at org.testng.SuiteRunner.run(SuiteRunner.java:268)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
at org.testng.TestNG.run(TestNG.java:1064)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:124)
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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.UnsupportedOperationException
at com.google.cloud.storage.contrib.nio.testing.FakeStorageRpc.create(FakeStorageRpc.java:96)
at com.google.cloud.storage.StorageImpl$2.call(StorageImpl.java:110)
at com.google.cloud.storage.StorageImpl$2.call(StorageImpl.java:107)
at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:93)
at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:49)
at com.google.cloud.storage.StorageImpl.create(StorageImpl.java:106)
... 29 more
Metadata
Metadata
Assignees
Labels
api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.
Activity
vam-google commentedon Aug 11, 2017
Hello @Burtan, unfortunately the "in-memory" storage configuration for testing does not support many methods. More specifically it does not support:
In your example you are trying execute the create bucket operation, which is not supported by the in-memory version. To test those kind of operations you should fallback to using the "real" storage and follow these instructions.
We'll update the TESTING.md and LocalStorageHelper documentation to reduce confusion.
vam-google commentedon Aug 11, 2017
Updated the documentation. Closing this issue.
ensonic commentedon Jan 23, 2018
Is there is single example somewhere what should actually work? It would be awesome to expand
https://github.com/GoogleCloudPlatform/google-cloud-java/blob/master/TESTING.md#on-your-machine-2 a bit. I don't understand how I will be able to get any object, if I can get the bucket first.
Typical code is:
Having an example or a test for this under
https://github.com/GoogleCloudPlatform/google-cloud-java/tree/master/google-cloud-contrib/google-cloud-nio/src
would also help. Maybe you can also comment on my the api operates on classes from
com.google.api.services.storage.model.*; instead ofcom.google.cloud.storage.*(e.g. StorageObject).ensonic commentedon Feb 5, 2018
Answering my own question:
gaschler commentedon May 30, 2018
Same here, it would be great to find an example unit test that uses fake or in-memory storage.
deps: update dependency com.google.cloud:google-cloud-trace to v2.66.0 (
deps: update dependency com.google.cloud:google-cloud-trace to v2.62.0 (
deps: update actions/setup-java action to v4 (googleapis#2106)
chore(main): release 2.34.0 (googleapis#2118)