@@ -248,6 +248,53 @@ func TestRunnerPoolReconciler_scalesFromQueueDepth(t *testing.T) {
248248 }
249249}
250250
251+ func TestRunnerPoolReconciler_scalesFromWebhookDemandAnnotation (t * testing.T ) {
252+ pool := & impv1alpha1.ImpVMRunnerPool {
253+ ObjectMeta : metav1.ObjectMeta {
254+ Name : "ci-pool" ,
255+ Namespace : "ci" ,
256+ Annotations : map [string ]string {
257+ AnnotationRunnerDemand : "2" ,
258+ },
259+ },
260+ Spec : impv1alpha1.ImpVMRunnerPoolSpec {
261+ TemplateName : "ubuntu-runner" ,
262+ Platform : impv1alpha1.RunnerPlatformSpec {
263+ Type : "github-actions" ,
264+ CredentialsSecret : "gh-creds" ,
265+ },
266+ Scaling : & impv1alpha1.RunnerScalingSpec {MinIdle : 0 , MaxConcurrent : 5 },
267+ JobDetection : & impv1alpha1.RunnerJobDetectionSpec {
268+ Webhook : & impv1alpha1.RunnerWebhookSpec {Enabled : true },
269+ },
270+ },
271+ }
272+ tpl := & impv1alpha1.ImpVMTemplate {
273+ ObjectMeta : metav1.ObjectMeta {Name : "ubuntu-runner" , Namespace : "ci" },
274+ Spec : impv1alpha1.ImpVMTemplateSpec {ClassRef : impv1alpha1.ClusterObjectRef {Name : "standard" }, Image : "ubuntu:22.04" },
275+ }
276+
277+ scheme := newRunnerPoolTestScheme (t )
278+ c := fake .NewClientBuilder ().WithScheme (scheme ).
279+ WithObjects (pool , tpl ).WithStatusSubresource (pool ).Build ()
280+ r := & ImpVMRunnerPoolReconciler {Client : c , Scheme : scheme }
281+
282+ _ , err := r .Reconcile (context .Background (), reconcile.Request {
283+ NamespacedName : types.NamespacedName {Name : "ci-pool" , Namespace : "ci" },
284+ })
285+ if err != nil {
286+ t .Fatalf ("unexpected error: %v" , err )
287+ }
288+
289+ vmList := & impv1alpha1.ImpVMList {}
290+ _ = c .List (context .Background (), vmList ,
291+ client .InNamespace ("ci" ),
292+ client.MatchingLabels {impv1alpha1 .LabelRunnerPool : "ci-pool" })
293+ if len (vmList .Items ) != 2 {
294+ t .Fatalf ("expected 2 webhook-demand VMs, got %d" , len (vmList .Items ))
295+ }
296+ }
297+
251298type stubRunnerQueueDepthReader struct {
252299 queueDepth int
253300 err error
0 commit comments