Skip to content

Commit

Permalink
chore: Update example mock manager
Browse files Browse the repository at this point in the history
Signed-off-by: Mahendra Paipuri <[email protected]>
  • Loading branch information
mahendrapaipuri committed Jun 20, 2024
1 parent 5059c38 commit 9af7166
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
5 changes: 5 additions & 0 deletions examples/mock_resource_manager/cmd/mock_ceems_server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ import (
"os"

_ "github.com/mahendrapaipuri/ceems/examples/mock_resource_manager/pkg/resource"

"github.com/mahendrapaipuri/ceems/pkg/api/cli"

// If existing schedulers in CEEMS are needed, they need to be imported too
// For instance to import slurm manager, following import statement must be added
_ "github.com/mahendrapaipuri/ceems/pkg/api/resource/slurm"
)

// Main entry point for `usagestats` app
Expand Down
35 changes: 33 additions & 2 deletions examples/mock_resource_manager/pkg/resource/mock_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ func NewMockManager(cluster models.Cluster, logger log.Logger) (resource.Fetcher
}, nil
}

// Add the logic here to get compute units from resource manager and return slice of Unit structs
// Add the logic here to get compute units from resource manager and return slice of
// ClusterUnits structs
//
// When making Unit stucts, ensure to format the datetime using base.DatetimeLayout
// Also ensure to set StartTS and EndTS fields to start and end times in unix milliseconds epoch
func (s *mockManager) Fetch(start time.Time, end time.Time) ([]models.ClusterUnits, error) {
func (s *mockManager) FetchUnits(start time.Time, end time.Time) ([]models.ClusterUnits, error) {
return []models.ClusterUnits{
{
Cluster: models.Cluster{
Expand All @@ -74,3 +75,33 @@ func (s *mockManager) Fetch(start time.Time, end time.Time) ([]models.ClusterUni
},
}, nil
}

// Add the logic here to get users and projects/accounts/tenants/namespaces from
// resource manager
func (s *mockManager) FetchUsersProjects(current time.Time) ([]models.ClusterUsers, []models.ClusterProjects, error) {
return []models.ClusterUsers{
{
Cluster: models.Cluster{
ID: "mock",
},
Users: []models.User{
{
Name: "usr1",
Projects: models.List{"prj1", "prj2"},
},
},
},
}, []models.ClusterProjects{
{
Cluster: models.Cluster{
ID: "mock",
},
Projects: []models.Project{
{
Name: "usr1",
Users: models.List{"prj1", "prj2"},
},
},
},
}, nil
}

0 comments on commit 9af7166

Please sign in to comment.