Skip to content

Commit

Permalink
fix: Increment tests execution time limit (#10)
Browse files Browse the repository at this point in the history
* chore: Rename local tests execution directory

* refactor: Create src folder

* fix: Increment tests execution timeout to one minute
  • Loading branch information
PedroChaparro authored Jan 6, 2024
1 parent c682c5f commit c164193
Show file tree
Hide file tree
Showing 18 changed files with 29 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
tmp

# Tests execution folder
tests_exec_dir/
tests-execution-directory/
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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{}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down Expand Up @@ -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
Expand All @@ -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,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
6 changes: 3 additions & 3 deletions utils/utils.go → src/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
File renamed without changes.

0 comments on commit c164193

Please sign in to comment.