disable sdk v1 and ceph tests

This commit is contained in:
Anatoly Karlov 2023-04-18 19:51:12 +03:00
parent 34161553d2
commit 98640fe376
19 changed files with 37 additions and 98 deletions

View File

@ -7,4 +7,4 @@ on:
jobs: jobs:
build: build:
uses: valitydev/java-workflow/.github/workflows/maven-service-build.yml@v1 uses: valitydev/java-workflow/.github/workflows/maven-service-build.yml@v2

View File

@ -12,7 +12,7 @@ env:
jobs: jobs:
deploy: deploy:
uses: valitydev/java-workflow/.github/workflows/maven-service-deploy.yml@v1 uses: valitydev/java-workflow/.github/workflows/maven-service-deploy.yml@v2
secrets: secrets:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
mm-webhook-url: ${{ secrets.MATTERMOST_WEBHOOK_URL }} mm-webhook-url: ${{ secrets.MATTERMOST_WEBHOOK_URL }}

View File

@ -5,30 +5,10 @@ access an Amazon S3 resource without requiring the user of the URL to know the a
## Параметры запуска ## Параметры запуска
Для работы с 1 версией `AWS SDK S3`
```yaml
s3:
endpoint: 'http://127.0.0.1:32827'
bucket-name: 'files'
signing-region: 'RU'
client-protocol: 'http'
client-max-error-retry: 10
signer-override: 'S3SignerType'
# signer-override: 'AWSS3V4SignerType'
access-key: 'test'
secret-key: 'test'
s3-sdk-v2:
enabled: 'false'
```
дефолтная версия сигнера — `S3SignerType`, для использования более актуальной версии указывается `AWSS3V4SignerType`
Для работы с 2 версией `AWS SDK S3 V2` Для работы с 2 версией `AWS SDK S3 V2`
```yaml ```yaml
s3-sdk-v2: s3-sdk-v2:
enabled: 'true'
endpoint: 'http://127.0.0.1:9000' endpoint: 'http://127.0.0.1:9000'
bucket-name: 'files-v2' bucket-name: 'files-v2'
region: 'RU' region: 'RU'
@ -36,9 +16,6 @@ s3-sdk-v2:
secret-key: 'minio123' secret-key: 'minio123'
``` ```
Для работы сервиса может использоваться только одна из двух версий `AWS SDK S3`, переключение происходит
параметром `s3-sdk-v2.enabled=false`
## Minio ## Minio
Если сервисом используется 2 версия `AWS SDK S3 V2`, и в качестве s3 кластера используется `minio`, то для поддержки Если сервисом используется 2 версия `AWS SDK S3 V2`, и в качестве s3 кластера используется `minio`, то для поддержки

14
pom.xml
View File

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>dev.vality</groupId> <groupId>dev.vality</groupId>
<artifactId>service-parent-pom</artifactId> <artifactId>service-parent-pom</artifactId>
<version>1.0.19</version> <version>2.1.4</version>
</parent> </parent>
<artifactId>file-storage</artifactId> <artifactId>file-storage</artifactId>
@ -30,7 +30,7 @@
<dependency> <dependency>
<groupId>dev.vality</groupId> <groupId>dev.vality</groupId>
<artifactId>file-storage-proto</artifactId> <artifactId>file-storage-proto</artifactId>
<version>1.44-1dbc006</version> <version>1.45-321e0e8</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>dev.vality</groupId> <groupId>dev.vality</groupId>
@ -78,12 +78,12 @@
<dependency> <dependency>
<groupId>com.amazonaws</groupId> <groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId> <artifactId>aws-java-sdk-s3</artifactId>
<version>1.12.300</version> <version>1.12.451</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>software.amazon.awssdk</groupId> <groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId> <artifactId>s3</artifactId>
<version>2.17.271</version> <version>2.20.48</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
@ -107,7 +107,7 @@
<dependency> <dependency>
<groupId>dev.vality</groupId> <groupId>dev.vality</groupId>
<artifactId>testcontainers-annotations</artifactId> <artifactId>testcontainers-annotations</artifactId>
<version>1.4.3</version> <version>2.0.2</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
@ -142,12 +142,12 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-remote-resources-plugin</artifactId> <artifactId>maven-remote-resources-plugin</artifactId>
<version>1.7.0</version> <version>3.0.0</version>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.maven.shared</groupId> <groupId>org.apache.maven.shared</groupId>
<artifactId>maven-filtering</artifactId> <artifactId>maven-filtering</artifactId>
<version>3.3.0</version> <version>3.3.1</version>
</dependency> </dependency>
</dependencies> </dependencies>
<configuration> <configuration>

View File

@ -12,13 +12,11 @@ import com.amazonaws.services.s3.transfer.TransferManager;
import com.amazonaws.services.s3.transfer.TransferManagerBuilder; import com.amazonaws.services.s3.transfer.TransferManagerBuilder;
import dev.vality.file.storage.configuration.properties.S3Properties; import dev.vality.file.storage.configuration.properties.S3Properties;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration //@Configuration
@RequiredArgsConstructor @RequiredArgsConstructor
@EnableConfigurationProperties(S3Properties.class) //@EnableConfigurationProperties(S3Properties.class)
public class S3ClientConfig { public class S3ClientConfig {
private final S3Properties s3Properties; private final S3Properties s3Properties;

View File

@ -3,13 +3,11 @@ package dev.vality.file.storage.configuration.properties;
import com.amazonaws.Protocol; import com.amazonaws.Protocol;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Getter @Getter
@Setter @Setter
@Component //@Component
@ConfigurationProperties("s3") //@ConfigurationProperties("s3")
public class S3Properties { public class S3Properties {
private String endpoint; private String endpoint;

View File

@ -6,12 +6,9 @@ import dev.vality.file.storage.FileStorageSrv;
import dev.vality.file.storage.NewFileResult; import dev.vality.file.storage.NewFileResult;
import dev.vality.file.storage.service.StorageService; import dev.vality.file.storage.service.StorageService;
import dev.vality.file.storage.service.exception.FileNotFoundException; import dev.vality.file.storage.service.exception.FileNotFoundException;
import dev.vality.file.storage.service.exception.StorageException;
import dev.vality.file.storage.util.CheckerUtil; import dev.vality.file.storage.util.CheckerUtil;
import dev.vality.geck.common.util.TypeUtil; import dev.vality.geck.common.util.TypeUtil;
import dev.vality.msgpack.Value; import dev.vality.msgpack.Value;
import dev.vality.woody.api.flow.error.WUnavailableResultException;
import dev.vality.woody.api.flow.error.WUndefinedResultException;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.thrift.TException; import org.apache.thrift.TException;
@ -30,14 +27,8 @@ public class FileStorageHandler implements FileStorageSrv.Iface {
@Override @Override
public NewFileResult createNewFile(Map<String, Value> metadata, String expiresAt) throws TException { public NewFileResult createNewFile(Map<String, Value> metadata, String expiresAt) throws TException {
try { var instant = TypeUtil.stringToInstant(expiresAt);
Instant instant = TypeUtil.stringToInstant(expiresAt); return storageService.createNewFile(metadata, instant);
return storageService.createNewFile(metadata, instant);
} catch (StorageException e) {
throw unavailableResultException(e);
} catch (Exception e) {
throw undefinedResultException("Error when \"createNewFile\"", e);
}
} }
@Override @Override
@ -50,10 +41,6 @@ public class FileStorageHandler implements FileStorageSrv.Iface {
return url.toString(); return url.toString();
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw fileNotFound(e); throw fileNotFound(e);
} catch (StorageException e) {
throw unavailableResultException(e);
} catch (Exception e) {
throw undefinedResultException("Error when \"generateDownloadUrl\"", e);
} }
} }
@ -64,10 +51,6 @@ public class FileStorageHandler implements FileStorageSrv.Iface {
return storageService.getFileData(fileDataId); return storageService.getFileData(fileDataId);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
throw fileNotFound(e); throw fileNotFound(e);
} catch (StorageException e) {
throw unavailableResultException(e);
} catch (Exception e) {
throw undefinedResultException("Error when \"getFileData\"", e);
} }
} }
@ -75,14 +58,4 @@ public class FileStorageHandler implements FileStorageSrv.Iface {
log.warn("File not found", e); log.warn("File not found", e);
return new FileNotFound(); return new FileNotFound();
} }
private WUnavailableResultException unavailableResultException(StorageException e) {
log.error("Error with storage", e);
return new WUnavailableResultException("Error with storage", e);
}
private WUndefinedResultException undefinedResultException(String msg, Exception e) {
log.error(msg, e);
return new WUndefinedResultException(msg, e);
}
} }

View File

@ -19,8 +19,6 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.ToString; import lombok.ToString;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy; import javax.annotation.PreDestroy;
@ -34,8 +32,7 @@ import java.util.stream.Collectors;
import static java.lang.String.format; import static java.lang.String.format;
@Service //@Service
@ConditionalOnProperty(value = "s3-sdk-v2.enabled", havingValue = "false")
@Slf4j @Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
public class S3Service implements StorageService { public class S3Service implements StorageService {

View File

@ -11,7 +11,6 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.ToString; import lombok.ToString;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.core.sync.RequestBody;
import software.amazon.awssdk.services.s3.S3Client; import software.amazon.awssdk.services.s3.S3Client;
@ -29,7 +28,6 @@ import java.util.function.Predicate;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@ConditionalOnProperty(value = "s3-sdk-v2.enabled", havingValue = "true")
@Slf4j @Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
public class S3V2Service implements StorageService { public class S3V2Service implements StorageService {

View File

@ -8,7 +8,7 @@ import javax.servlet.*;
import javax.servlet.annotation.WebServlet; import javax.servlet.annotation.WebServlet;
import java.io.IOException; import java.io.IOException;
@WebServlet("/file_storage") @WebServlet("/file_storage/v2")
@RequiredArgsConstructor @RequiredArgsConstructor
public class FileStorageServlet extends GenericServlet { public class FileStorageServlet extends GenericServlet {

View File

@ -1,19 +1,19 @@
info: info:
version: '@project.version@' version: '${project.version}'
stage: dev stage: dev
server: server:
port: '@server.port@' port: '${server.port}'
management: management:
server: server:
port: '@management.port@' port: '${management.port}'
metrics: metrics:
export: export:
prometheus: prometheus:
enabled: false enabled: false
tags: tags:
application: '@project.name@' application: '${project.name}'
endpoint: endpoint:
health: health:
probes: probes:
@ -30,24 +30,12 @@ management:
spring: spring:
application: application:
name: '@project.name@' name: '${project.name}'
output: output:
ansi: ansi:
enabled: always enabled: always
s3:
endpoint: 'http://127.0.0.1:9000'
bucket-name: 'files'
signing-region: 'RU'
client-protocol: 'http'
client-max-error-retry: 10
# signer-override: 'S3SignerType'
signer-override: 'AWSS3V4SignerType'
access-key: 'minio'
secret-key: 'minio123'
s3-sdk-v2: s3-sdk-v2:
enabled: 'false'
endpoint: 'http://127.0.0.1:9000' endpoint: 'http://127.0.0.1:9000'
bucket-name: 'files-v2' bucket-name: 'files-v2'
region: 'RU' region: 'RU'

View File

@ -6,6 +6,7 @@ import com.amazonaws.services.s3.transfer.TransferManager;
import dev.vality.woody.api.flow.error.WRuntimeException; import dev.vality.woody.api.flow.error.WRuntimeException;
import dev.vality.woody.thrift.impl.http.THSpawnClientBuilder; import dev.vality.woody.thrift.impl.http.THSpawnClientBuilder;
import org.apache.thrift.TException; import org.apache.thrift.TException;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
@ -18,6 +19,7 @@ import java.util.UUID;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
@Disabled
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class CatchExceptionsTest { public class CatchExceptionsTest {
@ -33,7 +35,7 @@ public class CatchExceptionsTest {
@Test @Test
public void shouldThrowException() throws URISyntaxException, TException { public void shouldThrowException() throws URISyntaxException, TException {
FileStorageSrv.Iface fileStorageCli = new THSpawnClientBuilder() FileStorageSrv.Iface fileStorageCli = new THSpawnClientBuilder()
.withAddress(new URI("http://localhost:" + port + "/file_storage")) .withAddress(new URI("http://localhost:" + port + "/file_storage/v2"))
.withNetworkTimeout(555000) .withNetworkTimeout(555000)
.build(FileStorageSrv.Iface.class); .build(FileStorageSrv.Iface.class);

View File

@ -51,7 +51,7 @@ public abstract class FileStorageTest {
@BeforeEach @BeforeEach
public void setUp() throws Exception { public void setUp() throws Exception {
fileStorageClient = new THSpawnClientBuilder() fileStorageClient = new THSpawnClientBuilder()
.withAddress(new URI("http://localhost:" + port + "/file_storage")) .withAddress(new URI("http://localhost:" + port + "/file_storage/v2"))
.withNetworkTimeout(TIMEOUT) .withNetworkTimeout(TIMEOUT)
.build(FileStorageSrv.Iface.class); .build(FileStorageSrv.Iface.class);
} }

View File

@ -2,7 +2,9 @@ package dev.vality.file.storage.awssdks3v2;
import dev.vality.file.storage.FileStorageTest; import dev.vality.file.storage.FileStorageTest;
import dev.vality.testcontainers.annotations.ceph.CephTestcontainerSingleton; import dev.vality.testcontainers.annotations.ceph.CephTestcontainerSingleton;
import org.junit.jupiter.api.Disabled;
@Disabled
@CephTestcontainerSingleton( @CephTestcontainerSingleton(
properties = {"s3-sdk-v2.enabled=true", "s3-sdk-v2.region=us-east-1"}, properties = {"s3-sdk-v2.enabled=true", "s3-sdk-v2.region=us-east-1"},
bucketName = "awssdks3v2") bucketName = "awssdks3v2")

View File

@ -3,8 +3,6 @@ package dev.vality.file.storage.awssdks3v2;
import dev.vality.file.storage.FileStorageTest; import dev.vality.file.storage.FileStorageTest;
import dev.vality.testcontainers.annotations.minio.MinioTestcontainerSingleton; import dev.vality.testcontainers.annotations.minio.MinioTestcontainerSingleton;
@MinioTestcontainerSingleton( @MinioTestcontainerSingleton(bucketName = "awssdks3v2")
properties = "s3-sdk-v2.enabled=true",
bucketName = "awssdks3v2")
public class WithMinioTest extends FileStorageTest { public class WithMinioTest extends FileStorageTest {
} }

View File

@ -2,7 +2,9 @@ package dev.vality.file.storage.s3signer;
import dev.vality.file.storage.FileStorageTest; import dev.vality.file.storage.FileStorageTest;
import dev.vality.testcontainers.annotations.ceph.CephTestcontainerSingleton; import dev.vality.testcontainers.annotations.ceph.CephTestcontainerSingleton;
import org.junit.jupiter.api.Disabled;
@Disabled
@CephTestcontainerSingleton(bucketName = "s3signer") @CephTestcontainerSingleton(bucketName = "s3signer")
public class WithCephTest extends FileStorageTest { public class WithCephTest extends FileStorageTest {
} }

View File

@ -2,7 +2,9 @@ package dev.vality.file.storage.s3signer;
import dev.vality.file.storage.FileStorageTest; import dev.vality.file.storage.FileStorageTest;
import dev.vality.testcontainers.annotations.minio.MinioTestcontainerSingleton; import dev.vality.testcontainers.annotations.minio.MinioTestcontainerSingleton;
import org.junit.jupiter.api.Disabled;
@Disabled
@MinioTestcontainerSingleton(bucketName = "s3signer") @MinioTestcontainerSingleton(bucketName = "s3signer")
public class WithMinioTest extends FileStorageTest { public class WithMinioTest extends FileStorageTest {
} }

View File

@ -2,7 +2,9 @@ package dev.vality.file.storage.s3v4signer;
import dev.vality.file.storage.FileStorageTest; import dev.vality.file.storage.FileStorageTest;
import dev.vality.testcontainers.annotations.ceph.CephTestcontainerSingleton; import dev.vality.testcontainers.annotations.ceph.CephTestcontainerSingleton;
import org.junit.jupiter.api.Disabled;
@Disabled
@CephTestcontainerSingleton( @CephTestcontainerSingleton(
properties = "s3.signer-override=AWSS3V4SignerType", properties = "s3.signer-override=AWSS3V4SignerType",
bucketName = "s3v4signer") bucketName = "s3v4signer")

View File

@ -2,7 +2,9 @@ package dev.vality.file.storage.s3v4signer;
import dev.vality.file.storage.FileStorageTest; import dev.vality.file.storage.FileStorageTest;
import dev.vality.testcontainers.annotations.minio.MinioTestcontainerSingleton; import dev.vality.testcontainers.annotations.minio.MinioTestcontainerSingleton;
import org.junit.jupiter.api.Disabled;
@Disabled
@MinioTestcontainerSingleton( @MinioTestcontainerSingleton(
properties = "s3.signer-override=AWSS3V4SignerType", properties = "s3.signer-override=AWSS3V4SignerType",
bucketName = "s3v4signer") bucketName = "s3v4signer")