Skip to content
This repository has been archived by the owner on Feb 8, 2019. It is now read-only.

Fixes #10341: Running datasources test fails on some machine #10

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import net.liftweb.common.Empty
import net.liftweb.common.EmptyBox
import net.liftweb.common.Failure
import net.liftweb.common.Full
import monix.eval.TaskSemaphore

/*
* This file contain the hight level logic to update
Expand Down Expand Up @@ -195,8 +196,17 @@ class HttpQueryDataSourceService(
import net.liftweb.util.Helpers.tryo

def tasks(nodes: Map[NodeId, NodeInfo], policyServers: Map[NodeId, NodeInfo], parameters: Set[Parameter]): Task[List[Box[NodeId]]] = {

/*
* Here, we are executing all the task (one by node) in parallel. We want to limit the number of
* parallel task, especially to limit the number of output request. It is not very fair to
* do hundreds of simultaneous requests to the output server (and that make tests on macos
* fail, see: http://www.rudder-project.org/redmine/issues/10341)
*/
val semaphore = TaskSemaphore(maxParallelism = 50)

Task.gatherUnordered(nodes.values.map { nodeInfo =>
buildOneNodeTask(datasourceId, datasource, nodeInfo, policyServers, parameters, cause)
semaphore.greenLight(buildOneNodeTask(datasourceId, datasource, nodeInfo, policyServers, parameters, cause))
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class UpdateHttpDatasetTest extends Specification with BoxSpecMatcher with Logga

//start server on a free port
val server = BlazeBuilder.bindAny()
.withConnectorPoolSize(1) //to make the server slow and validate that it still works
.mountService(NodeDataset.service, "/datasources")
.run

Expand Down