// Create and delete the backend.
backend_state.deploy_backend("tag1", b_config_1, r_config_1)
backend_state.update()
replicas(backend_state)[0]._actor.set_ready()
backend_state.update()
delete_goal = backend_state.delete_backend("tag1")
backend_state.update()
After Change
b_config_1.experimental_graceful_shutdown_timeout_s = grace_period_s
// Create and delete the backend.
tag = "tag"
backend_state.deploy_backend(tag, b_config_1, r_config_1)
backend_state.update()
backend_state._replicas[tag].get()[0]._actor.set_ready()
backend_state.update()
delete_goal = backend_state.delete_backend(tag)
backend_state.update()
// Replica should remain in STOPPING until it finishes.
assert len(backend_state._replicas[tag].get()) == 1
assert len(
backend_state._replicas[tag].get(states=[ReplicaState.STOPPING])) == 1
assert backend_state._replicas[tag].get()[0]._actor.stopped
backend_state.update()
backend_state.update()
// force_stop shouldn"t be called until after the timer.
assert not backend_state._replicas[tag].get(
)[0]._actor.force_stopped_counter
assert not backend_state._replicas[tag].get()[0]._actor.cleaned_up
assert len(backend_state._replicas[tag].get()) == 1
assert len(
backend_state._replicas[tag].get(states=[ReplicaState.STOPPING])) == 1
// Advance the timer, now the replica should be force stopped.
timer.advance(grace_period_s + 0.1)
backend_state.update()
assert backend_state._replicas[tag].get()[
0]._actor.force_stopped_counter == 1
assert not backend_state._replicas[tag].get()[0]._actor.cleaned_up
assert len(backend_state._replicas[tag].get()) == 1
assert len(
backend_state._replicas[tag].get(states=[ReplicaState.STOPPING])) == 1
assert not goal_manager.check_complete(delete_goal)
// Force stop should be called repeatedly until the replica stops.
backend_state.update()
assert backend_state._replicas[tag].get()[
0]._actor.force_stopped_counter == 2
assert not backend_state._replicas[tag].get()[0]._actor.cleaned_up
assert len(backend_state._replicas[tag].get()) == 1
assert len(
backend_state._replicas[tag].get(states=[ReplicaState.STOPPING])) == 1
assert not goal_manager.check_complete(delete_goal)
// Once the replica is done stopping, it should be removed.
replica = backend_state._replicas[tag].get()[0]
replica._actor.set_done_stopping()
backend_state.update()
assert len(backend_state._replicas[tag].get()) == 0