()
| 57 | } |
| 58 | |
| 59 | func (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, |
nothing calls this directly
no test coverage detected