diff --git a/usersec/forms.py b/usersec/forms.py index 005ff2b..b1b2bc4 100644 --- a/usersec/forms.py +++ b/usersec/forms.py @@ -16,9 +16,24 @@ HpcUserCreateRequest, ) -DEFAULT_USER_RESOURCES = {"tier1": 1, "tier2_mirrored": 0, "tier2_unmirrored": 0} -DEFAULT_GROUP_RESOURCES = {"tier1": 1, "tier2_mirrored": 0, "tier2_unmirrored": 0} -DEFAULT_PROJECT_RESOURCES = {"tier1": 1, "tier2_mirrored": 0, "tier2_unmirrored": 0} +DEFAULT_USER_RESOURCES = { + "tier1_scratch": 1, + "tier1_work": 1, + "tier2_mirrored": 0, + "tier2_unmirrored": 0, +} +DEFAULT_GROUP_RESOURCES = { + "tier1_scratch": 1, + "tier1_work": 1, + "tier2_mirrored": 0, + "tier2_unmirrored": 0, +} +DEFAULT_PROJECT_RESOURCES = { + "tier1_scratch": 1, + "tier1_work": 1, + "tier2_mirrored": 0, + "tier2_unmirrored": 0, +} class HpcGroupCreateRequestForm(forms.ModelForm): @@ -100,16 +115,27 @@ def __init__(self, *args, user, group, **kwargs): ) # Add fields for storage. Will be merged into resources_requested field. - self.fields["tier1"] = forms.IntegerField( + self.fields["tier1_scratch"] = forms.IntegerField( required=True, help_text=( - "Amount of storage on the fast primary ('tier 1') storage that can be used with parallel access " - "for computation." + "Amount of scratch storage on the fast primary ('tier 1') storage that can be used " + "with parallel access for computation." ), label="Fast Active Storage [TB]", ) - self.fields["tier1"].initial = group.resources_requested["tier1"] - self.fields["tier1"].widget.attrs["class"] = "form-control mergeToJson" + self.fields["tier1_scratch"].initial = group.resources_requested["tier1_scratch"] + self.fields["tier1_scratch"].widget.attrs["class"] = "form-control mergeToJson" + + self.fields["tier1_work"] = forms.IntegerField( + required=True, + help_text=( + "Amount of work storage on the fast primary ('tier 1') storage that can be used " + "with parallel access for computation." + ), + label="Fast Active Storage [TB]", + ) + self.fields["tier1_work"].initial = group.resources_requested["tier1_work"] + self.fields["tier1_work"].widget.attrs["class"] = "form-control mergeToJson" self.fields["tier2_unmirrored"] = forms.IntegerField( required=True, @@ -296,16 +322,27 @@ def __init__(self, *args, user=None, group=None, **kwargs): self.fields["members_dropdown"].widget.attrs["class"] = "form-control" # Add fields for storage. Will be merged into resources_requested field. - self.fields["tier1"] = forms.IntegerField( + self.fields["tier1_scratch"] = forms.IntegerField( + required=True, + help_text=( + "Amount of scratch storage on the fast primary ('tier 1') storage that can be used " + "with parallel access for computation." + ), + label="Fast Active Storage [TB]", + ) + self.fields["tier1_scratch"].initial = DEFAULT_PROJECT_RESOURCES["tier1_scratch"] + self.fields["tier1_scratch"].widget.attrs["class"] = "form-control mergeToJson" + + self.fields["tier1_work"] = forms.IntegerField( required=True, help_text=( - "Amount of storage on the fast primary ('tier 1') storage that can be used with parallel access " - "for computation." + "Amount of work storage on the fast primary ('tier 1') storage that can be used " + "with parallel access for computation." ), label="Fast Active Storage [TB]", ) - self.fields["tier1"].initial = DEFAULT_PROJECT_RESOURCES["tier1"] - self.fields["tier1"].widget.attrs["class"] = "form-control mergeToJson" + self.fields["tier1_work"].initial = DEFAULT_PROJECT_RESOURCES["tier1_work"] + self.fields["tier1_work"].widget.attrs["class"] = "form-control mergeToJson" self.fields["tier2_unmirrored"] = forms.IntegerField( required=True, @@ -412,16 +449,27 @@ def __init__(self, *args, user=None, project=None, **kwargs): self.fields["members_dropdown"].widget.attrs["class"] = "form-control" # Add fields for storage. Will be merged into resources_requested field. - self.fields["tier1"] = forms.IntegerField( + self.fields["tier1_scratch"] = forms.IntegerField( + required=True, + help_text=( + "Amount of scratch storage on the fast primary ('tier 1') storage that can be used " + "with parallel access for computation." + ), + label="Fast Active Storage [TB]", + ) + self.fields["tier1_scratch"].initial = DEFAULT_PROJECT_RESOURCES["tier1_scratch"] + self.fields["tier1_scratch"].widget.attrs["class"] = "form-control mergeToJson" + + self.fields["tier1_work"] = forms.IntegerField( required=True, help_text=( - "Amount of storage on the fast primary ('tier 1') storage that can be used with parallel access " - "for computation." + "Amount of work storage on the fast primary ('tier 1') storage that can be used " + "with parallel access for computation." ), label="Fast Active Storage [TB]", ) - self.fields["tier1"].initial = DEFAULT_PROJECT_RESOURCES["tier1"] - self.fields["tier1"].widget.attrs["class"] = "form-control mergeToJson" + self.fields["tier1_work"].initial = DEFAULT_PROJECT_RESOURCES["tier1_work"] + self.fields["tier1_work"].widget.attrs["class"] = "form-control mergeToJson" self.fields["tier2_unmirrored"] = forms.IntegerField( required=True, diff --git a/usersec/tests/factories.py b/usersec/tests/factories.py index 6c83295..b9dd55e 100644 --- a/usersec/tests/factories.py +++ b/usersec/tests/factories.py @@ -45,9 +45,10 @@ def hpc_obj_to_dict(obj): #: Valid data for HpcGroupCreateRequestForm. HPCGROUPCREATEREQUEST_FORM_DATA_VALID = { "resources_requested": json.dumps({"resource": 100}), - "tier1": 100, - "tier2_mirrored": 200, - "tier2_unmirrored": 300, + "tier1_scratch": 100, + "tier1_work": 200, + "tier2_mirrored": 300, + "tier2_unmirrored": 400, "description": "some group description", "expiration": "2022-01-01", "comment": "nothing", @@ -57,9 +58,10 @@ def hpc_obj_to_dict(obj): #: Valid data for HpcGroupChangeRequestForm. HPCGROUPCHANGEREQUEST_FORM_DATA_VALID = { "resources_requested": json.dumps({"resource": 111}), - "tier1": 111, - "tier2_mirrored": 222, - "tier2_unmirrored": 333, + "tier1_scratch": 111, + "tier1_work": 222, + "tier2_mirrored": 333, + "tier2_unmirrored": 444, "description": "updated group description", "expiration": "2023-01-01", "comment": "nothing", @@ -69,9 +71,10 @@ def hpc_obj_to_dict(obj): #: Valid data for HpcUserCreateRequestForm. HPCUSERCREATEREQUEST_FORM_DATA_VALID = { "resources_requested": json.dumps({"resource": 100}), - "tier1": 100, - "tier2_mirrored": 200, - "tier2_unmirrored": 300, + "tier1_scratch": 100, + "tier1_work": 200, + "tier2_mirrored": 300, + "tier2_unmirrored": 400, "email": "user@" + settings.INSTITUTE_EMAIL_DOMAINS.split(",")[0], "expiration": "2022-01-01", "comment": "nothing", @@ -88,9 +91,10 @@ def hpc_obj_to_dict(obj): #: Valid data for HpcProjectCreateRequestForm. HPCPROJECTCREATEREQUEST_FORM_DATA_VALID = { "resources_requested": json.dumps({"resource": 100}), - "tier1": 100, - "tier2_mirrored": 200, - "tier2_unmirrored": 300, + "tier1_scratch": 100, + "tier1_work": 200, + "tier2_mirrored": 300, + "tier2_unmirrored": 400, "description": "some project description", "name": "some-project", "expiration": "2022-01-01", @@ -102,9 +106,10 @@ def hpc_obj_to_dict(obj): #: Valid data for HpcProjectCreateRequestForm. HPCPROJECTCHANGEREQUEST_FORM_DATA_VALID = { "resources_requested": json.dumps({"resource": 111}), - "tier1": 111, - "tier2_mirrored": 222, - "tier2_unmirrored": 333, + "tier1_scratch": 111, + "tier1_work": 222, + "tier2_mirrored": 333, + "tier2_unmirrored": 444, "description": "updated project description", "expiration": "2022-01-01", "comment": "nothing", @@ -156,8 +161,18 @@ class Meta: owner = None # HpcUser delegate = None # HpcUser - resources_requested = {"tier1": 1, "tier2_mirrored": 0, "tier2_unmirrored": 0} - resources_used = {"tier1": 0.5, "tier2_mirrored": 0, "tier2_unmirrored": 0} + resources_requested = { + "tier1_scratch": 1, + "tier1_work": 1, + "tier2_mirrored": 0, + "tier2_unmirrored": 0, + } + resources_used = { + "tier1_scratch": 0.5, + "tier1_work": 0.5, + "tier2_mirrored": 0, + "tier2_unmirrored": 0, + } description = "this is a group" creator = factory.SubFactory(UserFactory) # User gid = 2000 diff --git a/usersec/tests/snapshots/snap_test_serializers.py b/usersec/tests/snapshots/snap_test_serializers.py index 9779a5e..2ee6f40 100644 --- a/usersec/tests/snapshots/snap_test_serializers.py +++ b/usersec/tests/snapshots/snap_test_serializers.py @@ -18,8 +18,18 @@ "name": "hpc-group0", "owner": None, "phone_number": "phone_number_placeholder", - "resources_requested": {"tier1": 1, "tier2_mirrored": 0, "tier2_unmirrored": 0}, - "resources_used": {"tier1": 0.5, "tier2_mirrored": 0, "tier2_unmirrored": 0}, + "resources_requested": { + "tier1_scratch": 1, + "tier1_work": 1, + "tier2_mirrored": 0, + "tier2_unmirrored": 0, + }, + "resources_used": { + "tier1_scratch": 0.5, + "tier1_work": 0.5, + "tier2_mirrored": 0, + "tier2_unmirrored": 0, + }, "status": "INITIAL", "uuid": "uuid_placeholder", } diff --git a/usersec/tests/test_forms.py b/usersec/tests/test_forms.py index ffd419f..7453541 100644 --- a/usersec/tests/test_forms.py +++ b/usersec/tests/test_forms.py @@ -88,7 +88,11 @@ def test_form_initials(self): form.fields["resources_requested"].initial, self.hpc_group.resources_requested ) self.assertEqual( - form.fields["tier1"].initial, self.hpc_group.resources_requested.get("tier1") + form.fields["tier1_scratch"].initial, + self.hpc_group.resources_requested.get("tier1_scratch"), + ) + self.assertEqual( + form.fields["tier1_work"].initial, self.hpc_group.resources_requested.get("tier1_work") ) self.assertEqual( form.fields["tier2_mirrored"].initial, diff --git a/usersec/tests/test_views.py b/usersec/tests/test_views.py index 3d66d63..68328e0 100644 --- a/usersec/tests/test_views.py +++ b/usersec/tests/test_views.py @@ -266,9 +266,10 @@ def test_post(self): "comment": "I made a comment!", "resources_requested": '{"updated": 400}', "description": "description changed", - "tier1": 100, - "tier2_mirrored": 200, - "tier2_unmirrored": 300, + "tier1_scratch": 100, + "tier1_work": 200, + "tier2_mirrored": 300, + "tier2_unmirrored": 400, "expiration": "2050-01-01", } @@ -312,9 +313,10 @@ def test_post_fail(self): "comment": "I made a comment!", "resources_requested": "", "description": "description changed", - "tier1": 100, - "tier2_mirrored": 200, - "tier2_unmirrored": 300, + "tier1_scratch": 100, + "tier1_work": 200, + "tier2_mirrored": 300, + "tier2_unmirrored": 400, "expiration": "2050-01-01", } @@ -545,9 +547,10 @@ def test_post(self): "comment": "I made a comment!", "resources_requested": '{"updated": 400}', "description": "description changed", - "tier1": 100, - "tier2_mirrored": 200, - "tier2_unmirrored": 300, + "tier1_scratch": 100, + "tier1_work": 200, + "tier2_mirrored": 300, + "tier2_unmirrored": 400, "expiration": "2050-01-01", } @@ -591,9 +594,10 @@ def test_post_fail(self): "comment": "I made a comment!", "resources_requested": "", "description": "description changed", - "tier1": 100, - "tier2_mirrored": 200, - "tier2_unmirrored": 300, + "tier1_scratch": 100, + "tier1_work": 200, + "tier2_mirrored": 300, + "tier2_unmirrored": 400, "expiration": "2050-01-01", } @@ -931,9 +935,10 @@ def test_post(self): update = { "comment": "I made a comment!", "resources_requested": '{"updated": 400}', - "tier1": 100, - "tier2_mirrored": 200, - "tier2_unmirrored": 300, + "tier1_scratch": 100, + "tier1_work": 200, + "tier2_mirrored": 300, + "tier2_unmirrored": 400, "email": "other@" + settings.INSTITUTE_EMAIL_DOMAINS.split(",")[0], "expiration": "2050-01-01", } @@ -977,9 +982,10 @@ def test_post_fail(self): update = { "comment": "I made a comment!", "resources_requested": "", - "tier1": 100, - "tier2_mirrored": 200, - "tier2_unmirrored": 300, + "tier1_scratch": 100, + "tier1_work": 200, + "tier2_mirrored": 300, + "tier2_unmirrored": 400, "email": "other@" + settings.INSTITUTE_EMAIL_DOMAINS.split(",")[0], "expiration": "2050-01-01", } @@ -1593,9 +1599,10 @@ def test_post(self): update = { "comment": "I made a comment!", "resources_requested": '{"updated": 400}', - "tier1": 100, - "tier2_mirrored": 200, - "tier2_unmirrored": 300, + "tier1_scratch": 100, + "tier1_work": 200, + "tier2_mirrored": 300, + "tier2_unmirrored": 400, "expiration": self.obj.expiration, "name": self.obj.name, "description": self.obj.description, @@ -1956,9 +1963,10 @@ def test_post(self): update = { "comment": "I made a comment!", "resources_requested": '{"updated": 444}', - "tier1": 111, - "tier2_mirrored": 222, - "tier2_unmirrored": 333, + "tier1_scratch": 111, + "tier1_work": 222, + "tier2_mirrored": 333, + "tier2_unmirrored": 444, "expiration": self.obj.expiration, "description": self.obj.description, "members": [m.id for m in self.obj.members.all()],