Skip to content

Commit

Permalink
One more hit
Browse files Browse the repository at this point in the history
  • Loading branch information
mPokornyETM committed Nov 29, 2023
1 parent e4087cd commit 649a5f8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ public List<LockableResource> getResourcesWithLabel(String label, Map<String, Ob
@NonNull
@Restricted(NoExternalUse.class)
public List<LockableResource> getResourcesWithLabel(final String label) {
return _getResourcesWithLabel(label, this.getResources());
synchronized (this.syncResources) {
return _getResourcesWithLabel(label, this.getResources());
}
}

// ---------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void parallelTasksTest() throws Exception {
// Do not mirror nodes now. We will allow it later in parallel tasks
System.setProperty(Constants.SYSTEM_PROPERTY_ENABLE_NODE_MIRROR, "false");
LOGGER.info("add agents");
for (int i = 1; i <= agentsCount; i++) j.createSlave("Agent_" + i, "label label2", null);
for (int i = 1; i <= agentsCount; i++) j.createSlave("Agent_" + i, "label label2 agent", null);
LOGGER.info("add agents done");

LockableResourcesManager LRM = LockableResourcesManager.get();
Expand Down Expand Up @@ -69,7 +69,7 @@ public void run() {
LOGGER.info("create extra slaves");
for (int i = 1; i <= extraAgentsCount; i++) {
try {
j.createSlave("ExtraAgent_" + i, "label label2", null);
j.createSlave("ExtraAgent_" + i, "label label2 extra-agent", null);
Thread.sleep(5);
j.jenkins.removeNode(j.jenkins.getNode("ExtraAgent_" + i));
Thread.sleep(5);
Expand Down Expand Up @@ -114,12 +114,14 @@ public void run() {
LOGGER.info("wait for resources");
for (int i = 1; i <= 100; i++) {
Thread.sleep(500);
LOGGER.info("wait for resources " + i + " " + LRM.resourceExist("ExtraResource_" + extraResourcesCount)
+ " " + LRM.resourceExist("ExtraAgent_" + extraAgentsCount) + " "
+ LRM.resourceExist("Agent_" + agentsCount));
LOGGER.info("wait for resources " + i + " "
+ LRM.resourceExist("ExtraResource_" + extraResourcesCount)
+ " agent-extra: "
+ LRM.getResourcesWithLabel("agent-extra").size() + " != " + extraAgentsCount
+ " agent: " + LRM.getResourcesWithLabel("agent").size());
if (LRM.resourceExist("ExtraResource_" + extraResourcesCount)
&& !LRM.resourceExist("ExtraAgent_" + extraAgentsCount)
&& LRM.resourceExist("Agent_" + agentsCount)) break;
&& LRM.getResourcesWithLabel("agent-extra").size() == 0
&& LRM.getResourcesWithLabel("agent").size() == agentsCount) break;
}

// normally is is bad idea to make so much assertions, but we need verify if all works fine
Expand Down

0 comments on commit 649a5f8

Please sign in to comment.