Skip to content

Commit 433174e

Browse files
author
Алексеев Павел Леонидович
committed
DATA-8394 Fix handling issue type and project
1 parent 7c4f9b7 commit 433174e

File tree

11 files changed

+70
-20
lines changed

11 files changed

+70
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ receivers:
3535
eva__field__severity: High
3636
value: '{{$value}}'
3737
annotations:
38-
eva__field__project: data-alerts
38+
eva__project: data-alerts
3939
eva__field__issue_type_name: Task
4040
eva__field__cf_env: PROD
4141
summary: DataTest0 summary

_DEV.scripts/alert-sample.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"description": "Some description QAZ2\nof DataTest0 alert\nVALUE: 3\n",
1919
"eva__field__assignee": "plalexeev",
2020
"eva__field__issue_type_name": "Alert",
21-
"eva__field__project_key": "DATA",
21+
"eva__project": "DATA",
2222
"qaz1_annotation": "qaz1_annotation_value",
2323
"summary": "DataTest0 summary",
2424
"value": "3"

_DEV.scripts/alert-sample.small.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"description": "Some description QAZ2\nof DataTest0 alert\nVALUE: 3\n",
1919
"eva__field__assignee": "plalexeev",
2020
"eva__field__issue_type_name": "Alert",
21-
"eva__field__project_key": "DATA",
21+
"eva__project": "DATA",
2222
"qaz1_annotation": "qaz1_annotation_value",
2323
"summary": "DataTest0 summary",
2424
"value": "3"

_DEV.scripts/eva.connekt.kts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,51 @@ POST(api) {
6767
)
6868
}
6969

70+
POST(api) {
71+
contentType("application/json")
72+
header("Authorization", "Bearer $token")
73+
body(
74+
"""{
75+
"jsonrpc": "2.2",
76+
"method": "CmfTask.create",
77+
"kwargs": {
78+
"logic_type" : "Alert",
79+
"name" : "[] Завершился ошибкой DAG reindex - 2025-08-23",
80+
"text" : "test description - empty",
81+
"tags" : [ "DQ", "DQ:issue", "alert:airflow" ],
82+
"Component/s" : "DQ-issues+alerts, DevOps+infrastructure",
83+
"priority" : "1",
84+
"project" : "data-alerts",
85+
"cf_alert_id" : "alert[2f559d99774e36e8]"
86+
},
87+
"callid": "необязательный параметр",
88+
"jshash": "??",
89+
"fields": "***",
90+
"no_meta": true
91+
}"""
92+
)
93+
}
94+
95+
96+
.then {
97+
val id = jsonPath().readString("\$.result")
98+
POST(api) {
99+
contentType("application/json")
100+
header("Authorization", "Bearer $token")
101+
body(
102+
"""{
103+
"jsonrpc": "2.2",
104+
"method": "CmfTask.get",
105+
"kwargs": {"filter": ["id", "==", "$id"]},
106+
"callid": "необязательный параметр",
107+
"jshash": "??",
108+
"fields": "***",
109+
"no_meta": true
110+
}"""
111+
)
112+
}
113+
}
114+
70115
POST(api) {
71116
contentType("application/json")
72117
header("Authorization", "Bearer $token")

src/main/groovy/info/hubbitus/alertmanager/DTO/AlertContext.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ class AlertContext {
3434
CmfTask toCmfTask() {
3535
return new CmfTask(
3636
project: field(EVA__PROJECT),
37-
type: field(EVA__ISSUE_TYPE_NAME),
37+
parent: field(EVA__PROJECT),
38+
logic_type: field(EVA__ISSUE_TYPE_NAME),
3839
name: field('summary'),
3940
text: field('description')
4041
).tap {CmfTask task ->
4142
task.properties.findAll {
42-
!(it.key as String in ['class', 'other_fields', 'project', 'type', 'name', 'text'])
43+
!(it.key as String in ['class', 'other_fields', 'project', 'parent', 'logic_type', 'name', 'text']) // Set before
4344
}.each {
4445
task.setProperty(it.key as String, evaFields[it.key]?.value)
4546
}

src/main/groovy/info/hubbitus/alertmanager/DTO/CmfTask.groovy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package info.hubbitus.alertmanager.DTO
33
import groovy.transform.Canonical
44
import groovy.transform.CompileStatic
55
import groovy.transform.ToString
6-
import info.hubbitus.alertmanager.service.GlobalConfig
76
import io.vertx.core.json.JsonObject
87
import org.eclipse.microprofile.config.ConfigProvider
98

@@ -36,7 +35,7 @@ class CmfTask {
3635
String id
3736
String parent
3837
String project
39-
String type = 'Task'
38+
String logic_type
4039
String name
4140
String code
4241
String text

src/main/groovy/info/hubbitus/alertmanager/service/GlobalConfig.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class GlobalConfig {
1919
String getBaseURL(RoutingContext context) {
2020
return (
2121
"auto" == baseURL
22-
? "${context.request().isSSL() ? "https" : "http"}://${context.request().getHeader("host")}"
22+
? "${context?.request()?.isSSL() ? "https" : "http"}://${context?.request()?.getHeader("host")}"
2323
: baseURL
2424
)
2525
}

src/main/resources/application.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ quarkus:
4747
app:
4848
# Special value "auto" means to use Host HTTP header automatically.
4949
# Value without trailing /
50-
baseURL: auto
50+
# baseURL: auto
5151
# baseURL: https://eva-alert.k8s-dev.gid.team
52+
baseURL: http://localhost:8080
5253
eva:
5354
api:
5455
base: https://eva-lab.gid.team/

src/test/groovy/info/hubbitus/alertmanager/EvaServiceTest.groovy

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import info.hubbitus.alertmanager.DTO.AlertContext
77
import info.hubbitus.alertmanager.DTO.AlertRequest
88
import info.hubbitus.alertmanager.DTO.CmfTask
99
import info.hubbitus.alertmanager.service.EvateamService
10+
import info.hubbitus.alertmanager.service.GlobalConfig
1011
import io.quarkus.test.junit.QuarkusTest
1112
import io.smallrye.mutiny.Uni
1213
import io.vertx.core.json.JsonObject
@@ -36,6 +37,9 @@ class EvaServiceTest {
3637
@Inject
3738
Logger log
3839

40+
@Inject
41+
GlobalConfig config
42+
3943
@BeforeEach
4044
void setupTest() {
4145
objectMapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true)
@@ -48,7 +52,7 @@ class EvaServiceTest {
4852
project: 'data-alerts',
4953
name: 'Test alertmanager-evateam',
5054
text: 'Test text creating issue from java',
51-
type: 'Task',
55+
logic_type: 'Alert',
5256
other_fields: [
5357
cf_alert_id: 'autotest',
5458
workflow: 'Data-Alert'
@@ -57,18 +61,18 @@ class EvaServiceTest {
5761
)
5862

5963
CmfTask task = uni.await().indefinitely()
60-
log.debugf('Created task id [%s]', task.getId())
64+
log.debugf('Created task [%s]', task.taskURI(config.getBaseURL(null)))
6165
assertThat(task.id, notNullValue())
6266
assertThat(task.name, nullValue())
6367
assertThat(task.text, nullValue())
64-
assertThat(task.type, is('Task'))
68+
assertThat(task.logic_type, nullValue())
6569
assertThat(task.other_fields, is([:]))
6670

6771
task = eva.getTaskById(task.id).await().indefinitely()
68-
log.debugf('Created task %s, full: %s', task.taskURI(), task)
72+
log.debugf('Created task %s, full: %s', task.taskURI(config.getBaseURL(null)), task)
6973
assertThat(task.name, is('Test alertmanager-evateam'))
7074
assertThat(task.code, startsWith('ALERT-'))
71-
assertThat(task.type, is('Task'))
75+
assertThat(task.logic_type, nullValue()) // Does not returned in the result
7276
assertThat(task.text, nullValue()) // Does not returned by default
7377
assertThat(task.parent, nullValue())
7478
assertThat(task.project, is('CmfProject:07796e28-2054-11f0-a901-3e9b82c78085'))
@@ -178,11 +182,11 @@ class EvaServiceTest {
178182
CmfTask task = issuesToCreate.first()
179183
// Values may be filled only n saved issues:
180184
assertThat(task.id, nullValue())
181-
assertThat(task.parent, nullValue())
185+
assertThat(task.parent, is('data-alerts'))
182186
assertThat(task.code, nullValue())
183187
// Parsed values
184188
assertThat(task.project, is('data-alerts'))
185-
assertThat(task.type, is('Task'))
189+
assertThat(task.logic_type, is('Alert'))
186190
assertThat(task.name, startsWith("DataTest0 summary ${LocalDate.now()}"))
187191
assertThat(task.text, is("Some description QAZ2\nof DataTest0 alert\nVALUE: 3\nText should be as is: \$some, \$200"))
188192
assertThat(task.other_fields, is([priority: "1", assignee: 'plalexeev', 'composite field name': 'composite field value', 'cf_alert_id': alertContext.alert.hashCode().toString()]))

src/test/resources/alert-sample.DATA-8310.json5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"eva__field__value__1": "DQ-issues+alerts, DevOps+infrastructure",
3535
"eva__issue_type_name": "Alert",
3636
"eva__bql_to_find_issue_for_update": "[[\"cf_alert_id\",\"=\",\"${context.alert.fingerprint}\"],[\"cache_status_type\",\"!=\",\"CLOSED\"]]",
37-
"eva__field__project": "data-alerts"
37+
"eva__project": "data-alerts"
3838
},
3939
"startsAt": "2025-05-27T09:11:00Z",
4040
"endsAt": "0001-01-01T00:00:00Z",
@@ -78,7 +78,7 @@
7878
"eva__field__value__1": "DQ-issues+alerts, DevOps+infrastructure",
7979
"eva__issue_type_name": "Alert",
8080
"eva__bql_to_find_issue_for_update": "[\"cf_alert_id\",\"=\",\"${context.alert.fingerprint}\"],[\"cache_status_type\",\"!=\",\"CLOSED\"]]",
81-
"eva__field__project": "data-alerts"
81+
"eva__project": "data-alerts"
8282
},
8383
"externalURL": "https://alert-private.gid.team",
8484
"version": "4",

0 commit comments

Comments
 (0)