Skip to content

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
gskrobisz committed Jan 15, 2025
1 parent bd2654f commit 43a81b6
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,28 @@ class ManagementResources(
private implicit final val plainBytes: FromEntityUnmarshaller[Array[Byte]] = Unmarshaller.byteArrayUnmarshaller
private implicit final val plainString: FromEntityUnmarshaller[String] = Unmarshaller.stringUnmarshaller

// TODO: This is workaround for touk/nussknacker-example-scenarios-library that deploys tests with plain text comment.
// https://github.com/TouK/nussknacker-scenario-examples-library/pull/7
private def deployRequestEntity: Directive1[RunDeploymentRequest] = {
entity(as[Option[String]]).flatMap { optStr =>
{
optStr match {
case None => provide(RunDeploymentRequest(None, None))
case Some(body) =>
io.circe.parser.parse(body) match {
case Right(json) =>
json.as[RunDeploymentRequest] match {
case Right(request) => provide(request)
case Left(notValidDeployRequest) =>
reject(MalformedRequestContentRejection("lorem ipsum", notValidDeployRequest))
}
case Left(notJson) => provide(RunDeploymentRequest(None, Some(body)))
}
}
}
}
}

def securedRoute(implicit user: LoggedUser): Route = {
pathPrefix("adminProcessManagement") {
path("snapshot" / ProcessNameSegment) { processName =>
Expand Down Expand Up @@ -120,7 +142,7 @@ class ManagementResources(
}
} ~
path("deploy" / ProcessNameSegment) { processName =>
(post & processId(processName) & entity(as[RunDeploymentRequest]) & parameters(Symbol("savepointPath"))) {
(post & processId(processName) & deployRequestEntity & parameters(Symbol("savepointPath"))) {
(processIdWithName, request, savepointPath) =>
canDeploy(processIdWithName) {
complete {
Expand All @@ -143,7 +165,7 @@ class ManagementResources(
pathPrefix("processManagement") {

path("deploy" / ProcessNameSegment) { processName =>
(post & processId(processName) & entity(as[RunDeploymentRequest])) { (processIdWithName, request) =>
(post & processId(processName) & deployRequestEntity) { (processIdWithName, request) =>
canDeploy(processIdWithName) {
complete {
measureTime("deployment", metricRegistry) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,17 @@ trait NuResourcesTest
) ~>
withPermissions(deployRoute(), Permission.Deploy, Permission.Read)

// TODO: See comment in ManagementResources.deployRequestEntity
protected def deployProcessCommentOnly(
processName: ProcessName,
comment: Option[String] = None
): RouteTestResult =
Post(
s"/processManagement/deploy/$processName",
HttpEntity(ContentTypes.`application/json`, comment.getOrElse(""))
) ~>
withPermissions(deployRoute(), Permission.Deploy, Permission.Read)

protected def cancelProcess(
processName: ProcessName,
comment: Option[String] = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,34 @@ class ManagementResourcesSpec
}
}

// TODO: To be removed. See comment in ManagementResources.deployRequestEntity
test("deploys and cancels with plain text comment") {
saveCanonicalProcessAndAssertSuccess(ProcessTestData.sampleScenario)
deployProcessCommentOnly(
ProcessTestData.sampleScenario.name,
comment = Some("deployComment")
) ~> checkThatEventually {
getProcess(processName) ~> check {
val processDetails = responseAs[ScenarioWithDetails]
processDetails.lastStateAction.exists(_.actionName == ScenarioActionName.Deploy) shouldBe true
}
}
}

// TODO: To be removed. See comment in ManagementResources.deployRequestEntity
test("deploys and cancels with plain text no comment") {
saveCanonicalProcessAndAssertSuccess(ProcessTestData.sampleScenario)
deployProcessCommentOnly(
ProcessTestData.sampleScenario.name,
comment = None
) ~> checkThatEventually {
getProcess(processName) ~> check {
val processDetails = responseAs[ScenarioWithDetails]
processDetails.lastStateAction.exists(_.actionName == ScenarioActionName.Deploy) shouldBe true
}
}
}

test("deploys and cancels with comment") {
saveCanonicalProcessAndAssertSuccess(ProcessTestData.sampleScenario)
deployProcess(
Expand Down
2 changes: 2 additions & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
* [#7446](https://github.com/TouK/nussknacker/pull/7446) Small changes regarding node errors in fragments used in scenarios:
* Fragment error node tips in scenarios are now clickable and open problematic node edit window in a new tab.
* Fragment nodes are now highlighted when they contain nodes with errors.
* [#6860](https://github.com/TouK/nussknacker/pull/6860) Ability to configure deploy action parameters and apply those parameters in deploy http request.
Kafka source has "offset reset strategy" parameter that controls starting point for reading events.

## 1.18

Expand Down
2 changes: 2 additions & 0 deletions docs/MigrationGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ To see the biggest differences please consult the [changelog](Changelog.md).
* [#7379](https://github.com/TouK/nussknacker/pull/7379) Removed CustomAction mechanism.
If there were any custom actions defined in some custom DeploymentManager implementation,
they should be modified to use the predefined set of actions or otherwise replaced by custom links and handled outside Nussknacker.
* [#6860](https://github.com/TouK/nussknacker/pull/6860) Deploy http request requires valid json in request body (see `RunDeploymentRequest`) instead of plain text, e.g. `{"comment": "example text"}`.
For KafkaFlinkSource it is possible to provide optional deployment parameter, e.g. `{"comment": "example text", "nodesDeploymentData": {"my_source_node_id": {"offsetResetStrategy": "Reset"}}}`

### Code API changes
* [#7368](https://github.com/TouK/nussknacker/pull/7368) Renamed `PeriodicSourceFactory` to `SampleGeneratorSourceFactory`
Expand Down
2 changes: 1 addition & 1 deletion examples/dev/local-testing.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ services:
deploy:
resources:
limits:
memory: 4096M
memory: 1024M

telegraf:
image: telegraf:1.30.2
Expand Down

0 comments on commit 43a81b6

Please sign in to comment.