Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor test suite setup/teardown #645

Merged
merged 6 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions tests/integration/golang/admin/namespace/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
"github.com/PuerkitoBio/goquery"
"github.com/stretchr/testify/suite"

"github.com/G-Research/fasttrackml/pkg/api/mlflow/common"
"github.com/G-Research/fasttrackml/pkg/api/mlflow/dao/models"
"github.com/G-Research/fasttrackml/pkg/ui/admin/request"
"github.com/G-Research/fasttrackml/tests/integration/golang/helpers"
)
Expand All @@ -25,16 +23,6 @@ func TestCreateNamespaceTestSuite(t *testing.T) {
}

func (s *CreateNamespaceTestSuite) Test_Ok() {
defer func() {
s.Require().Nil(s.NamespaceFixtures.UnloadFixtures())
}()
_, err := s.NamespaceFixtures.CreateNamespace(context.Background(), &models.Namespace{
ID: 1,
Code: "default",
DefaultExperimentID: common.GetPointer(int32(0)),
})
s.Require().Nil(err)

requests := []request.Namespace{
{
Code: "test2",
Expand Down Expand Up @@ -64,16 +52,6 @@ func (s *CreateNamespaceTestSuite) Test_Ok() {
}

func (s *CreateNamespaceTestSuite) Test_Error() {
defer func() {
s.Require().Nil(s.NamespaceFixtures.UnloadFixtures())
}()
_, err := s.NamespaceFixtures.CreateNamespace(context.Background(), &models.Namespace{
ID: 1,
Code: "default",
DefaultExperimentID: common.GetPointer(int32(0)),
})
s.Require().Nil(err)

testData := []struct {
name string
request *request.Namespace
Expand Down
18 changes: 0 additions & 18 deletions tests/integration/golang/admin/namespace/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,7 @@ func TestDeleteNamespaceTestSuite(t *testing.T) {
}

func (s *DeleteNamespaceTestSuite) Test_Ok() {
defer func() {
s.Require().Nil(s.NamespaceFixtures.UnloadFixtures())
}()
_, err := s.NamespaceFixtures.CreateNamespace(context.Background(), &models.Namespace{
ID: 1,
Code: "default",
DefaultExperimentID: common.GetPointer(int32(0)),
})
s.Require().Nil(err)
_, err = s.NamespaceFixtures.CreateNamespace(context.Background(), &models.Namespace{
ID: 2,
Code: "test2",
Description: "test namespace 2 description",
Expand Down Expand Up @@ -73,16 +64,7 @@ func (s *DeleteNamespaceTestSuite) Test_Ok() {
}

func (s *DeleteNamespaceTestSuite) Test_Error() {
defer func() {
s.Require().Nil(s.NamespaceFixtures.UnloadFixtures())
}()
_, err := s.NamespaceFixtures.CreateNamespace(context.Background(), &models.Namespace{
ID: 1,
Code: "default",
DefaultExperimentID: common.GetPointer(int32(0)),
})
s.Require().Nil(err)
_, err = s.NamespaceFixtures.CreateNamespace(context.Background(), &models.Namespace{
ID: 2,
Code: "test2",
Description: "test namespace 2 description",
Expand Down
18 changes: 0 additions & 18 deletions tests/integration/golang/admin/namespace/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ func TestUpdateNamespaceTestSuite(t *testing.T) {
}

func (s *UpdateNamespaceTestSuite) Test_Ok() {
defer func() {
s.Require().Nil(s.NamespaceFixtures.UnloadFixtures())
}()
_, err := s.NamespaceFixtures.CreateNamespace(context.Background(), &models.Namespace{
ID: 1,
Code: "default",
DefaultExperimentID: common.GetPointer(int32(0)),
})
s.Require().Nil(err)
ns, err := s.NamespaceFixtures.CreateNamespace(context.Background(), &models.Namespace{
ID: 2,
Code: "test2",
Expand Down Expand Up @@ -61,16 +52,7 @@ func (s *UpdateNamespaceTestSuite) Test_Ok() {
}

func (s *UpdateNamespaceTestSuite) Test_Error() {
defer func() {
s.Require().Nil(s.NamespaceFixtures.UnloadFixtures())
}()
_, err := s.NamespaceFixtures.CreateNamespace(context.Background(), &models.Namespace{
ID: 1,
Code: "default",
DefaultExperimentID: common.GetPointer(int32(0)),
})
s.Require().Nil(err)
_, err = s.NamespaceFixtures.CreateNamespace(context.Background(), &models.Namespace{
ID: 2,
Code: "test2",
Description: "test namespace 2 description",
Expand Down
25 changes: 0 additions & 25 deletions tests/integration/golang/aim/app/create_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
package run

import (
"context"
"net/http"
"testing"

"github.com/stretchr/testify/suite"

"github.com/G-Research/fasttrackml/pkg/api/aim/request"
"github.com/G-Research/fasttrackml/pkg/api/aim/response"
"github.com/G-Research/fasttrackml/pkg/api/mlflow/common"
"github.com/G-Research/fasttrackml/pkg/api/mlflow/dao/models"
"github.com/G-Research/fasttrackml/tests/integration/golang/helpers"
)

Expand All @@ -25,17 +22,6 @@ func TestCreateAppTestSuite(t *testing.T) {
}

func (s *CreateAppTestSuite) Test_Ok() {
defer func() {
s.Require().Nil(s.NamespaceFixtures.UnloadFixtures())
}()

_, err := s.NamespaceFixtures.CreateNamespace(context.Background(), &models.Namespace{
ID: 1,
Code: "default",
DefaultExperimentID: common.GetPointer(int32(0)),
})
s.Require().Nil(err)

tests := []struct {
name string
requestBody request.CreateApp
Expand Down Expand Up @@ -74,17 +60,6 @@ func (s *CreateAppTestSuite) Test_Ok() {
}

func (s *CreateAppTestSuite) Test_Error() {
defer func() {
s.Require().Nil(s.NamespaceFixtures.UnloadFixtures())
}()

_, err := s.NamespaceFixtures.CreateNamespace(context.Background(), &models.Namespace{
ID: 1,
Code: "default",
DefaultExperimentID: common.GetPointer(int32(0)),
})
s.Require().Nil(err)

tests := []struct {
name string
requestBody any
Expand Down
30 changes: 3 additions & 27 deletions tests/integration/golang/aim/app/delete_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
"github.com/stretchr/testify/suite"

"github.com/G-Research/fasttrackml/pkg/api/aim/response"
"github.com/G-Research/fasttrackml/pkg/api/mlflow/common"
"github.com/G-Research/fasttrackml/pkg/api/mlflow/dao/models"
"github.com/G-Research/fasttrackml/pkg/database"
"github.com/G-Research/fasttrackml/tests/integration/golang/helpers"
)
Expand All @@ -27,25 +25,14 @@ func TestDeleteAppTestSuite(t *testing.T) {
}

func (s *DeleteAppTestSuite) Test_Ok() {
defer func() {
s.Require().Nil(s.NamespaceFixtures.UnloadFixtures())
}()

namespace, err := s.NamespaceFixtures.CreateNamespace(context.Background(), &models.Namespace{
ID: 1,
Code: "default",
DefaultExperimentID: common.GetPointer(int32(0)),
})
s.Require().Nil(err)

app, err := s.AppFixtures.CreateApp(context.Background(), &database.App{
Base: database.Base{
ID: uuid.New(),
CreatedAt: time.Now(),
},
Type: "mpi",
State: database.AppState{},
NamespaceID: namespace.ID,
NamespaceID: s.DefaultNamespace.ID,
})
s.Require().Nil(err)

Expand Down Expand Up @@ -75,25 +62,14 @@ func (s *DeleteAppTestSuite) Test_Ok() {
}

func (s *DeleteAppTestSuite) Test_Error() {
defer func() {
s.Require().Nil(s.NamespaceFixtures.UnloadFixtures())
}()

namespace, err := s.NamespaceFixtures.CreateNamespace(context.Background(), &models.Namespace{
ID: 1,
Code: "default",
DefaultExperimentID: common.GetPointer(int32(0)),
})
s.Require().Nil(err)

_, err = s.AppFixtures.CreateApp(context.Background(), &database.App{
jgiannuzzi marked this conversation as resolved.
Show resolved Hide resolved
_, err := s.AppFixtures.CreateApp(context.Background(), &database.App{
Base: database.Base{
ID: uuid.New(),
CreatedAt: time.Now(),
},
Type: "mpi",
State: database.AppState{},
NamespaceID: namespace.ID,
NamespaceID: s.DefaultNamespace.ID,
})
s.Require().Nil(err)

Expand Down
26 changes: 1 addition & 25 deletions tests/integration/golang/aim/app/get_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"github.com/stretchr/testify/suite"

"github.com/G-Research/fasttrackml/pkg/api/aim/response"
"github.com/G-Research/fasttrackml/pkg/api/mlflow/common"
"github.com/G-Research/fasttrackml/pkg/api/mlflow/dao/models"
"github.com/G-Research/fasttrackml/pkg/database"
"github.com/G-Research/fasttrackml/tests/integration/golang/helpers"
)
Expand All @@ -26,25 +24,14 @@ func TestGetAppTestSuite(t *testing.T) {
}

func (s *GetAppTestSuite) Test_Ok() {
defer func() {
s.Require().Nil(s.NamespaceFixtures.UnloadFixtures())
}()

namespace, err := s.NamespaceFixtures.CreateNamespace(context.Background(), &models.Namespace{
ID: 1,
Code: "default",
DefaultExperimentID: common.GetPointer(int32(0)),
})
s.Require().Nil(err)

app, err := s.AppFixtures.CreateApp(context.Background(), &database.App{
Base: database.Base{
ID: uuid.New(),
CreatedAt: time.Now(),
},
Type: "mpi",
State: database.AppState{},
NamespaceID: namespace.ID,
NamespaceID: s.DefaultNamespace.ID,
})
s.Require().Nil(err)

Expand All @@ -58,17 +45,6 @@ func (s *GetAppTestSuite) Test_Ok() {
}

func (s *GetAppTestSuite) Test_Error() {
defer func() {
s.Require().Nil(s.NamespaceFixtures.UnloadFixtures())
}()

_, err := s.NamespaceFixtures.CreateNamespace(context.Background(), &models.Namespace{
ID: 1,
Code: "default",
DefaultExperimentID: common.GetPointer(int32(0)),
})
s.Require().Nil(err)

tests := []struct {
name string
idParam uuid.UUID
Expand Down
21 changes: 6 additions & 15 deletions tests/integration/golang/aim/app/get_apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"github.com/stretchr/testify/suite"

"github.com/G-Research/fasttrackml/pkg/api/aim/response"
"github.com/G-Research/fasttrackml/pkg/api/mlflow/common"
"github.com/G-Research/fasttrackml/pkg/api/mlflow/dao/models"
"github.com/G-Research/fasttrackml/pkg/database"
"github.com/G-Research/fasttrackml/tests/integration/golang/helpers"
)
Expand All @@ -20,7 +18,11 @@ type GetAppsTestSuite struct {
}

func TestGetAppsTestSuite(t *testing.T) {
suite.Run(t, new(GetAppsTestSuite))
suite.Run(t, &GetAppsTestSuite{
helpers.BaseTestSuite{
ResetOnSubTest: true,
},
})
}

func (s *GetAppsTestSuite) Test_Ok() {
Expand All @@ -39,18 +41,7 @@ func (s *GetAppsTestSuite) Test_Ok() {
}
for _, tt := range tests {
s.Run(tt.name, func() {
defer func() {
s.Require().Nil(s.AppFixtures.UnloadFixtures())
}()

namespace, err := s.NamespaceFixtures.CreateNamespace(context.Background(), &models.Namespace{
ID: 1,
Code: "default",
DefaultExperimentID: common.GetPointer(int32(0)),
})
s.Require().Nil(err)

apps, err := s.AppFixtures.CreateApps(context.Background(), namespace, tt.expectedAppCount)
apps, err := s.AppFixtures.CreateApps(context.Background(), s.DefaultNamespace, tt.expectedAppCount)
s.Require().Nil(err)

var resp []response.App
Expand Down
28 changes: 2 additions & 26 deletions tests/integration/golang/aim/app/update_app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (

"github.com/G-Research/fasttrackml/pkg/api/aim/request"
"github.com/G-Research/fasttrackml/pkg/api/aim/response"
"github.com/G-Research/fasttrackml/pkg/api/mlflow/common"
"github.com/G-Research/fasttrackml/pkg/api/mlflow/dao/models"
"github.com/G-Research/fasttrackml/pkg/database"
"github.com/G-Research/fasttrackml/tests/integration/golang/helpers"
)
Expand All @@ -28,25 +26,14 @@ func TestUpdateAppTestSuite(t *testing.T) {
}

func (s *UpdateAppTestSuite) Test_Ok() {
defer func() {
s.Require().Nil(s.NamespaceFixtures.UnloadFixtures())
}()

namespace, err := s.NamespaceFixtures.CreateNamespace(context.Background(), &models.Namespace{
ID: 1,
Code: "default",
DefaultExperimentID: common.GetPointer(int32(0)),
})
s.Require().Nil(err)

app, err := s.AppFixtures.CreateApp(context.Background(), &database.App{
Base: database.Base{
ID: uuid.New(),
CreatedAt: time.Now(),
},
Type: "mpi",
State: database.AppState{},
NamespaceID: namespace.ID,
NamespaceID: s.DefaultNamespace.ID,
})
s.Require().Nil(err)

Expand Down Expand Up @@ -96,25 +83,14 @@ func (s *UpdateAppTestSuite) Test_Ok() {
}

func (s *UpdateAppTestSuite) Test_Error() {
defer func() {
s.Require().Nil(s.NamespaceFixtures.UnloadFixtures())
}()

namespace, err := s.NamespaceFixtures.CreateNamespace(context.Background(), &models.Namespace{
ID: 1,
Code: "default",
DefaultExperimentID: common.GetPointer(int32(0)),
})
s.Require().Nil(err)

app, err := s.AppFixtures.CreateApp(context.Background(), &database.App{
Base: database.Base{
ID: uuid.New(),
CreatedAt: time.Now(),
},
Type: "mpi",
State: database.AppState{},
NamespaceID: namespace.ID,
NamespaceID: s.DefaultNamespace.ID,
})
s.Require().Nil(err)

Expand Down
Loading