Opened 6 years ago

Closed 15 months ago

#1215 closed defect (fixed)

Unit tests may run a router (and reseed it)

Reported by: dg Owned by: slumlord
Priority: minor Milestone: 0.9.36
Component: router/general Version: 0.9.11
Keywords: privacy Cc:
Parent Tickets: Sensitive: no

Description

Some of our unit tests may start up a full router from scratch and, in turn, reseed from the open internet. This could cause anonymity issues for some developers or service providers (those perhaps willing to run any CI/Jenkins eepsite that covers all of the codebase tests).

The problematic tests should be disabled by default (when running all tests, require them to be explicitly turned on) or 'reseed' from a local router instead.

Subtickets

Change History (9)

comment:1 Changed 6 years ago by zzz

Component: unspecifiedrouter/general

agreed

comment:2 Changed 5 years ago by str4d

Keywords: privacy added
Milestone: 0.9.12

comment:3 Changed 4 years ago by str4d

Status: newopen

comment:4 Changed 2 years ago by slumlord

Bumping this, I am running BobTheBuilder?.i2p and am currently wrapping ant test with torify to get around this issue. Running ant test on a system with no clearnet access causes ant test to take upwards of 45 minutes.

comment:5 Changed 2 years ago by zzz

Owner: set to str4d
Status: openassigned

There's a couple of choices here.

1) change all router unit tests to prevent any net access (basically, disable reseed, disable NTP, enable vmcommsystem)

2) create an ant target that runs all unit tests except those that require net access

Not sure which is easier. I'd prefer 1) if possible, although 2) might be a short-term fix. Assigning to str4d to research/comment/address, he's the unit test maintainer right now, more or less

I believe the delay w/o any access is caused by the wait-for-NTP time in the router startup.

Might be nice, for starters, to identify each test that starts a router now, and which of those actually require net access, and if the test it does is useful. slumlord could perhaps help with that, as he must have test logs from bobthebuilder.

comment:6 Changed 17 months ago by slumlord

Going to see if tests that require internet access can be identified and split into their own ant target. This would allow the tests to be run on a system specifically set up for these internet-related tests.

Looking through build.xml:

$ grep -in '<target name="test"' build.xml
1878:    <target name="test" depends="testCore, testRouter, testMinistreaming, testStreaming" />

build.xml:

    <target name="testCore" depends="buildProperties, jbigi" >                                                                                                                 
        <ant dir="core/java/" target="test" />                                                                                                                                 
    </target>                                                                                                                                                                  
    <target name="testRouter" depends="buildProperties, jbigi" >                                                                                                               
        <ant dir="router/java/" target="test" />                                                                                                                               
    </target>                                                                                                                                                                  
    <target name="testMinistreaming" depends="buildProperties, jbigi" >                                                                                                        
        <ant dir="apps/ministreaming/java/" target="test" />                                                                                                                   
    </target>                                                                                                                                                                  
    <target name="testStreaming" depends="buildProperties" >                                                                                                                   
        <ant dir="apps/streaming/java/" target="test" />                                                                                                                       
    </target>

/i2p.i2p/core/java/test/junit/net/i2p/AllCoreTests.java defines tests:

@RunWith(Suite.class)
@Suite.SuiteClasses({
    net.i2p.client.I2PClientTestSuite.class,
    net.i2p.crypto.CryptoTestSuite.class,
    net.i2p.data.DataTestSuite.class,
    net.i2p.stat.StatTestSuite.class,
    net.i2p.util.UtilTestSuite.class,
})
public class AllCoreTests {
}

/i2p.i2p/router/java/test:

$ find . -iname '*Test.java'
./junit/net/i2p/router/tunnel/BatchedFragmentTest.java
./junit/net/i2p/router/tunnel/OutboundTest.java
./junit/net/i2p/router/tunnel/FragmentTest.java
./junit/net/i2p/router/transport/crypto/DHSessionKeyBuilderTest.java
./junit/net/i2p/router/util/CachedIteratorArrayListTest.java
./junit/net/i2p/router/crypto/SessionEncryptionTest.java
./junit/net/i2p/data/router/RouterIdentityTest.java
./junit/net/i2p/data/router/RouterAddressTest.java
./junit/net/i2p/data/router/RouterInfoTest.java
./junit/net/i2p/data/i2np/DeliveryInstructionsTest.java
./junit/net/i2p/data/i2np/DatabaseStoreMessageTest.java

/i2p.i2p/apps/ministreaming/java/test:

$ find . -iname '*Test.java'
./junit/net/i2p/client/streaming/I2PSocketAddressTest.java
./junit/net/i2p/client/streaming/I2PSocketManagerFactoryTest.java
./junit/net/i2p/client/streaming/I2PSocketExceptionTest.java
./junit/net/i2p/client/streaming/I2PSocketEepGetTest.java

/i2p.i2p/apps/streaming/java/test/junit:

$ find . -iname '*Test.java'
./net/i2p/client/streaming/impl/MessageInputStreamTest.java
./net/i2p/client/streaming/impl/MessageOutputStreamTest.java
./net/i2p/client/streaming/impl/ConnectionTest.java
./net/i2p/client/streaming/impl/SchedulerDeadTest.java

Notes:

  • Read and understand tests
  • Identify tests that require internet access

comment:7 Changed 17 months ago by zzz

Milestone: 0.9.36
Owner: changed from str4d to slumlord

Should only be some of the ones in router/java/test.
Note that there are also scala unit tests, but there aren't any for the router.
Alternate plan after identifying tests - disable them, or rewrite so they don't need a running router. Based on the names, they shouldn't need a full router.

comment:8 Changed 16 months ago by slumlord

Found and fixed a configuration problem on the build system which was causing builds to take a lot longer when torsocks wasn't used with ant test. System was using an IP in the 127.0.0.0/8 subnet (not 127.0.0.1) and the tests were hanging when trying to determine the loopback IP address.

zzz, anything further to be done here?

comment:9 Changed 15 months ago by slumlord

Resolution: fixed
Status: assignedclosed

Have not heard anything from zzz. As far as I can tell tests run just fine without network access, either directly or through tor.

Closing as fixed.

Note: See TracTickets for help on using tickets.