Google cloud storage 有谷歌云存储模拟器吗?

Google cloud storage 有谷歌云存储模拟器吗?,google-cloud-storage,cloud-storage,Google Cloud Storage,Cloud Storage,出于测试的目的,我想模拟云存储,因为它会降低测试速度 有谷歌云存储模拟器吗 谷歌目前还没有提供官方的模拟器 我目前正在使用project Minio()模拟Google Storage在开发中的行为(Minio使用文件系统作为存储后端,并提供与S3 apiV2的兼容性,后者与Google Storage兼容)。Google有一个您可以使用的工具(大多数核心功能都已实现) 在测试类路径上需要com.google.cloud:googlecloudnio(:0.25.0-alpha当前)。然后,您可

出于测试的目的,我想模拟云存储,因为它会降低测试速度


有谷歌云存储模拟器吗

谷歌目前还没有提供官方的模拟器

我目前正在使用project Minio()模拟Google Storage在开发中的行为(Minio使用文件系统作为存储后端,并提供与S3 apiV2的兼容性,后者与Google Storage兼容)。

Google有一个您可以使用的工具(大多数核心功能都已实现)

在测试类路径上需要
com.google.cloud:googlecloudnio
:0.25.0-alpha
当前)。然后,您可以使用/inject
Storage
接口,该接口由内存中的
LocalStorageHelper
testhelper服务实现

用法示例:

  import com.google.cloud.storage.Storage;
  import com.google.cloud.storage.contrib.nio.testing.LocalStorageHelper;

  @Test
  public void exampleInMemoryGoogleStorageTest() {
    Storage storage = LocalStorageHelper.getOptions().getService();

    final String blobPath = "test/path/foo.txt";
    final String testBucketName = "test-bucket";
    BlobInfo blobInfo = BlobInfo.newBuilder(
        BlobId.of(testBucketName, blobPath)
    ).build();

    storage.create(blobInfo, "randomContent".getBytes(StandardCharsets.UTF_8));
    Iterable<Blob> allBlobsIter = storage.list(testBucketName).getValues();
    // expect to find the blob we saved when iterating over bucket blobs
    assertTrue(
        StreamSupport.stream(allBlobsIter.spliterator(), false)
            .map(BlobInfo::getName)
            .anyMatch(blobPath::equals)
    );
  }
导入com.google.cloud.storage.storage;
导入com.google.cloud.storage.contrib.nio.testing.LocalStorageHelper;
@试验
public void示例MemoryGoogleStorageTest(){
Storage Storage=LocalStorageHelper.getOptions().getService();
最后一个字符串blobPath=“test/path/foo.txt”;
最终字符串testBucketName=“testbucket”;
BlobInfo BlobInfo=BlobInfo.newBuilder(
of(testBucketName,blobPath)
).build();
创建(blobInfo,“randomContent”.getBytes(StandardCharsets.UTF_8));
Iterable allBlobsIter=storage.list(testBucketName).getValues();
//希望在遍历bucket blob时找到我们保存的blob
资产真实(
StreamSupport.stream(allBlobsIter.spliterator(),false)
.map(BlobInfo::getName)
.anyMatch(blobPath::equals)
);
}

您能提供一些有关设置的详细信息吗?如果您能提供一些详细信息,我也会很高兴。您是否能够创建指向本地MinIO实例的存储/存储桶引用?或者你只是模拟调用云存储API的服务,然后通过模拟服务存储文件?我再也无法访问项目设置,但因为我回答了这个问题,谷歌开发了一个存储模拟器:该模拟器似乎只是一个实现java客户机云存储接口的java类,所以它实际上是专门为java开发者开发的,emulator被移动到了:看看这个答案,他们现在可能正在开发一个。