Skip to content
Snippets Groups Projects
Commit 0e5146e5 authored by iwakeh's avatar iwakeh :palm_tree:
Browse files

Make OnionPerf adhere to the standard CollecTorMain.

This includes adding property 'OnionPerfSources' and renaming
some markers properly.  In addition, all camel-case occurrences
of 'OnionPerf' have a capitalized 'P' now.

Part of task-21759.
parent b284a90a
Branches
Tags
No related merge requests found
Showing with 31 additions and 23 deletions
......@@ -12,7 +12,7 @@ import org.torproject.collector.cron.Scheduler;
import org.torproject.collector.cron.ShutdownHook;
import org.torproject.collector.exitlists.ExitListDownloader;
import org.torproject.collector.index.CreateIndexJson;
import org.torproject.collector.onionperf.OnionperfDownloader;
import org.torproject.collector.onionperf.OnionPerfDownloader;
import org.torproject.collector.relaydescs.ArchiveWriter;
import org.slf4j.Logger;
......@@ -50,7 +50,7 @@ public class Main {
collecTorMains.put(Key.ExitlistsActivated, ExitListDownloader.class);
collecTorMains.put(Key.UpdateindexActivated, CreateIndexJson.class);
collecTorMains.put(Key.RelaydescsActivated, ArchiveWriter.class);
collecTorMains.put(Key.OnionperfActivated, OnionperfDownloader.class);
collecTorMains.put(Key.OnionPerfActivated, OnionPerfDownloader.class);
}
private static Configuration conf = new Configuration();
......
......@@ -16,7 +16,7 @@ public enum Annotation {
Microdescriptor("@type microdescriptor 1.0\n"),
Server("@type server-descriptor 1.0\n"),
Status("@type bridge-network-status 1.2\n"),
Onionperf("@type torperf 1.0\n"),
OnionPerf("@type torperf 1.0\n"),
Vote("@type network-status-vote-3 1.0\n");
private final String annotation;
......
......@@ -92,7 +92,7 @@ public class Configuration extends Observable implements Cloneable {
|| this.getBool(Key.BridgedescsActivated)
|| this.getBool(Key.ExitlistsActivated)
|| this.getBool(Key.UpdateindexActivated)
|| this.getBool(Key.OnionperfActivated))) {
|| this.getBool(Key.OnionPerfActivated))) {
throw new ConfigurationException("Nothing is activated!\n"
+ "Please edit collector.properties. Exiting.");
}
......
......@@ -27,6 +27,7 @@ public enum Key {
RelaySources(SourceType[].class),
BridgeSources(SourceType[].class),
ExitlistSources(SourceType[].class),
OnionPerfSources(SourceType[].class),
RelayCacheOrigins(String[].class),
RelayLocalOrigins(Path.class),
RelaySyncOrigins(URL[].class),
......@@ -42,9 +43,9 @@ public enum Key {
RelaydescsActivated(Boolean.class),
RelaydescsOffsetMinutes(Integer.class),
RelaydescsPeriodMinutes(Integer.class),
OnionperfActivated(Boolean.class),
OnionperfOffsetMinutes(Integer.class),
OnionperfPeriodMinutes(Integer.class),
OnionPerfActivated(Boolean.class),
OnionPerfOffsetMinutes(Integer.class),
OnionPerfPeriodMinutes(Integer.class),
UpdateindexActivated(Boolean.class),
UpdateindexOffsetMinutes(Integer.class),
UpdateindexPeriodMinutes(Integer.class),
......
......@@ -41,14 +41,15 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** Download download .tpf files from OnionPerf hosts. */
public class OnionperfDownloader extends CollecTorMain {
public class OnionPerfDownloader extends CollecTorMain {
private static final Logger logger = LoggerFactory.getLogger(
OnionperfDownloader.class);
OnionPerfDownloader.class);
private static final String TORPERF = "torperf";
public OnionperfDownloader(Configuration config) {
/** Instanciate the OnionPerf module using the given configuration. */
public OnionPerfDownloader(Configuration config) {
super(config);
}
......@@ -72,12 +73,12 @@ public class OnionperfDownloader extends CollecTorMain {
@Override
public String module() {
return TORPERF;
return "onionperf";
}
@Override
protected String syncMarker() {
return "TorperfFiles";
return "OnionPerf";
}
@Override
......
......@@ -30,11 +30,11 @@ RelaydescsPeriodMinutes = 30
# offset in minutes since the epoch and
RelaydescsOffsetMinutes = 5
## the following defines, if this module is activated
OnionperfActivated = false
OnionPerfActivated = false
# period in minutes
OnionperfPeriodMinutes = 360
OnionPerfPeriodMinutes = 360
# offset in minutes since the epoch and
OnionperfOffsetMinutes = 1
OnionPerfOffsetMinutes = 1
# the following defines, if this module is activated
UpdateindexActivated = false
# period in minutes
......@@ -139,7 +139,11 @@ ExitlistSyncOrigins = https://collector.torproject.org
## Where to download exit-lists from.
ExitlistUrl = https://check.torproject.org/exit-addresses
#
######## Onionperf downloader ########
######## OnionPerf downloader ########
#
## Define descriptor sources
# possible values: Remote
OnionPerfSources = Remote
#
## OnionPerf base URLs
## Hosts must be configured to use the first subdomain part of the given URL as
......@@ -147,3 +151,4 @@ ExitlistUrl = https://check.torproject.org/exit-addresses
## the second, etc.:
## OnionPerfHosts = http://first.torproject.org/, http://second.torproject.org/
OnionPerfHosts = https://op-us.onionperf.torproject.net/
......@@ -100,7 +100,7 @@ public class MainTest {
Main.main(new String[]{conf.toString()});
assertTrue(4_000L <= conf.length());
changeFilePathsAndSetActivation(conf,
Key.OnionperfActivated.name());
Key.OnionPerfActivated.name());
Main.main(new String[]{conf.toString()});
waitSec(2);
}
......
......@@ -40,7 +40,7 @@ public class ConfigurationTest {
public void testKeyCount() throws Exception {
assertEquals("The number of properties keys in enum Key changed."
+ "\n This test class should be adapted.",
43, Key.values().length);
44, Key.values().length);
}
@Test()
......
......@@ -70,6 +70,7 @@ public class CollecTorMainTest {
case "Relay":
case "Bridge":
case "Exitlist":
case "OnionPerf":
assertNotNull("Property '" + key
+ "' not specified in " + Main.CONF_FILE + ".",
props.getProperty(key));
......
......@@ -22,8 +22,8 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
public class SchedulerTest {
private static final String runConfigProperties =
"OnionperfActivated=true\nOnionperfPeriodMinutes=1\n"
+ "OnionperfOffsetMinutes=0\n"
"OnionPerfActivated=true\nOnionPerfPeriodMinutes=1\n"
+ "OnionPerfOffsetMinutes=0\n"
+ "RelaydescsActivated=true\nRelaydescsPeriodMinutes=1\n"
+ "RelaydescsOffsetMinutes=0\n"
+ "ExitlistsActivated=true\nExitlistsPeriodMinutes=1\n"
......@@ -38,7 +38,7 @@ public class SchedulerTest {
Map<Key, Class<? extends CollecTorMain>> ctms = new HashMap<>();
Configuration conf = new Configuration();
conf.load(new ByteArrayInputStream(runConfigProperties.getBytes()));
ctms.put(Key.OnionperfActivated, Dummy.class);
ctms.put(Key.OnionPerfActivated, Dummy.class);
ctms.put(Key.BridgedescsActivated, Dummy.class);
ctms.put(Key.RelaydescsActivated, Dummy.class);
ctms.put(Key.ExitlistsActivated, Dummy.class);
......@@ -70,7 +70,7 @@ public class SchedulerTest {
conf.load(new ByteArrayInputStream(("ShutdownGraceWaitMinutes=1\n"
+ runConfigProperties).getBytes()));
conf.setProperty(Key.RunOnce.name(), "true");
ctms.put(Key.OnionperfActivated, Counter.class);
ctms.put(Key.OnionPerfActivated, Counter.class);
ctms.put(Key.BridgedescsActivated, Counter.class);
ctms.put(Key.RelaydescsActivated, Counter.class);
ctms.put(Key.ExitlistsActivated, Counter.class);
......@@ -93,7 +93,7 @@ public class SchedulerTest {
Map<Key, Class<? extends CollecTorMain>> ctms = new HashMap<>();
Configuration conf = new Configuration();
conf.load(new ByteArrayInputStream(runConfigProperties.getBytes()));
ctms.put(Key.OnionperfActivated, Broken.class);
ctms.put(Key.OnionPerfActivated, Broken.class);
ctms.put(Key.BridgedescsActivated, Broken.class);
ctms.put(Key.RelaydescsActivated, Broken.class);
ctms.put(Key.ExitlistsActivated, Broken.class);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment