func TestReconciler_ScaleDown_Zero(t *testing.T) {
	// Set desired 0
	job := mock.Job()
	job.TaskGroups[0].Count = 0

	// Create 20 existing allocations
	var allocs []*structs.Allocation
	for i := 0; i < 20; i++ {
		alloc := mock.Alloc()
		alloc.Job = job
		alloc.JobID = job.ID
		alloc.NodeID = structs.GenerateUUID()
		alloc.Name = structs.AllocName(job.ID, job.TaskGroups[0].Name, uint(i))
		allocs = append(allocs, alloc)
	}

	reconciler := NewAllocReconciler(testLogger(), allocUpdateFnIgnore, false, job.ID, job, nil, allocs, nil)
	r := reconciler.Compute()

	// Assert the correct results
	assertResults(t, r, &resultExpectation{
		createDeployment:  nil,
		deploymentUpdates: nil,
		place:             0,
		inplace:           0,
		stop:              20,
		desiredTGUpdates: map[string]*structs.DesiredUpdates{
			job.TaskGroups[0].Name: {
				Stop: 20,
			},
		},
	})

	assertNamesHaveIndexes(t, intRange(0, 19), stopResultsToNames(r.stop))
}
// Tests the reconciler properly handles stopping allocations for a job that has
// scaled down to zero desired
Tests the reconciler properly handles stopping allocations for a job that has
scaled down to zero desired
// Tests the reconciler properly handles stopping allocations for a job that has // scaled down to zero desired
func TestReconciler_ScaleDown_Zero(t *testing.T) {
	job := mock.Job()
	job.TaskGroups[0].Count = 0
	var allocs []*structs.Allocation
	for i := 0; i < 20; i++ {
		alloc := mock.Alloc()
		alloc.Job = job
		alloc.JobID = job.ID
		alloc.NodeID = structs.GenerateUUID()
		alloc.Name = structs.AllocName(job.ID, job.TaskGroups[0].Name, uint(i))
		allocs = append(allocs, alloc)
	}
	reconciler := NewAllocReconciler(testLogger(), allocUpdateFnIgnore, false, job.ID, job, nil, allocs, nil)
	r := reconciler.Compute()
	assertResults(t, r, &resultExpectation{
		createDeployment:  nil,
		deploymentUpdates: nil,
		place:             0,
		inplace:           0,
		stop:              20,
		desiredTGUpdates: map[string]*structs.DesiredUpdates{
			job.TaskGroups[0].Name: {
				Stop: 20,
			},
		},
	})
	assertNamesHaveIndexes(t, intRange(0, 19), stopResultsToNames(r.stop))
}
func TestReconciler_ScaleDown_Zero ( t * testing . T ) { job := mock . Job ( ) job . TaskGroups [ 0 ] . Count = 0 var allocs [ ] * structs . Allocation for i := 0 ; i < 20 ; i ++ { alloc := mock . Alloc ( ) alloc . Job = job alloc . JobID = job . ID alloc . NodeID = structs . GenerateUUID ( ) alloc . Name = structs . AllocName ( job . ID , job . TaskGroups [ 0 ] . Name , uint ( i ) ) allocs = append ( allocs , alloc ) } reconciler := NewAllocReconciler ( testLogger ( ) , allocUpdateFnIgnore , false , job . ID , job , nil , allocs , nil ) r := reconciler . Compute ( ) assertResults ( t , r , & resultExpectation { createDeployment : nil , deploymentUpdates : nil , place : 0 , inplace : 0 , stop : 20 , desiredTGUpdates : map [ string ] * structs . DesiredUpdates { job . TaskGroups [ 0 ] . Name : { Stop : 20 , } , } , } ) assertNamesHaveIndexes ( t , intRange ( 0 , 19 ) , stopResultsToNames ( r . stop ) ) }
Tests the reconciler properly handles stopping allocations for a job that has
scaled down to zero desired
Tests the reconciler properly handles stopping allocations for a job that has scaled down to zero desired
// Set desired 0 // Create 20 existing allocations // Assert the correct results