| 7070 |
dpurdie |
1 |
package com.erggroup.buildtool.utf;
|
|
|
2 |
|
|
|
3 |
|
|
|
4 |
import java.sql.SQLException;
|
|
|
5 |
import java.util.ArrayList;
|
|
|
6 |
import java.util.Date;
|
|
|
7 |
import java.util.Iterator;
|
|
|
8 |
|
|
|
9 |
import com.erggroup.buildtool.daemon.BuildDaemon;
|
|
|
10 |
import com.erggroup.buildtool.daemon.BuildThread;
|
|
|
11 |
import com.erggroup.buildtool.daemon.MasterThread;
|
|
|
12 |
import com.erggroup.buildtool.daemon.SlaveThread;
|
|
|
13 |
import com.erggroup.buildtool.ripple.BuildFile;
|
|
|
14 |
import com.erggroup.buildtool.ripple.BuildFile.BuildFileState;
|
|
|
15 |
import com.erggroup.buildtool.ripple.BuildStandard;
|
|
|
16 |
import com.erggroup.buildtool.ripple.ReleaseConfig;
|
|
|
17 |
import com.erggroup.buildtool.ripple.ReleaseManager;
|
|
|
18 |
import com.erggroup.buildtool.ripple.Package;
|
|
|
19 |
import com.erggroup.buildtool.ripple.RippleEngine;
|
|
|
20 |
import com.erggroup.buildtool.ripple.RunLevelData;
|
|
|
21 |
import com.erggroup.buildtool.ripple.RunLevel.BuildState;
|
|
|
22 |
|
|
|
23 |
import org.slf4j.Logger;
|
|
|
24 |
import org.slf4j.LoggerFactory;
|
|
|
25 |
import org.junit.AfterClass;
|
|
|
26 |
import org.junit.BeforeClass;
|
|
|
27 |
import org.junit.After;
|
|
|
28 |
import org.junit.Before;
|
|
|
29 |
import org.junit.Test;
|
|
|
30 |
import org.junit.runner.JUnitCore;
|
|
|
31 |
|
|
|
32 |
import static org.junit.Assert.*;
|
|
|
33 |
|
|
|
34 |
/**
|
|
|
35 |
* container of Build Daemon test methods
|
|
|
36 |
*/
|
|
|
37 |
public class DaemonBuildTestCase2
|
|
|
38 |
{
|
|
|
39 |
private static final Logger mLogger = LoggerFactory.getLogger(DaemonBuildTestCase2.class);
|
|
|
40 |
myReleaseManager releaseManager = null;
|
|
|
41 |
RippleEngine rippleEngine = null;
|
|
|
42 |
ArrayList<Package> testPackageCollection = new ArrayList<Package>();
|
|
|
43 |
|
|
|
44 |
/**
|
|
|
45 |
* Init the package set
|
|
|
46 |
*/
|
|
|
47 |
public void initTestPackages(String setName)
|
|
|
48 |
{
|
|
|
49 |
releaseManager.initTestPackages(rippleEngine, testPackageCollection, setName);
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
/** Create a WIP for a package in the Release
|
|
|
53 |
* This will mark it as directlyPlanned
|
|
|
54 |
* @param newPvId
|
|
|
55 |
* @param alias
|
|
|
56 |
*/
|
|
|
57 |
private Package createWip(int newPvId, String alias) {
|
|
|
58 |
|
|
|
59 |
Package wip = ReleaseManager.NULL_PACKAGE;
|
|
|
60 |
|
|
|
61 |
for (Iterator<Package> it = testPackageCollection.iterator(); it.hasNext(); )
|
|
|
62 |
{
|
|
|
63 |
Package p = it.next();
|
|
|
64 |
|
|
|
65 |
if ( p.mAlias.compareTo( alias ) == 0 )
|
|
|
66 |
{
|
|
|
67 |
wip = new Package(newPvId, p);
|
|
|
68 |
wip.mDirectlyPlanned = true;
|
|
|
69 |
testPackageCollection.add(wip);
|
|
|
70 |
break;
|
|
|
71 |
}
|
|
|
72 |
}
|
|
|
73 |
return wip;
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
/** Create a basic package
|
|
|
77 |
*
|
|
|
78 |
*/
|
|
|
79 |
private Package createPackage(int idx, String pName) {
|
|
|
80 |
Package p = new Package(idx, idx * 100, pName, "1.0.0000", ".cr", pName + ".cr" , "CC::/vob/"+pName+".WIP", 'b', 'P');
|
|
|
81 |
BuildStandard bs = new BuildStandard(rippleEngine, "Linux", "Java 1.6");
|
|
|
82 |
p.mBuildStandardCollection.add(bs);
|
|
|
83 |
return p;
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
/** Subclass and override key methods so that the test can control
|
|
|
89 |
* the data being used
|
|
|
90 |
*/
|
|
|
91 |
public class myReleaseManager extends ReleaseManagerUtf
|
|
|
92 |
{
|
|
|
93 |
public myReleaseManager(final String connectionString, final String username, final String password)
|
|
|
94 |
{
|
|
|
95 |
super(connectionString, username, password);
|
|
|
96 |
mLogger.error("Test {}", connectionString);
|
|
|
97 |
}
|
|
|
98 |
|
|
|
99 |
public myReleaseManager()
|
|
|
100 |
{
|
|
|
101 |
super();
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
@Override
|
|
|
105 |
public void queryPackageVersions(RippleEngine rippleEngine, ArrayList<Package> packageCollection, int baseline) throws SQLException, Exception
|
|
|
106 |
{
|
|
|
107 |
|
|
|
108 |
// Filter for the packages that are in the release
|
|
|
109 |
for (Iterator<Package> it = testPackageCollection.iterator(); it.hasNext(); )
|
|
|
110 |
{
|
|
|
111 |
Package p = it.next();
|
|
|
112 |
if (!p.mDirectlyPlanned && p.mTestBuildInstruction == 0 && p.mForcedRippleInstruction == 0)
|
|
|
113 |
{
|
|
|
114 |
p.mIsNotReleased = false;
|
|
|
115 |
p.mBuildTime = 90;
|
|
|
116 |
packageCollection.add(p);
|
|
|
117 |
}
|
|
|
118 |
}
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
@Override
|
|
|
122 |
public void queryWips(RippleEngine rippleEngine, ArrayList<Package> packageCollection, int baseline) throws SQLException, Exception
|
|
|
123 |
{
|
|
|
124 |
// Filter for the packages that are WIPs
|
|
|
125 |
for (Iterator<Package> it = testPackageCollection.iterator(); it.hasNext(); )
|
|
|
126 |
{
|
|
|
127 |
Package p = it.next();
|
|
|
128 |
if (p.mDirectlyPlanned )
|
|
|
129 |
{
|
|
|
130 |
p.mIsNotReleased = true;
|
|
|
131 |
p.mDirectlyPlanned = true;
|
|
|
132 |
p.mBuildReason = BuildReason.NewVersion;
|
|
|
133 |
p.mBuildTime = 100;
|
|
|
134 |
packageCollection.add(p);
|
|
|
135 |
}
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
@Override
|
|
|
141 |
public void queryTest(RippleEngine rippleEngine, ArrayList<Package> packageCollection, int baseline) throws SQLException, Exception
|
|
|
142 |
{
|
|
|
143 |
// Filter for the packages that are TEST builds
|
|
|
144 |
for (Iterator<Package> it = testPackageCollection.iterator(); it.hasNext(); )
|
|
|
145 |
{
|
|
|
146 |
Package p = it.next();
|
|
|
147 |
if (p.mTestBuildInstruction != 0 )
|
|
|
148 |
{
|
|
|
149 |
p.mIsNotReleased = true;
|
|
|
150 |
p.mDirectlyPlanned = false;
|
|
|
151 |
p.mBuildReason = BuildReason.Test;
|
|
|
152 |
packageCollection.add(p);
|
|
|
153 |
}
|
|
|
154 |
}
|
|
|
155 |
}
|
|
|
156 |
|
|
|
157 |
@Override
|
|
|
158 |
public void queryRipples(RippleEngine rippleEngine, ArrayList<Package> packageCollection, int baseline) throws SQLException, Exception
|
|
|
159 |
{
|
|
|
160 |
// Filter for the packages that are forced Ripples
|
|
|
161 |
for (Iterator<Package> it = testPackageCollection.iterator(); it.hasNext(); )
|
|
|
162 |
{
|
|
|
163 |
Package p = it.next();
|
|
|
164 |
if (p.mForcedRippleInstruction != 0)
|
|
|
165 |
{
|
|
|
166 |
p.mIsNotReleased = true;
|
|
|
167 |
p.mDirectlyPlanned = false;
|
|
|
168 |
p.mBuildReason = BuildReason.Ripple;
|
|
|
169 |
p.mBuildTime = 3;
|
|
|
170 |
packageCollection.add(p);
|
|
|
171 |
}
|
|
|
172 |
}
|
|
|
173 |
}
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
/** Build a single package collection
|
|
|
177 |
* It will be split up when requested by the classes under test
|
|
|
178 |
*
|
|
|
179 |
* @param packageCollection
|
|
|
180 |
*/
|
|
|
181 |
private void initTestPackages(RippleEngine rippleEngine, ArrayList<Package> packageCollection, String setName)
|
|
|
182 |
{
|
|
|
183 |
packageCollection.clear();
|
|
|
184 |
|
|
|
185 |
/* A basic set of packages
|
|
|
186 |
* All buildable
|
|
|
187 |
*/
|
|
|
188 |
Package p1 = createPackage(1, "p1");
|
|
|
189 |
Package p2 = createPackage(2, "p2");
|
|
|
190 |
Package p3 = createPackage(3, "p3");
|
|
|
191 |
Package p4 = createPackage(4, "p4");
|
|
|
192 |
Package p5 = createPackage(5, "p5");
|
|
|
193 |
Package p6 = createPackage(6, "p6");
|
|
|
194 |
Package p7 = createPackage(7, "p7");
|
|
|
195 |
|
|
|
196 |
packageCollection.add(p1);
|
|
|
197 |
packageCollection.add(p2);
|
|
|
198 |
packageCollection.add(p3);
|
|
|
199 |
packageCollection.add(p4);
|
|
|
200 |
packageCollection.add(p5);
|
|
|
201 |
packageCollection.add(p6);
|
|
|
202 |
packageCollection.add(p7);
|
|
|
203 |
|
|
|
204 |
|
|
|
205 |
p2.addDependency(p1);
|
|
|
206 |
p3.addDependency(p1);
|
|
|
207 |
p4.addDependency(p2).addDependency(p3);
|
|
|
208 |
p5.addDependency(p2).addDependency(p4);
|
|
|
209 |
p6.addDependency(p3).addDependency(p4);
|
|
|
210 |
p7.addDependency(p5).addDependency(p6);
|
|
|
211 |
|
|
|
212 |
}
|
|
|
213 |
|
|
|
214 |
}
|
|
|
215 |
|
|
|
216 |
|
|
|
217 |
public DaemonBuildTestCase2()
|
|
|
218 |
{
|
|
|
219 |
mLogger.debug("DaemonBuildTestCase2");
|
|
|
220 |
}
|
|
|
221 |
|
|
|
222 |
/**
|
|
|
223 |
* Test Case main line
|
|
|
224 |
*/
|
|
|
225 |
public static void main(String[] args)
|
|
|
226 |
{
|
|
|
227 |
mLogger.debug("main");
|
|
|
228 |
JUnitCore.main("com.erggroup.buildtool.utf.DaemonBuildTestCase2");
|
|
|
229 |
}
|
|
|
230 |
|
|
|
231 |
/**
|
|
|
232 |
* set up performed prior to any test method
|
|
|
233 |
*/
|
|
|
234 |
@BeforeClass
|
|
|
235 |
public static void TestCaseSetUp()
|
|
|
236 |
{
|
|
|
237 |
mLogger.debug("TestCaseSetUp");
|
|
|
238 |
}
|
|
|
239 |
|
|
|
240 |
/**
|
|
|
241 |
* tear down performed after test methods
|
|
|
242 |
*/
|
|
|
243 |
@AfterClass
|
|
|
244 |
public static void TestCaseTearDown()
|
|
|
245 |
{
|
|
|
246 |
mLogger.debug("TestCaseTearDown");
|
|
|
247 |
}
|
|
|
248 |
|
|
|
249 |
/**
|
|
|
250 |
* set up performed prior to each test method
|
|
|
251 |
*/
|
|
|
252 |
@Before
|
|
|
253 |
public void TestSetUp()
|
|
|
254 |
{
|
|
|
255 |
mLogger.debug("TestSetUp");
|
|
|
256 |
System.setProperty("vix.utf.name", "DaemonBuildTestCase2");
|
|
|
257 |
Package.mGenericMachtype = "win32";
|
|
|
258 |
Package.mGbeDpkg = ".";
|
|
|
259 |
}
|
|
|
260 |
|
|
|
261 |
/**
|
|
|
262 |
* tear down performed after each test method
|
|
|
263 |
*/
|
|
|
264 |
@After
|
|
|
265 |
public void TestTearDown()
|
|
|
266 |
{
|
|
|
267 |
mLogger.debug("TestTearDown");
|
|
|
268 |
}
|
|
|
269 |
|
|
|
270 |
/**
|
|
|
271 |
* I'm guessing as to the function of this test
|
|
|
272 |
* Test for:
|
|
|
273 |
* Circular dependencies
|
|
|
274 |
* Build Dependency not in the release
|
|
|
275 |
* Package has no build environment
|
|
|
276 |
* Package not built for configured platforms
|
|
|
277 |
* A package is selected to be built
|
|
|
278 |
*
|
|
|
279 |
*/
|
|
|
280 |
@Test
|
|
|
281 |
public void TestPlanRelease_1()
|
|
|
282 |
{
|
|
|
283 |
mLogger.debug("TestPlanRelease - Iteration 1");
|
|
|
284 |
System.out.println("TestPlanRelease - Iteration 1");
|
|
|
285 |
releaseManager = new myReleaseManager("iteration1", "not used", "not used");
|
|
|
286 |
rippleEngine = new RippleEngine(releaseManager, 11111, true);
|
|
|
287 |
|
|
|
288 |
try
|
|
|
289 |
{
|
|
|
290 |
rippleEngine.collectMetaData();
|
|
|
291 |
|
|
|
292 |
// Generate basic test set and then tweak for this test
|
|
|
293 |
initTestPackages(releaseManager.mConnectionString);
|
|
|
294 |
|
|
|
295 |
createWip(2000, "p1.cr");
|
|
|
296 |
rippleEngine.planRelease(false);
|
|
|
297 |
}
|
|
|
298 |
catch (Exception e)
|
|
|
299 |
{
|
|
|
300 |
}
|
|
|
301 |
|
|
|
302 |
boolean rv;
|
|
|
303 |
BuildFile buildFile;
|
|
|
304 |
|
|
|
305 |
buildFile = rippleEngine.getFirstBuildFileContent();
|
|
|
306 |
assertTrue(buildFile != null);
|
|
|
307 |
assertTrue(buildFile.state != BuildFileState.Dummy);
|
|
|
308 |
assertTrue(buildFile.state != BuildFileState.Empty);
|
|
|
309 |
|
|
|
310 |
rv = Utilities.checkBuildfile(buildFile.content, "ripple1");
|
|
|
311 |
assertTrue(rv);
|
|
|
312 |
|
|
|
313 |
buildFile = rippleEngine.getNextBuildFileContent();
|
|
|
314 |
assertTrue(buildFile != null);
|
|
|
315 |
assertTrue(buildFile.state == BuildFileState.Empty);
|
|
|
316 |
}
|
|
|
317 |
|
|
|
318 |
|
|
|
319 |
|
|
|
320 |
}
|