Skip to content

Commit

Permalink
Remove duplicate testing simple_server.py
Browse files Browse the repository at this point in the history
tests/simple_server.py was copied to tuf/scripts/ to "make testing
easier" (cf84d3f), although with
the current test setup the original (and recently patched to fix an
Windows/Py2 test issue) test simple_server.py can be used just as
well.

This commit:
- removes tuf/scripts/simple_server.py
  Note: that version slightly differed from the original test
  server, probably due to demands by the linter that is only executed
  on the tuf core code and not on the tests. However, for the testing
  purposes of simple_server.py these changes (i.e., `SystemRandom()`,
  `if __name__ =='__main__':`) are not necessary.
- updates the tests that used tuf.scripts.simple_server to instead
  use tests.simple_server,
- updates setup.py to not install the simple_server module as
  script, when installing tuf, as it is only a testing script and
  not meant for end-user usage.

Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
  • Loading branch information
lukpueh committed Feb 25, 2020
1 parent 7dbb30a commit 52071b1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@
packages = find_packages(exclude=['tests']),
scripts = [
'tuf/scripts/repo.py',
'tuf/scripts/client.py',
'tuf/scripts/simple_server.py',
'tuf/scripts/client.py'
]
)
4 changes: 2 additions & 2 deletions tests/test_multiple_repositories_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ def setUp(self):
while self.SERVER_PORT == self.SERVER_PORT2:
self.SERVER_PORT2 = random.SystemRandom().randint(30000, 45000)

command = ['python', '-m', 'tuf.scripts.simple_server', str(self.SERVER_PORT)]
command2 = ['python', '-m', 'tuf.scripts.simple_server', str(self.SERVER_PORT2)]
command = ['python', '-m', 'tests.simple_server', str(self.SERVER_PORT)]
command2 = ['python', '-m', 'tests.simple_server', str(self.SERVER_PORT2)]

self.server_process = subprocess.Popen(command, stderr=subprocess.PIPE,
cwd=self.repository_directory)
Expand Down
12 changes: 6 additions & 6 deletions tests/test_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def setUpClass(cls):
# as a delegated role 'targets/role1', three target files, five key files,
# etc.
cls.SERVER_PORT = random.randint(30000, 45000)
command = ['python', '-m', 'tuf.scripts.simple_server', str(cls.SERVER_PORT)]
command = ['python', '-m', 'tests.simple_server', str(cls.SERVER_PORT)]
cls.server_process = subprocess.Popen(command, stderr=subprocess.PIPE)
logger.info('\n\tServer process started.')
logger.info('\tServer process id: '+str(cls.server_process.pid))
Expand Down Expand Up @@ -1094,7 +1094,7 @@ def test_6_get_one_valid_targetinfo(self):
# The SimpleHTTPServer started in the setupclass has a tendency to
# timeout in Windows after a few tests.
SERVER_PORT = random.randint(30000, 45000)
command = ['python', '-m', 'tuf.scripts.simple_server', str(SERVER_PORT)]
command = ['python', '-m', 'tests.simple_server', str(SERVER_PORT)]
server_process = subprocess.Popen(command, stderr=subprocess.PIPE)

# NOTE: Following error is raised if a delay is not long enough:
Expand Down Expand Up @@ -1361,7 +1361,7 @@ def test_7_updated_targets(self):
# The SimpleHTTPServer started in the setupclass has a tendency to
# timeout in Windows after a few tests.
SERVER_PORT = random.randint(30000, 45000)
command = ['python', '-m', 'tuf.scripts.simple_server', str(SERVER_PORT)]
command = ['python', '-m', 'tests.simple_server', str(SERVER_PORT)]
server_process = subprocess.Popen(command, stderr=subprocess.PIPE)

# NOTE: Following error is raised if a delay is not long enough to allow
Expand Down Expand Up @@ -1493,7 +1493,7 @@ def test_8_remove_obsolete_targets(self):
# The SimpleHTTPServer started in the setupclass has a tendency to
# timeout in Windows after a few tests.
SERVER_PORT = random.randint(30000, 45000)
command = ['python', '-m', 'tuf.scripts.simple_server', str(SERVER_PORT)]
command = ['python', '-m', 'tests.simple_server', str(SERVER_PORT)]
server_process = subprocess.Popen(command, stderr=subprocess.PIPE)

# NOTE: Following error is raised if a delay is not long enough to allow
Expand Down Expand Up @@ -1877,8 +1877,8 @@ def setUp(self):
self.SERVER_PORT = 30001
self.SERVER_PORT2 = 30002

command = ['python', '-m', 'tuf.scripts.simple_server', str(self.SERVER_PORT)]
command2 = ['python', '-m', 'tuf.scripts.simple_server', str(self.SERVER_PORT2)]
command = ['python', '-m', 'tests.simple_server', str(self.SERVER_PORT)]
command2 = ['python', '-m', 'tests.simple_server', str(self.SERVER_PORT2)]

self.server_process = subprocess.Popen(command, stderr=subprocess.PIPE,
cwd=self.repository_directory)
Expand Down

0 comments on commit 52071b1

Please sign in to comment.