Skip to content

Commit 2fdd696

Browse files
authored
Merge pull request #1305 from jdcasey/indy-1.8.x
Fix path-cleanup submit to drain service, not to executor service.
2 parents 6e26e2b + 91d7526 commit 2fdd696

2 files changed

Lines changed: 118 additions & 1 deletion

File tree

core/src/main/java/org/commonjava/indy/core/change/StoreContentListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ private void clearPaths( final Set<StoreKey> keys, Predicate<? super String> pat
269269

270270
logger.debug( "Submit clean job for origin: {}", origin );
271271
final Set<Group> affectedGroups = affected;
272-
cleanupExecutor.submit( clearPathsProcessor( origin, pathFilter, affectedGroups, deleteOriginPath ) );
272+
clearService.submit( clearPathsProcessor( origin, pathFilter, affectedGroups, deleteOriginPath ) );
273273
} );
274274

275275
drainAndCount( clearService, "stores: " + keys );
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/**
2+
* Copyright (C) 2011-2018 Red Hat, Inc. (https://github.com/Commonjava/indy)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.commonjava.indy.ftest.core.content;
17+
18+
import org.commonjava.indy.ftest.core.category.BytemanTest;
19+
import org.commonjava.indy.test.fixture.core.CoreServerFixture;
20+
import org.jboss.byteman.contrib.bmunit.BMRule;
21+
import org.jboss.byteman.contrib.bmunit.BMRules;
22+
import org.jboss.byteman.contrib.bmunit.BMUnitConfig;
23+
import org.jboss.byteman.contrib.bmunit.BMUnitRunner;
24+
import org.junit.Test;
25+
import org.junit.experimental.categories.Category;
26+
import org.junit.runner.RunWith;
27+
28+
import java.io.IOException;
29+
30+
import static org.hamcrest.CoreMatchers.equalTo;
31+
import static org.junit.Assert.assertThat;
32+
33+
/**
34+
* <b>GIVEN:</b>
35+
* <ul>
36+
* <li>RemoteRepositories A, B, and C, each containing metadata paths P</li>
37+
* <li>Group G with A and B members</li>
38+
* </ul>
39+
*
40+
* <br/>
41+
* <b>WHEN:</b>
42+
* <ul>
43+
* <li>Actions of Users coordinated by Byteman to expose race condition</li>
44+
* <li>User 1 START</li>
45+
* <li>User 1 GET: path P from Group G</li>
46+
* <li>RENDEZVOUS: User 1 END <i>then</i> User 2 START</li>
47+
* <li>User 2 POST: add C to Group G membership</li>
48+
* <li>RENDEZVOUS: User 2 END <i>then</i> User 3 START</li>
49+
* <li>User 3 GET: path P from Group G</li>
50+
* <li>User 3 END</li>
51+
* </ul>
52+
*
53+
* <br/>
54+
* <b>THEN:</b>
55+
* <ul>
56+
* <li>User 1 request gets AB content for P in G</li>
57+
* <li>User 2 request deletes path P maven-metadata.xml in G</li>
58+
* <li>User 3 request gets ABC content for P in G</li>
59+
* </ul>
60+
*/
61+
@RunWith( BMUnitRunner.class )
62+
@BMUnitConfig( debug = true )
63+
public class GroupMembershipAddMayDisruptMetadataRefreshTest
64+
extends GroupMembershipChangeUpdateMetadataTest
65+
{
66+
/* @formatter:off */
67+
@BMRules( rules = {
68+
@BMRule(
69+
name = "Enable slow list processing",
70+
targetClass = "TestStartTrigger",
71+
targetMethod = "run",
72+
targetLocation = "EXIT",
73+
action = "debug(\"Setting up slow-down for list processing\"); flag(\"ready\")" ),
74+
@BMRule(
75+
name = "Slow list processing when ready",
76+
targetClass = "StoreChangeUtil",
77+
targetMethod = "listPathsAnd",
78+
condition = "flagged(\"ready\")",
79+
targetLocation = "ENTRY",
80+
action = "debug(\"Slowing file listing processor...\"); Thread.sleep(2000)" ),
81+
} )
82+
/* @formatter:on */
83+
@Test
84+
@Category( BytemanTest.class )
85+
public void run()
86+
throws Exception
87+
{
88+
prepare();
89+
90+
logger.info("\n\n\n\n\n\nSTART Test Process\n\n\n\n");
91+
92+
new TestStartTrigger().run();
93+
94+
String beforeMetadata = new GroupMetaCallable( path_P ).call();
95+
96+
String retCode = new GroupAddCallable( remoteRepositoryC.getKey() ).call();
97+
98+
String afterMetadata = new GroupMetaCallable( path_P ).call();
99+
100+
assertThat( "User 1 INCORRECT", beforeMetadata, equalTo( mergedContent_AB ) );
101+
assertThat( "User 2 INCORRECT", retCode, equalTo( "OK" ) );
102+
assertThat( "User 3 INCORRECT", afterMetadata, equalTo( mergedContent_ABC ) );
103+
}
104+
105+
@Override
106+
protected void initTestConfig( final CoreServerFixture fixture )
107+
throws IOException
108+
{
109+
super.initTestConfig( fixture );
110+
writeConfigFile( "conf.d/threadpools.conf", "[threadpools]\nenabled=true" );
111+
}
112+
113+
private static final class TestStartTrigger implements Runnable
114+
{
115+
public void run(){}
116+
}
117+
}

0 commit comments

Comments
 (0)