-
Notifications
You must be signed in to change notification settings - Fork 23
/
DatabaseFullMigrationTest.java
136 lines (121 loc) · 6.01 KB
/
DatabaseFullMigrationTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* #%L
* NetarchiveSuite System test
* %%
* Copyright (C) 2005 - 2018 The Royal Danish Library,
* the National Library of France and the Austrian National Library.
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/
package dk.netarkivet.systemtest.performance;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import dk.netarkivet.systemtest.SeleniumTest;
import dk.netarkivet.systemtest.TestLogger;
import dk.netarkivet.systemtest.environment.testGUIController;
import dk.netarkivet.systemtest.page.PageHelper;
/**
* Tests to be run against the full production-load database.
*/
@SuppressWarnings("unused")
public class DatabaseFullMigrationTest extends AbstractStressTest {
protected final TestLogger log = new TestLogger(getClass());
@Test ( enabled = false )
public void testUpdateFileStatus() {
addDescription("Test updating the file status for all files in one bitarchive replica. This procedure takes around one hour to run for " +
"a full production load. Because there are no actual files present in the test system, the test will eventually show that all files are " +
"missing in this replica.");
doUpdateFileStatus();
}
@Test ( enabled = false )
public void testUpdateChecksumStatus() {
addDescription("Test updating checksum status for all files in one checksum-replica. This takes about four hours to run in a full production load.");
doUpdateChecksumAndFileStatus();
}
@Test
public void testIngestDomains() {
addDescription("Test ingesting domains from a textual list of about 2 million domains. This is not a particularly heavy" +
" operation but tests some browser functionality which is not easily testable elsewhere - specifically that the 'keep-alive' " +
"functionality allows the browser to follow the complete upload/ingest of all the domains without timing out.");
doIngestDomains();
}
@Test ( enabled = true )
public void testGenerateSnapshot() {
addDescription("Test generating snapshot jobs with a maximum number of bytes per domain of 100 000. This takes about ten hours to complete. The" +
" number of jobs generated is determined roughly by the parameter settings.harvester.scheduler.jobGen.domainConfigSubsetSize which is" +
" set to 10000 by default. Ie there is a maximum of 10000 domains per job, although there are also a small number of jobs with much fewer domains" +
" where these have specialised configurations.");
doGenerateSnapshot();
}
@BeforeClass
public void setupTestEnvironment() throws Exception {
shutdownPreviousTest();
fetchProductionData();
deployComponents();
replaceDatabasesWithProd(false);
upgradeHarvestDatabase();
startTestSystem();
initialiseDriver();
}
private void initialiseDriver() {
testGUIController testGUIController = new testGUIController(testController);
SeleniumTest.testGUIController = testGUIController;
initialiseSelenium();
driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
String baseUrl = "http://" + testController.ENV.getGuiHost() + ":" + testController.ENV.getGuiPort();
PageHelper.initialize(driver, baseUrl);
testGUIController.waitForGUIToStart(60);
}
private void doGenerateSnapshot() {
//WebDriver driver = new FirefoxDriver();
String snapshotTimeDividerString = System.getProperty("stresstest.snapshottimedivider", "1");
Integer snapshotTimeDivider = Integer.parseInt(snapshotTimeDividerString);
if (snapshotTimeDivider != 1) {
log.info("Dividing timescale for snapshot test by a factor {} (stresstest.snapshottimedivider).", snapshotTimeDivider);
}
testGUIController testGUIController = new testGUIController(testController);
LongRunningJob snapshotJob = new GenerateSnapshotJob(this, testController, this.driver,
2*HOUR/snapshotTimeDivider, 30*MINUTE/snapshotTimeDivider, 20*HOUR/snapshotTimeDivider, "SnapshotGenerationJob"
);
snapshotJob.run();
}
private void doIngestDomains() {
//WebDriver driver = new FirefoxDriver();
IngestDomainJob ingestDomainJob = new IngestDomainJob(this, this.driver, 60*HOUR);
ingestDomainJob.run();
}
private void doUpdateFileStatus() {
UpdateFileStatusJob updateFileStatusJob = new UpdateFileStatusJob(this, this.driver, 0L, 5*MINUTE, 5*HOUR, "Update FileStatus Job");
updateFileStatusJob.run();
}
private void doUpdateChecksumAndFileStatus() {
Long stepTimeout = DAY;
String minStepTimeHoursString = System.getProperty("stresstest.minchecksumtime", "1");
log.debug("Checksum checking must take at least {} (stresstest.minchecksumtime) hours to complete.", minStepTimeHoursString);
Long minStepTime = Integer.parseInt(minStepTimeHoursString)*HOUR;
UpdateChecksumJob updateChecksumJob = new UpdateChecksumJob(
this,
new FirefoxDriver(),
MINUTE,
5*MINUTE,
stepTimeout,
"Update Checksum Job"
);
updateChecksumJob.run();
}
}