Skip to content

Commit

Permalink
Merge pull request #524 from ARGOeu/devel
Browse files Browse the repository at this point in the history
Version 3.4.6
  • Loading branch information
themiszamani authored Feb 2, 2023
2 parents faa64f6 + c8e6109 commit 9add5bf
Show file tree
Hide file tree
Showing 34 changed files with 13,808 additions and 8,491 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Changelog

## [3.4.6] - 2023-02-01

### Added

* ARGO-4103 POEM POST service types with tags=poem field set

### Fixed

* ARGO-4104 Reflect changing number of entries in pagination on rendering of tuples
* ARGO-4160 Form validation triggered wrong
* ARGO-4179 Fix duplicated tuple logic clear off on metric profiles

### Changed

* ARGO-4030 Switch aggregation profile page to react-hook-form library
* ARGO-4033 Switch metric overrides page to react-hook-form library
* ARGO-4034 Switch metric profile page to react-hook-form library
* ARGO-4035 Switch metric and metric templates page to react-hook-form library
* ARGO-4036 Switch metric tags page to react-hook-form library
* ARGO-4038 Remove formik from operations profile page
* ARGO-4040 Switch probe page to react-hook-form library
* ARGO-4043 Switch users page to react-hook-form library
* ARGO-4044 Switch YUM repo page to react-hook-form library
* ARGO-4161 Bump libs

## [3.4.5] - 2022-11-03

### Added
Expand Down
10 changes: 7 additions & 3 deletions poem/Poem/api/internal_views/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,9 +740,13 @@ def put(self, request):
"{hostname} {metric} {parameter} {value}".format(**item)
)

conf.globalattribute = json.dumps(global_attrs)
conf.hostattribute = json.dumps(host_attrs)
conf.metricparameter = json.dumps(metric_params)
conf.globalattribute = json.dumps(global_attrs) if \
len(global_attrs) >= 1 and global_attrs[0] != " " else ""
conf.hostattribute = json.dumps(host_attrs) \
if len(host_attrs) >= 1 and host_attrs[0] != " " else ""
conf.metricparameter = json.dumps(metric_params) \
if len(metric_params) >= 1 and metric_params[0] != " " \
else ""

conf.save()

Expand Down
46 changes: 20 additions & 26 deletions poem/Poem/api/internal_views/metrictemplates.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,8 +769,14 @@ def get(self, request, name=None):
if name:
try:
tag = admin_models.MetricTags.objects.get(name=name)
serializer = serializers.MetricTagsSerializer(tag)
return Response(serializer.data)
metrics = admin_models.MetricTemplate.objects.filter(
tags__name=tag.name
)
return Response({
"id": tag.id,
"name": tag.name,
"metrics": sorted([metric.name for metric in metrics])
})

except admin_models.MetricTags.DoesNotExist:
return Response(
Expand All @@ -780,8 +786,18 @@ def get(self, request, name=None):

else:
tags = admin_models.MetricTags.objects.all().order_by('name')
serializer = serializers.MetricTagsSerializer(tags, many=True)
return Response(serializer.data)
data = list()
for tag in tags:
metrics = admin_models.MetricTemplate.objects.filter(
tags__name=tag.name
)
data.append({
"id": tag.id,
"name": tag.name,
"metrics": sorted([metric.name for metric in metrics])
})

return Response(data)

def post(self, request):
if request.tenant.schema_name == get_public_schema_name() and \
Expand Down Expand Up @@ -1038,33 +1054,11 @@ def delete(self, request, name):
)


class ListMetricTemplates4Tag(APIView):
authentication_classes = (SessionAuthentication,)

def get(self, request, tag):
try:
admin_models.MetricTags.objects.get(name=tag)
mts = admin_models.MetricTemplate.objects.filter(tags__name=tag)

return Response(sorted([mt.name for mt in mts]))

except admin_models.MetricTags.DoesNotExist:
return Response(
{"detail": "Requested tag not found."},
status=status.HTTP_404_NOT_FOUND
)


class ListPublicMetricTags(ListMetricTags):
authentication_classes = ()
permission_classes = ()


class ListPublicMetricTemplates4Tag(ListMetricTemplates4Tag):
authentication_classes = ()
permission_classes = ()


class ListDefaultPorts(APIView):
authentication_classes = (SessionAuthentication,)

Expand Down
6 changes: 0 additions & 6 deletions poem/Poem/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ class Meta:
model = models.ThresholdsProfiles


class MetricTagsSerializer(serializers.ModelSerializer):
class Meta:
model = MetricTags
fields = "__all__"


class DefaultPortsSerializer(serializers.ModelSerializer):
class Meta:
model = DefaultPort
Expand Down
39 changes: 39 additions & 0 deletions poem/Poem/api/tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -3663,6 +3663,45 @@ def test_put_configuration_regular_user(self):
])
)

def test_put_configuration_with_only_name(self):
data = {
"id": self.configuration1.id,
"name": "local_updated",
"global_attributes": [
{
"attribute": "",
"value": ""
}
],
"host_attributes": [
{
"hostname": "",
"attribute": "",
"value": ""
}
],
"metric_parameters": [
{
"hostname": "",
"metric": "",
"parameter": "",
"value": ""
}
]
}
content, content_type = encode_data(data)
request = self.factory.put(self.url, content, content_type=content_type)
force_authenticate(request, user=self.user)
response = self.view(request)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
conf = poem_models.MetricConfiguration.objects.get(
id=self.configuration1.id
)
self.assertEqual(conf.name, "local_updated")
self.assertEqual(conf.globalattribute, "")
self.assertEqual(conf.hostattribute, "")
self.assertEqual(conf.metricparameter, "")

def test_put_configuration_with_existing_name_super_user(self):
data = {
"id": self.configuration1.id,
Expand Down
79 changes: 40 additions & 39 deletions poem/Poem/api/tests/test_metrictemplates.py
Original file line number Diff line number Diff line change
Expand Up @@ -9601,19 +9601,23 @@ def test_get_metric_tags_admin_superuser(self):
[
{
"id": self.tag2.id,
"name": "deprecated"
"name": "deprecated",
"metrics": []
},
{
"id": self.tag1.id,
"name": "internal"
"name": "internal",
"metrics": ["argo.AMS-Check"]
},
{
"id": self.tag3.id,
"name": "test_tag1"
"name": "test_tag1",
"metrics": ["argo.AMS-Check", "argo.EGI-Connectors-Check"]
},
{
"id": self.tag4.id,
"name": "test_tag2"
"name": "test_tag2",
"metrics": ["argo.AMS-Check", "org.apel.APEL-Pub"]
}
]
)
Expand All @@ -9627,19 +9631,23 @@ def test_get_metric_tags_admin_regular_user(self):
[
{
"id": self.tag2.id,
"name": "deprecated"
"name": "deprecated",
"metrics": []
},
{
"id": self.tag1.id,
"name": "internal"
"name": "internal",
"metrics": ["argo.AMS-Check"]
},
{
"id": self.tag3.id,
"name": "test_tag1"
"name": "test_tag1",
"metrics": ["argo.AMS-Check", "argo.EGI-Connectors-Check"]
},
{
"id": self.tag4.id,
"name": "test_tag2"
"name": "test_tag2",
"metrics": ["argo.AMS-Check", "org.apel.APEL-Pub"]
}
]
)
Expand All @@ -9653,19 +9661,23 @@ def test_get_metric_tags_tenant_superuser(self):
[
{
"id": self.tag2.id,
"name": "deprecated"
"name": "deprecated",
"metrics": []
},
{
"id": self.tag1.id,
"name": "internal"
"name": "internal",
"metrics": ["argo.AMS-Check"]
},
{
"id": self.tag3.id,
"name": "test_tag1"
"name": "test_tag1",
"metrics": ["argo.AMS-Check", "argo.EGI-Connectors-Check"]
},
{
"id": self.tag4.id,
"name": "test_tag2"
"name": "test_tag2",
"metrics": ["argo.AMS-Check", "org.apel.APEL-Pub"]
}
]
)
Expand All @@ -9679,19 +9691,23 @@ def test_get_metric_tags_tenant_regular_user(self):
[
{
"id": self.tag2.id,
"name": "deprecated"
"name": "deprecated",
"metrics": []
},
{
"id": self.tag1.id,
"name": "internal"
"name": "internal",
"metrics": ["argo.AMS-Check"]
},
{
"id": self.tag3.id,
"name": "test_tag1"
"name": "test_tag1",
"metrics": ["argo.AMS-Check", "argo.EGI-Connectors-Check"]
},
{
"id": self.tag4.id,
"name": "test_tag2"
"name": "test_tag2",
"metrics": ["argo.AMS-Check", "org.apel.APEL-Pub"]
}
]
)
Expand All @@ -9709,7 +9725,8 @@ def test_get_metric_tag_by_name_admin_superuser(self):
response.data,
{
"id": self.tag1.id,
"name": "internal"
"name": "internal",
"metrics": ["argo.AMS-Check"]
}
)

Expand All @@ -9721,7 +9738,8 @@ def test_get_metric_tag_by_name_admin_regular_user(self):
response.data,
{
"id": self.tag1.id,
"name": "internal"
"name": "internal",
"metrics": ["argo.AMS-Check"]
}
)

Expand All @@ -9733,7 +9751,8 @@ def test_get_metric_tag_by_name_tenant_superuser(self):
response.data,
{
"id": self.tag1.id,
"name": "internal"
"name": "internal",
"metrics": ["argo.AMS-Check"]
}
)

Expand All @@ -9745,7 +9764,8 @@ def test_get_metric_tag_by_name_tenant_regular_user(self):
response.data,
{
"id": self.tag1.id,
"name": "internal"
"name": "internal",
"metrics": ["argo.AMS-Check"]
}
)

Expand Down Expand Up @@ -14399,25 +14419,6 @@ def test_delete_nonexisting_metric_tag_tenant_regular_user(self, mock_sync):
)


class ListMetricTemplates4Tag(TenantTestCase):
def setUp(self) -> None:
self.factory = TenantRequestFactory(self.tenant)
self.view = views.ListMetricTemplates4Tag.as_view()
self.url = '/api/v2/internal/metrictags/'
self.user = CustUser.objects.create_user(username='test')

mock_db()

def test_get_metrics4tag(self):
request = self.factory.get(self.url + "test_tag2")
force_authenticate(request, user=self.user)
response = self.view(request, "test_tag2")
self.assertEqual(
response.data,
["argo.AMS-Check", "org.apel.APEL-Pub"]
)


class ListDefaultPortsTests(TenantTestCase):
def setUp(self):
self.factory = TenantRequestFactory(self.tenant)
Expand Down
8 changes: 4 additions & 4 deletions poem/Poem/api/tests/test_yumrepos.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ def test_put_yum_repo_with_nonexisting_tag_tenant_user(self):

def test_put_yum_repo_with_nonexisting_repo_sp_superuser(self):
data = {
'id': 999,
'id': self.repo1.id + self.repo2.id,
'name': 'repo-3',
'tag': 'CentOS 6',
'description': 'New repo description.'
Expand All @@ -948,7 +948,7 @@ def test_put_yum_repo_with_nonexisting_repo_sp_superuser(self):

def test_put_yum_repo_with_nonexisting_repo_sp_user(self):
data = {
'id': 999,
'id': self.repo1.id + self.repo2.id,
'name': 'repo-3',
'tag': 'CentOS 6',
'description': 'New repo description.'
Expand All @@ -966,7 +966,7 @@ def test_put_yum_repo_with_nonexisting_repo_sp_user(self):

def test_put_yum_repo_with_nonexisting_repo_tenant_superuser(self):
data = {
'id': 999,
'id': self.repo1.id + self.repo2.id,
'name': 'repo-3',
'tag': 'CentOS 6',
'description': 'New repo description.'
Expand All @@ -984,7 +984,7 @@ def test_put_yum_repo_with_nonexisting_repo_tenant_superuser(self):

def test_put_yum_repo_with_nonexisting_repo_tenant_user(self):
data = {
'id': 999,
'id': self.repo1.id + self.repo2.id,
'name': 'repo-3',
'tag': 'CentOS 6',
'description': 'New repo description.'
Expand Down
Loading

0 comments on commit 9add5bf

Please sign in to comment.