diff --git a/.github/workflows/hermes-tests-ci.yaml b/.github/workflows/hermes-tests-ci.yaml new file mode 100644 index 0000000..b874611 --- /dev/null +++ b/.github/workflows/hermes-tests-ci.yaml @@ -0,0 +1,40 @@ +name: Hermes - Build and Test Tests Service + +on: + push: + paths: + - "hermes-tests/**" + - ".github/workflows/hermes-tests-ci.yaml" + + pull_request: + paths: + - "hermes-tests/**" + - ".github/workflows/hermes-tests-ci.yaml" + +env: + HERMES_CONFIG: ${{ secrets.HERMES_CONFIG }} + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: dart-lang/setup-dart@v1 + with: + sdk: 2.19.2 + + - name: Get dependencies + run: | + cd hermes-tests + dart pub get + + - name: Format code + run: dart format --set-exit-if-changed . + + - name: Analyze code + run: dart analyze + + - name: Test + run: dart test diff --git a/hermes-tests/.dockerignore b/hermes-tests/.dockerignore index c3cd8b6..1f3ec55 100644 --- a/hermes-tests/.dockerignore +++ b/hermes-tests/.dockerignore @@ -1,6 +1,7 @@ .vscode/ .idea/ .dart_tool/ +.fvm* test/ temp/test/ *.md diff --git a/hermes-tests/.gitignore b/hermes-tests/.gitignore index 692cac2..fe4bde3 100644 --- a/hermes-tests/.gitignore +++ b/hermes-tests/.gitignore @@ -3,7 +3,11 @@ .dart_tool/ .idea/ .vscode/ -temp/ +#temp/ logs/ config.json -.env \ No newline at end of file +.env + +# FVM Version Cache +.fvm/ +.fvmrc \ No newline at end of file diff --git a/hermes-tests/bin/client.dart b/hermes-tests/bin/client.dart index f64ad73..12e3a06 100644 --- a/hermes-tests/bin/client.dart +++ b/hermes-tests/bin/client.dart @@ -6,7 +6,7 @@ import 'package:hermes_tests/domain/core/file_log_output.dart'; import 'package:logger/logger.dart'; Future main(List arguments) async { - final config = Config.fromJsonFile('config.json'); + final config = Config.fromEnv('HERMES_CONFIG'); final serverConfig = ServerConfig.fromJson(config.dev); final logger = Logger( diff --git a/hermes-tests/temp/test/archived/sum/1-invalid.tar.gz b/hermes-tests/temp/test/archived/sum/1-invalid.tar.gz new file mode 100644 index 0000000..22fbc75 Binary files /dev/null and b/hermes-tests/temp/test/archived/sum/1-invalid.tar.gz differ diff --git a/hermes-tests/temp/test/archived/sum/1-oversize.zip b/hermes-tests/temp/test/archived/sum/1-oversize.zip new file mode 100644 index 0000000..899e087 Binary files /dev/null and b/hermes-tests/temp/test/archived/sum/1-oversize.zip differ diff --git a/hermes-tests/temp/test/archived/sum/1-valid.zip b/hermes-tests/temp/test/archived/sum/1-valid.zip new file mode 100644 index 0000000..9a2c576 Binary files /dev/null and b/hermes-tests/temp/test/archived/sum/1-valid.zip differ diff --git a/hermes-tests/temp/test/archived/sum/1.zip b/hermes-tests/temp/test/archived/sum/1.zip new file mode 100644 index 0000000..9a2c576 Binary files /dev/null and b/hermes-tests/temp/test/archived/sum/1.zip differ diff --git a/hermes-tests/temp/test/archived/sum/4.zip b/hermes-tests/temp/test/archived/sum/4.zip new file mode 100644 index 0000000..22fbc75 Binary files /dev/null and b/hermes-tests/temp/test/archived/sum/4.zip differ diff --git a/hermes-tests/temp/test/unarchived/sum/2/input.txt b/hermes-tests/temp/test/unarchived/sum/2/input.txt new file mode 100644 index 0000000..92880af --- /dev/null +++ b/hermes-tests/temp/test/unarchived/sum/2/input.txt @@ -0,0 +1 @@ +1 1 \ No newline at end of file diff --git a/hermes-tests/temp/test/unarchived/sum/2/output.txt b/hermes-tests/temp/test/unarchived/sum/2/output.txt new file mode 100644 index 0000000..d8263ee --- /dev/null +++ b/hermes-tests/temp/test/unarchived/sum/2/output.txt @@ -0,0 +1 @@ +2 \ No newline at end of file diff --git a/hermes-tests/temp/test/unarchived/sum/6/input.txt b/hermes-tests/temp/test/unarchived/sum/6/input.txt new file mode 100644 index 0000000..92880af --- /dev/null +++ b/hermes-tests/temp/test/unarchived/sum/6/input.txt @@ -0,0 +1 @@ +1 1 \ No newline at end of file diff --git a/hermes-tests/test/api/server/hermes_grpc_server_integration_test.dart b/hermes-tests/test/api/server/hermes_grpc_server_integration_test.dart index babd364..b94f718 100644 --- a/hermes-tests/test/api/server/hermes_grpc_server_integration_test.dart +++ b/hermes-tests/test/api/server/hermes_grpc_server_integration_test.dart @@ -50,9 +50,9 @@ void main() { 'Then the uploaded test is accessible from the remote firebase cloud storage', () async { // Arrange - final String testPath = 'temp/test/archived/marsx/1-valid.zip'; + final String testPath = 'temp/test/archived/sum/1-valid.zip'; final Metadata testMetadata = Metadata() - ..problemId = 'marsx' + ..problemId = 'sum' ..testId = '10' ..testSize = File(testPath).lengthSync(); @@ -100,7 +100,7 @@ void main() { () async { // Arrange final request = DownloadRequest() - ..problemId = 'marsx' + ..problemId = 'sum' ..testId = '9'; // Act @@ -133,9 +133,9 @@ void main() { 'Then the test is deleted from the remote firebase cloud storage', () async { // Arrange - final String testPath = 'temp/test/archived/marsx/1-valid.zip'; + final String testPath = 'temp/test/archived/sum/1-valid.zip'; final Metadata testMetadata = Metadata() - ..problemId = 'marsx' + ..problemId = 'sum' ..testId = '10' ..testSize = File(testPath).lengthSync(); @@ -154,6 +154,14 @@ void main() { // Assert expect(response.status.code, StatusCode.Ok); + final String localTestArchivePath = + '${testConfig.tempLocalArchivedTestFolder}/${testMetadata.problemId}/${testMetadata.testId}.zip'; + final String localTestPath = + '${testConfig.tempLocalUnarchivedTestFolder}/${testMetadata.problemId}/${testMetadata.testId}'; + + FileManager.disposeLocalFile(localTestArchivePath); + FileManager.disposeLocalDirectory(localTestPath); + client.close(); }); @@ -163,7 +171,7 @@ void main() { 'Then the download link is successfully retrieved', () async { // Arrange final request = GetDownloadLinkForTestRequest() - ..problemId = 'marsx' + ..problemId = 'sum' ..testId = '9'; // Act diff --git a/hermes-tests/test/application/use_cases/download/download_test_use_case_unit_test.dart b/hermes-tests/test/application/use_cases/download/download_test_use_case_unit_test.dart index c49f9a8..7011d4f 100644 --- a/hermes-tests/test/application/use_cases/download/download_test_use_case_unit_test.dart +++ b/hermes-tests/test/application/use_cases/download/download_test_use_case_unit_test.dart @@ -23,7 +23,7 @@ void main() { group('Download Test UseCase Unit Tests', () { setUpAll(() { testConfig = ServerConfig.fromJson( - Config.fromJsonFile('config.json').test, + Config.fromEnv('HERMES_CONFIG').test, ); mockTestRepository = MockTestRepository(); final logger = Logger( @@ -52,7 +52,7 @@ void main() { () async { // Arrange final TestMetadata requestTestMetadata = TestMetadata.testToDownload( - problemId: 'marsx', + problemId: 'sum', testId: '2', fromDir: testConfig.remoteUnarchivedTestFolder, toDir: testConfig.tempLocalUnarchivedTestFolder, @@ -84,7 +84,7 @@ void main() { 'Then localTestNotFound storage failure is returned', () async { // Arrange final TestMetadata requestTestMetadata = TestMetadata.testToDownload( - problemId: 'marsx', + problemId: 'sum', testId: '6', fromDir: testConfig.remoteUnarchivedTestFolder, toDir: testConfig.tempLocalUnarchivedTestFolder, @@ -122,7 +122,7 @@ void main() { 'Then unexpected storage failure is returned', () async { // Arrange final TestMetadata requestTestMetadata = TestMetadata.testToDownload( - problemId: 'marsx', + problemId: 'sum', testId: '5', fromDir: testConfig.remoteUnarchivedTestFolder, toDir: testConfig.tempLocalUnarchivedTestFolder, @@ -163,7 +163,7 @@ void main() { 'Then unexpected storage failure is returned', () async { // Arrange final TestMetadata requestTestMetadata = TestMetadata.testToUpload( - problemId: 'marsx', + problemId: 'sum', testId: '5', fromDir: testConfig.remoteUnarchivedTestFolder, toDir: testConfig.tempLocalUnarchivedTestFolder, diff --git a/hermes-tests/test/application/use_cases/download/encode_test_use_case_unit_test.dart b/hermes-tests/test/application/use_cases/download/encode_test_use_case_unit_test.dart index 9aaecfd..42ea027 100644 --- a/hermes-tests/test/application/use_cases/download/encode_test_use_case_unit_test.dart +++ b/hermes-tests/test/application/use_cases/download/encode_test_use_case_unit_test.dart @@ -19,7 +19,7 @@ void main() { group('Encode Test UseCase Unit Tests', () { setUpAll(() { testConfig = ServerConfig.fromJson( - Config.fromJsonFile('config.json').test, + Config.fromEnv('HERMES_CONFIG').test, ); final logger = Logger( output: FileLogOutput( @@ -42,7 +42,7 @@ void main() { 'Then metadata for corresponding archived test is returned', () async { // Arrange final TestMetadata testMetadata = TestMetadata.testToEncode( - problemId: 'marsx', + problemId: 'sum', testId: '2', archiveTypeExtension: testConfig.archiveTypeExtension, fromDir: testConfig.tempLocalUnarchivedTestFolder, @@ -77,7 +77,7 @@ void main() { 'Then metadata for corresponding archived test is returned', () async { // Arrange final TestMetadata testMetadata = TestMetadata.testToEncode( - problemId: 'marsx', + problemId: 'sum', testId: '1', archiveTypeExtension: testConfig.archiveTypeExtension, fromDir: testConfig.tempLocalUnarchivedTestFolder, @@ -103,7 +103,7 @@ void main() { 'Then localTestNotFound storage failure is returned', () async { // Arrange final TestMetadata testMetadata = TestMetadata.testToEncode( - problemId: 'marsx', + problemId: 'sum', testId: '3', archiveTypeExtension: testConfig.archiveTypeExtension, fromDir: testConfig.tempLocalUnarchivedTestFolder, @@ -135,7 +135,7 @@ void main() { 'Then invalidLocalTestFormat storage failure is returned', () async { // Arrange final TestMetadata testMetadata = TestMetadata.testToEncode( - problemId: 'marsx', + problemId: 'sum', testId: '6', archiveTypeExtension: testConfig.archiveTypeExtension, fromDir: testConfig.tempLocalUnarchivedTestFolder, @@ -167,7 +167,7 @@ void main() { 'Then unexpected storage failure is returned', () async { // Arrange final TestMetadata testMetadata = TestMetadata.testToDecode( - problemId: 'marsx', + problemId: 'sum', testId: '6', archiveTypeExtension: testConfig.archiveTypeExtension, fromDir: testConfig.tempLocalUnarchivedTestFolder, diff --git a/hermes-tests/test/application/use_cases/download/fragment_test_use_case_unit_test.dart b/hermes-tests/test/application/use_cases/download/fragment_test_use_case_unit_test.dart index 4084bf0..daa9a3f 100644 --- a/hermes-tests/test/application/use_cases/download/fragment_test_use_case_unit_test.dart +++ b/hermes-tests/test/application/use_cases/download/fragment_test_use_case_unit_test.dart @@ -19,7 +19,7 @@ void main() { group('Fragment Test UseCase Unit Tests', () { setUpAll(() { testConfig = ServerConfig.fromJson( - Config.fromJsonFile('config.json').test, + Config.fromEnv('HERMES_CONFIG').test, ); final logger = Logger( output: FileLogOutput( @@ -42,7 +42,7 @@ void main() { 'Then a stream of chunks is returned', () async { // Arrange final TestMetadata testMetadata = TestMetadata.testToFragment( - problemId: 'marsx', + problemId: 'sum', testId: '1', archiveTypeExtension: testConfig.archiveTypeExtension, fromDir: testConfig.tempLocalArchivedTestFolder, @@ -78,7 +78,7 @@ void main() { 'Then localTestNotFound storage failure is returned', () async { // Arrange final TestMetadata testMetadata = TestMetadata.testToFragment( - problemId: 'marsx', + problemId: 'sum', testId: '7', archiveTypeExtension: testConfig.archiveTypeExtension, fromDir: testConfig.tempLocalArchivedTestFolder, @@ -108,7 +108,7 @@ void main() { 'Then invalidLocalTestFormat storage failure is returned', () async { // Arrange final TestMetadata testMetadata = TestMetadata.testToFragment( - problemId: 'marsx', + problemId: 'sum', testId: '4', archiveTypeExtension: testConfig.archiveTypeExtension, fromDir: testConfig.tempLocalArchivedTestFolder, @@ -138,7 +138,7 @@ void main() { 'Then unexpected storage failure is returned', () async { // Arrange final TestMetadata testMetadata = TestMetadata.testToUpload( - problemId: 'marsx', + problemId: 'sum', testId: '4', fromDir: testConfig.tempLocalUnarchivedTestFolder, toDir: testConfig.remoteUnarchivedTestFolder, diff --git a/hermes-tests/test/application/use_cases/upload/decode_test_use_case_unit_test.dart b/hermes-tests/test/application/use_cases/upload/decode_test_use_case_unit_test.dart index bf88dfe..b49c4ca 100644 --- a/hermes-tests/test/application/use_cases/upload/decode_test_use_case_unit_test.dart +++ b/hermes-tests/test/application/use_cases/upload/decode_test_use_case_unit_test.dart @@ -19,7 +19,7 @@ void main() { group('Decode Test UseCase Unit Tests', () { setUpAll(() { testConfig = ServerConfig.fromJson( - Config.fromJsonFile('config.json').test, + Config.fromEnv('HERMES_CONFIG').test, ); final logger = Logger( output: FileLogOutput( @@ -43,7 +43,7 @@ void main() { () async { // Arrange final TestMetadata testMetadata = TestMetadata.testToDecode( - problemId: 'marsx', + problemId: 'sum', testId: '1', archiveTypeExtension: testConfig.archiveTypeExtension, fromDir: testConfig.tempLocalArchivedTestFolder, @@ -86,7 +86,7 @@ void main() { 'Then localTestNotFound storage failure is returned', () async { // Arrange final TestMetadata testMetadata = TestMetadata.testToDecode( - problemId: 'marsx', + problemId: 'sum', testId: '3', archiveTypeExtension: testConfig.archiveTypeExtension, fromDir: testConfig.tempLocalArchivedTestFolder, @@ -118,7 +118,7 @@ void main() { 'Then invalidLocalTestFormat storage failure is returned', () async { // Arrange final TestMetadata testMetadata = TestMetadata.testToDecode( - problemId: 'marsx', + problemId: 'sum', testId: '4', archiveTypeExtension: testConfig.archiveTypeExtension, fromDir: testConfig.tempLocalArchivedTestFolder, @@ -150,7 +150,7 @@ void main() { 'Then unexpected storage failure is returned', () async { // Arrange final TestMetadata testMetadata = TestMetadata.testToEncode( - problemId: 'marsx', + problemId: 'sum', testId: '4', archiveTypeExtension: testConfig.archiveTypeExtension, fromDir: testConfig.tempLocalArchivedTestFolder, diff --git a/hermes-tests/test/application/use_cases/upload/defragment_test_use_case_unit_test.dart b/hermes-tests/test/application/use_cases/upload/defragment_test_use_case_unit_test.dart index b499af7..7b510ba 100644 --- a/hermes-tests/test/application/use_cases/upload/defragment_test_use_case_unit_test.dart +++ b/hermes-tests/test/application/use_cases/upload/defragment_test_use_case_unit_test.dart @@ -21,7 +21,7 @@ void main() { group('Defragment Test UseCase Unit Tests', () { setUpAll(() async { testConfig = ServerConfig.fromJson( - Config.fromJsonFile('config.json').test, + Config.fromEnv('HERMES_CONFIG').test, ); final logger = Logger( output: FileLogOutput( @@ -44,11 +44,11 @@ void main() { 'Then the test is successfully written on disk ' 'and associated metadata is returned', () async { // Arrange - final String inputPath = 'temp/test/archived/marsx/1-valid.zip'; + final String inputPath = 'temp/test/archived/sum/1-valid.zip'; final int testSize = File(inputPath).lengthSync(); final Metadata metadata = Metadata() - ..problemId = 'marsx' + ..problemId = 'sum' ..testId = '2' ..testSize = testSize; @@ -89,11 +89,11 @@ void main() { 'When defragment test use case is called, ' 'Then invalidLocalTestFormat storage failure is returned', () async { // Arrange - final String inputPath = 'temp/test/archived/marsx/1-invalid.tar.xz'; + final String inputPath = 'temp/test/archived/sum/1-invalid.tar.gz'; final int testSize = File(inputPath).lengthSync(); final Metadata metadata = Metadata() - ..problemId = 'marsx' + ..problemId = 'sum' ..testId = '2' ..testSize = testSize; @@ -134,11 +134,11 @@ void main() { 'When defragment test use case is called, ' 'Then testSizeLimitExceeded storage failure is returned', () async { // Arrange - final String inputPath = 'temp/test/archived/marsx/1-oversize.zip'; + final String inputPath = 'temp/test/archived/sum/1-oversize.zip'; final int testSize = File(inputPath).lengthSync(); final Metadata metadata = Metadata() - ..problemId = 'marsx' + ..problemId = 'sum' ..testId = '2' ..testSize = testSize; @@ -179,11 +179,11 @@ void main() { 'When defragment test use case is called, ' 'Then unexpected storage failure is returned', () async { // Arrange - final String inputPath = 'temp/test/archived/marsx/1-oversize.zip'; + final String inputPath = 'temp/test/archived/sum/1-oversize.zip'; final int testSize = File(inputPath).lengthSync(); final Metadata metadata = Metadata() - ..problemId = 'marsx' + ..problemId = 'sum' ..testId = '2' ..testSize = testSize; diff --git a/hermes-tests/test/application/use_cases/upload/upload_test_use_case_unit_test.dart b/hermes-tests/test/application/use_cases/upload/upload_test_use_case_unit_test.dart index 451b57b..f031d7b 100644 --- a/hermes-tests/test/application/use_cases/upload/upload_test_use_case_unit_test.dart +++ b/hermes-tests/test/application/use_cases/upload/upload_test_use_case_unit_test.dart @@ -23,7 +23,7 @@ void main() { group('Upload Test UseCase Unit Tests', () { setUpAll(() { testConfig = ServerConfig.fromJson( - Config.fromJsonFile('config.json').test, + Config.fromEnv('HERMES_CONFIG').test, ); mockTestRepository = MockTestRepository(); final logger = Logger( @@ -50,7 +50,7 @@ void main() { 'Then no storage failure is returned', () async { // Arrange final TestMetadata testMetadata = TestMetadata.testToUpload( - problemId: 'marsx', + problemId: 'sum', testId: '2', fromDir: testConfig.tempLocalUnarchivedTestFolder, toDir: testConfig.tempLocalUnarchivedTestFolder, @@ -85,7 +85,7 @@ void main() { 'Then localtTestNotFound storage failure is returned', () async { // Arrange final TestMetadata testMetadata = TestMetadata.testToUpload( - problemId: 'marsx', + problemId: 'sum', testId: '3', fromDir: testConfig.tempLocalUnarchivedTestFolder, toDir: testConfig.tempLocalUnarchivedTestFolder, @@ -126,7 +126,7 @@ void main() { 'Then unexpected storage failure is returned', () async { // Arrange final TestMetadata testMetadata = TestMetadata.testToUpload( - problemId: 'marsx', + problemId: 'sum', testId: '2', fromDir: testConfig.tempLocalUnarchivedTestFolder, toDir: testConfig.tempLocalUnarchivedTestFolder, @@ -167,7 +167,7 @@ void main() { 'Then unexpected storage failure is returned', () async { // Arrange final TestMetadata testMetadata = TestMetadata.testToDownload( - problemId: 'marsx', + problemId: 'sum', testId: '2', fromDir: testConfig.tempLocalUnarchivedTestFolder, toDir: testConfig.tempLocalUnarchivedTestFolder,