diff --git a/.gitignore b/.gitignore index 34e1db5..3c43923 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ tmp # Tests execution folder -tests_exec_dir/ \ No newline at end of file +tests-execution-directory/ \ No newline at end of file diff --git a/docs/contributing.md b/docs/contributing.md index 1ebdfd9..9dd8fda 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -55,7 +55,7 @@ air This will start the tests micro-service and will watch for changes in the source code and restart the service automatically. -Additionally, you may want to generate a `.air.toml` file and add the `tests_exec_dir/` directory to the `exclude_dir` list in order to avoid restarting the service when the tests are executed, to do this, run the following command or refer to the [Air documentation](https://github.com/cosmtrek/air) +Additionally, you may want to generate a `.air.toml` file and add the `tests-execution-directory/` directory to the `exclude_dir` list in order to avoid restarting the service when the tests are executed, to do this, run the following command or refer to the [Air documentation](https://github.com/cosmtrek/air) ```bash air init diff --git a/main.go b/main.go index 6c176e5..c3d1754 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,7 @@ package main import ( - "github.com/upb-code-labs/tests-microservice/infrastructure/rabbitmq" + "github.com/upb-code-labs/tests-microservice/src/infrastructure/rabbitmq" ) func main() { diff --git a/application/submissions-use-cases.go b/src/application/submissions-use-cases.go similarity index 86% rename from application/submissions-use-cases.go rename to src/application/submissions-use-cases.go index ce47a85..42d6899 100644 --- a/application/submissions-use-cases.go +++ b/src/application/submissions-use-cases.go @@ -1,11 +1,11 @@ package application import ( - "github.com/upb-code-labs/tests-microservice/domain/definitions" - "github.com/upb-code-labs/tests-microservice/domain/dtos" - "github.com/upb-code-labs/tests-microservice/domain/entities" - "github.com/upb-code-labs/tests-microservice/infrastructure/static_files" - "github.com/upb-code-labs/tests-microservice/utils" + "github.com/upb-code-labs/tests-microservice/src/domain/definitions" + "github.com/upb-code-labs/tests-microservice/src/domain/dtos" + "github.com/upb-code-labs/tests-microservice/src/domain/entities" + "github.com/upb-code-labs/tests-microservice/src/infrastructure/static_files" + "github.com/upb-code-labs/tests-microservice/src/utils" ) type SubmissionsUseCases struct{} diff --git a/domain/definitions/archives_manager.go b/src/domain/definitions/archives_manager.go similarity index 100% rename from domain/definitions/archives_manager.go rename to src/domain/definitions/archives_manager.go diff --git a/domain/definitions/language-tests-runner.go b/src/domain/definitions/language-tests-runner.go similarity index 78% rename from domain/definitions/language-tests-runner.go rename to src/domain/definitions/language-tests-runner.go index 2e67216..aa80982 100644 --- a/domain/definitions/language-tests-runner.go +++ b/src/domain/definitions/language-tests-runner.go @@ -1,7 +1,7 @@ package definitions import ( - "github.com/upb-code-labs/tests-microservice/domain/dtos" + "github.com/upb-code-labs/tests-microservice/src/domain/dtos" ) type LanguageTestsRunner interface { diff --git a/domain/definitions/submission-status-updates-queue-manager.go b/src/domain/definitions/submission-status-updates-queue-manager.go similarity index 66% rename from domain/definitions/submission-status-updates-queue-manager.go rename to src/domain/definitions/submission-status-updates-queue-manager.go index 4255800..9c9829d 100644 --- a/domain/definitions/submission-status-updates-queue-manager.go +++ b/src/domain/definitions/submission-status-updates-queue-manager.go @@ -1,6 +1,6 @@ package definitions -import "github.com/upb-code-labs/tests-microservice/domain/dtos" +import "github.com/upb-code-labs/tests-microservice/src/domain/dtos" type SubmissionStatusUpdatesQueueManager interface { QueueUpdate(updateDTO *dtos.SubmissionStatusUpdateDTO) error diff --git a/domain/dtos/dtos.go b/src/domain/dtos/dtos.go similarity index 100% rename from domain/dtos/dtos.go rename to src/domain/dtos/dtos.go diff --git a/domain/entities/entities.go b/src/domain/entities/entities.go similarity index 100% rename from domain/entities/entities.go rename to src/domain/entities/entities.go diff --git a/infrastructure/environment.go b/src/infrastructure/environment.go similarity index 94% rename from infrastructure/environment.go rename to src/infrastructure/environment.go index fe79672..fc9cec5 100644 --- a/infrastructure/environment.go +++ b/src/infrastructure/environment.go @@ -5,7 +5,7 @@ import "github.com/kelseyhightower/envconfig" type Environment struct { RabbitMQConnectionString string `split_words:"true" default:"amqp://rabbitmq:rabbitmq@localhost:5672/"` StaticFilesMicroserviceAddress string `split_words:"true" default:"http://localhost:8081"` - TestsExecutionDirectory string `split_words:"true" default:"./tests_exec_dir"` + TestsExecutionDirectory string `split_words:"true" default:"./tests-execution-directory"` } var env *Environment diff --git a/infrastructure/implementations/archives_manager.go b/src/infrastructure/implementations/archives_manager.go similarity index 100% rename from infrastructure/implementations/archives_manager.go rename to src/infrastructure/implementations/archives_manager.go diff --git a/infrastructure/implementations/java-tests-runner.go b/src/infrastructure/implementations/java-tests-runner.go similarity index 96% rename from infrastructure/implementations/java-tests-runner.go rename to src/infrastructure/implementations/java-tests-runner.go index f90188b..0f0f977 100644 --- a/infrastructure/implementations/java-tests-runner.go +++ b/src/infrastructure/implementations/java-tests-runner.go @@ -11,8 +11,8 @@ import ( "strings" "time" - "github.com/upb-code-labs/tests-microservice/domain/dtos" - "github.com/upb-code-labs/tests-microservice/infrastructure" + "github.com/upb-code-labs/tests-microservice/src/domain/dtos" + "github.com/upb-code-labs/tests-microservice/src/infrastructure" ) type JavaTestsRunner struct{} @@ -180,7 +180,7 @@ func (javaTestsRunner *JavaTestsRunner) deleteArchives(submissionUUID string) er } func (javaTestsRunner *JavaTestsRunner) RunTests(submissionUUID string) (dto *dtos.TestResultDTO, err error) { - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) defer cancel() // Delete the submission directory at the end @@ -195,7 +195,7 @@ func (javaTestsRunner *JavaTestsRunner) RunTests(submissionUUID string) (dto *dt // Prepare the command testAndBuildCommand := fmt.Sprintf( - "cd %s && mvn clean test", + "cd %s && timeout 1m mvn clean test", submissionPath, ) diff --git a/infrastructure/rabbitmq/connection.go b/src/infrastructure/rabbitmq/connection.go similarity index 91% rename from infrastructure/rabbitmq/connection.go rename to src/infrastructure/rabbitmq/connection.go index 9fbf3d5..5d89ebb 100644 --- a/infrastructure/rabbitmq/connection.go +++ b/src/infrastructure/rabbitmq/connection.go @@ -4,7 +4,7 @@ import ( "log" amqp "github.com/rabbitmq/amqp091-go" - "github.com/upb-code-labs/tests-microservice/infrastructure" + "github.com/upb-code-labs/tests-microservice/src/infrastructure" ) var rabbitMQChannel *amqp.Channel diff --git a/infrastructure/rabbitmq/submission-queue.go b/src/infrastructure/rabbitmq/submission-queue.go similarity index 91% rename from infrastructure/rabbitmq/submission-queue.go rename to src/infrastructure/rabbitmq/submission-queue.go index fd8fb44..fc42c61 100644 --- a/infrastructure/rabbitmq/submission-queue.go +++ b/src/infrastructure/rabbitmq/submission-queue.go @@ -5,10 +5,10 @@ import ( "log" amqp "github.com/rabbitmq/amqp091-go" - "github.com/upb-code-labs/tests-microservice/application" - "github.com/upb-code-labs/tests-microservice/domain/dtos" - "github.com/upb-code-labs/tests-microservice/domain/entities" - "github.com/upb-code-labs/tests-microservice/utils" + "github.com/upb-code-labs/tests-microservice/src/application" + "github.com/upb-code-labs/tests-microservice/src/domain/dtos" + "github.com/upb-code-labs/tests-microservice/src/domain/entities" + "github.com/upb-code-labs/tests-microservice/src/utils" ) type SubmissionQueueMgr struct { @@ -131,6 +131,9 @@ func (manager *SubmissionQueueMgr) processSubmission(msg amqp.Delivery) { return } + // Log message to console + log.Println("[RabbitMQ]: Received submission status update", submissionWork.SubmissionUUID) + // Send submission status update statusDTO := &dtos.SubmissionStatusUpdateDTO{ SubmissionUUID: submissionWork.SubmissionUUID, diff --git a/infrastructure/rabbitmq/submission-status-updates-queue.go b/src/infrastructure/rabbitmq/submission-status-updates-queue.go similarity index 97% rename from infrastructure/rabbitmq/submission-status-updates-queue.go rename to src/infrastructure/rabbitmq/submission-status-updates-queue.go index 47354ef..2b7b7e0 100644 --- a/infrastructure/rabbitmq/submission-status-updates-queue.go +++ b/src/infrastructure/rabbitmq/submission-status-updates-queue.go @@ -7,7 +7,7 @@ import ( "time" amqp "github.com/rabbitmq/amqp091-go" - "github.com/upb-code-labs/tests-microservice/domain/dtos" + "github.com/upb-code-labs/tests-microservice/src/domain/dtos" ) type SubmissionStatusUpdatesQueueMgr struct { diff --git a/infrastructure/static_files/handler.go b/src/infrastructure/static_files/handler.go similarity index 94% rename from infrastructure/static_files/handler.go rename to src/infrastructure/static_files/handler.go index ede60b7..7035451 100644 --- a/infrastructure/static_files/handler.go +++ b/src/infrastructure/static_files/handler.go @@ -8,8 +8,8 @@ import ( "io" "net/http" - "github.com/upb-code-labs/tests-microservice/domain/dtos" - "github.com/upb-code-labs/tests-microservice/infrastructure" + "github.com/upb-code-labs/tests-microservice/src/domain/dtos" + "github.com/upb-code-labs/tests-microservice/src/infrastructure" ) type StaticFilesManager struct{} diff --git a/utils/utils.go b/src/utils/utils.go similarity index 80% rename from utils/utils.go rename to src/utils/utils.go index ce835f8..853138f 100644 --- a/utils/utils.go +++ b/src/utils/utils.go @@ -3,9 +3,9 @@ package utils import ( "errors" - "github.com/upb-code-labs/tests-microservice/domain/definitions" - "github.com/upb-code-labs/tests-microservice/domain/dtos" - "github.com/upb-code-labs/tests-microservice/infrastructure/implementations" + "github.com/upb-code-labs/tests-microservice/src/domain/definitions" + "github.com/upb-code-labs/tests-microservice/src/domain/dtos" + "github.com/upb-code-labs/tests-microservice/src/infrastructure/implementations" ) func GetTestRunnerByLanguageUUID(languageUUID string) (runner definitions.LanguageTestsRunner, err error) { diff --git a/tests_exec_dir/.gitkeep b/tests-execution-directory/.gitkeep similarity index 100% rename from tests_exec_dir/.gitkeep rename to tests-execution-directory/.gitkeep