MCPcopy Create free account
hub / github.com/cloudbase/garm / SetupTest

Method SetupTest

runner/pool/pool_test.go:59–128  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

57}
58
59func (s *PoolStressTestSuite) SetupTest() {
60 dbCfg := garmTesting.GetTestSqliteDBConfig(s.T())
61 db, err := database.NewDatabase(context.Background(), dbCfg)
62 s.Require().NoError(err)
63
64 s.store = db
65 s.adminCtx = garmTesting.ImpersonateAdminContext(context.Background(), db, s.T())
66
67 endpoint := garmTesting.CreateDefaultGithubEndpoint(s.adminCtx, db, s.T())
68 creds := garmTesting.CreateTestGithubCredentials(s.adminCtx, "stress-creds", db, s.T(), endpoint)
69
70 repo, err := db.CreateRepository(
71 s.adminCtx,
72 "test-owner",
73 "test-repo",
74 creds,
75 "test-webhook-secret",
76 params.PoolBalancerTypeRoundRobin,
77 false,
78 )
79 s.Require().NoError(err)
80
81 entity, err := repo.GetEntity()
82 s.Require().NoError(err)
83 s.entity = entity
84
85 s.providerMock = runnerCommonMocks.NewProvider(s.T())
86 s.ghcliMock = runnerCommonMocks.NewGithubClient(s.T())
87
88 pool, err := db.CreateEntityPool(s.adminCtx, entity, params.CreatePoolParams{
89 ProviderName: "test-provider",
90 MaxRunners: 10,
91 MinIdleRunners: 0,
92 Image: "test-image",
93 Flavor: "test-flavor",
94 OSType: "linux",
95 OSArch: "amd64",
96 Tags: []string{"self-hosted", "linux", "x64"},
97 Enabled: true,
98 })
99 s.Require().NoError(err)
100 s.pool = pool
101
102 // Populate the entity cache so ensureMinIdleRunners can find pools.
103 cache.SetEntity(entity)
104 cache.SetEntityPool(entity.ID, pool)
105
106 s.controllerInfo, err = db.InitController()
107 s.Require().NoError(err)
108
109 backoff, err := locking.NewInstanceDeleteBackoff(context.Background())
110 s.Require().NoError(err)
111
112 s.mgr = &basePoolManager{
113 ctx: s.adminCtx,
114 consumerID: "test-consumer",
115 entity: entity,
116 store: db,

Callers

nothing calls this directly

Calls 8

NewDatabaseFunction · 0.92
SetEntityFunction · 0.92
SetEntityPoolFunction · 0.92
NewInstanceDeleteBackoffFunction · 0.92
CreateRepositoryMethod · 0.65
GetEntityMethod · 0.65
CreateEntityPoolMethod · 0.65
InitControllerMethod · 0.65

Tested by

no test coverage detected