Commit 848767ac authored by lukas.burgey's avatar lukas.burgey

Add test for a bug

parent ef8a0bd7
......@@ -299,6 +299,7 @@ def test_upstream_changed_userinfo_redeploy(user, deployed_vo_deployment, upstre
assert state.userinfo['name'] == 'new name'
# }}}
# SERIALIZERS {{{
def test_deployment_state_serializer(pending_vo_deployment):
# setup a deployed deployment for the service
......@@ -307,3 +308,78 @@ def test_deployment_state_serializer(pending_vo_deployment):
ser = webpage_serializers.DeploymentStateSerializer(state)
assert ser.data is not None
# }}}
# VO-Deployment and Service-Deployment interaction {{{
def test_both_service_and_vo_deployments_remove(pending_vo_deployment, pending_service_deployment, service):
"""
The user first requests a VO-Dep which deploys a Service.
Then an additional Service-Deployment for the same Service (which actually should change nothing)
Then the VO-Deployment is removed.
The Service must still be deployed because of the Service-Deployment
"""
vo_dep, state_from_vo = pending_vo_deployment(service=service)
assert state_from_vo.is_pending
service_dep, state_from_service = pending_service_deployment(service=service)
assert state_from_service.is_pending
# these two deployments should've mapped to the same state
assert state_from_vo.pk == state_from_service.pk
state = state_from_vo # might as well just call it state from here on
# remove first dep
vo_dep.state_target = NOT_DEPLOYED
vo_dep.save()
vo_dep.target_changed()
# still pending as there is still the service deployment
assert state.is_pending
# remove second dep
service_dep.state_target = NOT_DEPLOYED
service_dep.save()
service_dep.target_changed()
state.refresh_from_db()
# both deployments are set NOT_DEPLOYED so the state is now pending
assert not state.is_orphaned
assert state.state == NOT_DEPLOYED
assert not state.is_pending
def test_both_service_and_vo_deployments_delete(pending_vo_deployment, pending_service_deployment, service):
"""
The same as test_both_service_and_vo_deployments_remove but we delete the deployments instead of removing them
"""
vo_dep, state_from_vo = pending_vo_deployment(service=service)
assert state_from_vo.is_pending
service_dep, state_from_service = pending_service_deployment(service=service)
assert state_from_service.is_pending
# these two deployments should've mapped to the same state
assert state_from_vo.pk == state_from_service.pk
state = state_from_vo # might as well just call it state from here on
# delete first dep
vo_dep.delete()
state.dep_target_changed()
# still pending as there is still the service deployment
assert state.is_pending
# delete second dep
service_dep.delete()
state.dep_target_changed()
state.refresh_from_db()
# both deployments are deleted so the state is now pending
assert state.is_orphaned
assert state.state == NOT_DEPLOYED
assert state.is_pending # because the state is orphaned
# }}}
Subproject commit 3724cc54526c1241ca0b12b87665254507739e15
Subproject commit af900e6c6a4b0792eb60585dde36bff351a1c443
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment