LeastAuthority / leastauthority.com

Least Authority S4
https://leastauthority.com/
Other
14 stars 18 forks source link

tests incorrectly assume existence of ../secret_config/lae_automation_config.json #193

Closed daira closed 10 years ago

daira commented 10 years ago
lae_site.handlers
  test
    test_submit_subscription ... Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Twisted-12.3.0-py2.7-linux-x86_64.egg/twisted/trial/runner.py", line 562, in loadPackage
    module = modinfo.load()
  File "/usr/local/lib/python2.7/dist-packages/Twisted-12.3.0-py2.7-linux-x86_64.egg/twisted/python/modules.py", line 383, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-12.3.0-py2.7-linux-x86_64.egg/twisted/python/_reflectpy3.py", line 208, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-12.3.0-py2.7-linux-x86_64.egg/twisted/python/_reflectpy3.py", line 144, in _importAndCheckStack
    return __import__(importName)
  File "/home/davidsarah/tahoe/git/LeastAuthority/leastauthority.com/lae_site/handlers/__init__.py", line 9, in <module>
    from lae_site.handlers.submit_subscription import SubmitSubscriptionHandler
  File "/home/davidsarah/tahoe/git/LeastAuthority/leastauthority.com/lae_site/handlers/submit_subscription.py", line 13, in <module>
    config = Config()
  File "/home/davidsarah/tahoe/git/LeastAuthority/leastauthority.com/lae_automation/config.py", line 24, in __init__
    assert field in value, value
exceptions.AssertionError: {'product_token': '{ProductToken}AAAGQXBwVGtuEvPmPL+rhE+rudPRlUdVjlC+4B70s+Vn1vDaKKZVW3XrPwCLxIb86PGoHJpbAn7CwedKmWtSIlC87ZSyePH4QGx0sfvbBc8OTHnE5aeexoNomsB3Foz4KEFCvtW14YkBvY7Ex0nFR9Ll3OzfBlnnlf0ZHTIABJfmxOJokpfV1IsteRVcUqXToQ4+7DhMRLx29bTjQOp0YlgzV62Tp3kPWTp5KM1eNCyaPRm8bCH0fof3N5JeWy5e+55pvpNdP/tk09hYg1v+maeY1Qp/1BMnA8RUvAXk+Vsq4Q8c21PArZg=', 'product_code': 'B2429CCE', 'ami_image_id': 'ami-361b5f5f', 'instance_size': 't1.micro', 'full_name': 'Tahoe-LAFS-on-S3 test B2429CCE'}
[ERROR]
lae_site.test.test_config
  ConfigTests
    test_load_file ...                                                     [OK]
    test_other ...                                                         [OK]
    test_unexceptional_load ...                                            [OK]
lae_site
  test
    test_site ... Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Twisted-12.3.0-py2.7-linux-x86_64.egg/twisted/trial/runner.py", line 562, in loadPackage
    module = modinfo.load()
  File "/usr/local/lib/python2.7/dist-packages/Twisted-12.3.0-py2.7-linux-x86_64.egg/twisted/python/modules.py", line 383, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-12.3.0-py2.7-linux-x86_64.egg/twisted/python/_reflectpy3.py", line 208, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-12.3.0-py2.7-linux-x86_64.egg/twisted/python/_reflectpy3.py", line 144, in _importAndCheckStack
    return __import__(importName)
  File "/home/davidsarah/tahoe/git/LeastAuthority/leastauthority.com/lae_site/test/test_site.py", line 13, in <module>
    from lae_site.handlers import make_site
  File "/home/davidsarah/tahoe/git/LeastAuthority/leastauthority.com/lae_site/handlers/__init__.py", line 9, in <module>
    from lae_site.handlers.submit_subscription import SubmitSubscriptionHandler
  File "/home/davidsarah/tahoe/git/LeastAuthority/leastauthority.com/lae_site/handlers/submit_subscription.py", line 13, in <module>
    config = Config()
  File "/home/davidsarah/tahoe/git/LeastAuthority/leastauthority.com/lae_automation/config.py", line 24, in __init__
    assert field in value, value
exceptions.AssertionError: {'product_token': '{ProductToken}AAAGQXBwVGtuEvPmPL+rhE+rudPRlUdVjlC+4B70s+Vn1vDaKKZVW3XrPwCLxIb86PGoHJpbAn7CwedKmWtSIlC87ZSyePH4QGx0sfvbBc8OTHnE5aeexoNomsB3Foz4KEFCvtW14YkBvY7Ex0nFR9Ll3OzfBlnnlf0ZHTIABJfmxOJokpfV1IsteRVcUqXToQ4+7DhMRLx29bTjQOp0YlgzV62Tp3kPWTp5KM1eNCyaPRm8bCH0fof3N5JeWy5e+55pvpNdP/tk09hYg1v+maeY1Qp/1BMnA8RUvAXk+Vsq4Q8c21PArZg=', 'product_code': 'B2429CCE', 'ami_image_id': 'ami-361b5f5f', 'instance_size': 't1.micro', 'full_name': 'Tahoe-LAFS-on-S3 test B2429CCE'}
[ERROR]

===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Twisted-12.3.0-py2.7-linux-x86_64.egg/twisted/trial/runner.py", line 562, in loadPackage
    module = modinfo.load()
  File "/usr/local/lib/python2.7/dist-packages/Twisted-12.3.0-py2.7-linux-x86_64.egg/twisted/python/modules.py", line 383, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-12.3.0-py2.7-linux-x86_64.egg/twisted/python/_reflectpy3.py", line 208, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-12.3.0-py2.7-linux-x86_64.egg/twisted/python/_reflectpy3.py", line 144, in _importAndCheckStack
    return __import__(importName)
  File "/home/davidsarah/tahoe/git/LeastAuthority/leastauthority.com/lae_site/handlers/__init__.py", line 9, in <module>
    from lae_site.handlers.submit_subscription import SubmitSubscriptionHandler
  File "/home/davidsarah/tahoe/git/LeastAuthority/leastauthority.com/lae_site/handlers/submit_subscription.py", line 13, in <module>
    config = Config()
  File "/home/davidsarah/tahoe/git/LeastAuthority/leastauthority.com/lae_automation/config.py", line 24, in __init__
    assert field in value, value
exceptions.AssertionError: {'product_token': '{ProductToken}AAAGQXBwVGtuEvPmPL+rhE+rudPRlUdVjlC+4B70s+Vn1vDaKKZVW3XrPwCLxIb86PGoHJpbAn7CwedKmWtSIlC87ZSyePH4QGx0sfvbBc8OTHnE5aeexoNomsB3Foz4KEFCvtW14YkBvY7Ex0nFR9Ll3OzfBlnnlf0ZHTIABJfmxOJokpfV1IsteRVcUqXToQ4+7DhMRLx29bTjQOp0YlgzV62Tp3kPWTp5KM1eNCyaPRm8bCH0fof3N5JeWy5e+55pvpNdP/tk09hYg1v+maeY1Qp/1BMnA8RUvAXk+Vsq4Q8c21PArZg=', 'product_code': 'B2429CCE', 'ami_image_id': 'ami-361b5f5f', 'instance_size': 't1.micro', 'full_name': 'Tahoe-LAFS-on-S3 test B2429CCE'}

lae_site.handlers.test.test_submit_subscription
===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/Twisted-12.3.0-py2.7-linux-x86_64.egg/twisted/trial/runner.py", line 562, in loadPackage
    module = modinfo.load()
  File "/usr/local/lib/python2.7/dist-packages/Twisted-12.3.0-py2.7-linux-x86_64.egg/twisted/python/modules.py", line 383, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-12.3.0-py2.7-linux-x86_64.egg/twisted/python/_reflectpy3.py", line 208, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File "/usr/local/lib/python2.7/dist-packages/Twisted-12.3.0-py2.7-linux-x86_64.egg/twisted/python/_reflectpy3.py", line 144, in _importAndCheckStack
    return __import__(importName)
  File "/home/davidsarah/tahoe/git/LeastAuthority/leastauthority.com/lae_site/test/test_site.py", line 13, in <module>
    from lae_site.handlers import make_site
  File "/home/davidsarah/tahoe/git/LeastAuthority/leastauthority.com/lae_site/handlers/__init__.py", line 9, in <module>
    from lae_site.handlers.submit_subscription import SubmitSubscriptionHandler
  File "/home/davidsarah/tahoe/git/LeastAuthority/leastauthority.com/lae_site/handlers/submit_subscription.py", line 13, in <module>
    config = Config()
  File "/home/davidsarah/tahoe/git/LeastAuthority/leastauthority.com/lae_automation/config.py", line 24, in __init__
    assert field in value, value
exceptions.AssertionError: {'product_token': '{ProductToken}AAAGQXBwVGtuEvPmPL+rhE+rudPRlUdVjlC+4B70s+Vn1vDaKKZVW3XrPwCLxIb86PGoHJpbAn7CwedKmWtSIlC87ZSyePH4QGx0sfvbBc8OTHnE5aeexoNomsB3Foz4KEFCvtW14YkBvY7Ex0nFR9Ll3OzfBlnnlf0ZHTIABJfmxOJokpfV1IsteRVcUqXToQ4+7DhMRLx29bTjQOp0YlgzV62Tp3kPWTp5KM1eNCyaPRm8bCH0fof3N5JeWy5e+55pvpNdP/tk09hYg1v+maeY1Qp/1BMnA8RUvAXk+Vsq4Q8c21PArZg=', 'product_code': 'B2429CCE', 'ami_image_id': 'ami-361b5f5f', 'instance_size': 't1.micro', 'full_name': 'Tahoe-LAFS-on-S3 test B2429CCE'}

lae_site.test.test_site
-------------------------------------------------------------------------------
zancas commented 10 years ago

ack'd

zancas commented 10 years ago

/me runs git pull --verbose github_leastauthority.com

zancas commented 10 years ago

./runtests.sh

zancas commented 10 years ago

daira what commit did these tests fail on?

I ran against: 28d900c6d3396709d89d9995ced40372d5cf59a6

and got no failures.

Also the test failures look like they use an older version of the test vector.

daira commented 10 years ago

Yes, because on my machine, ../secret_config/lae_automation_config.json randomly happened to be an older version of the config. The tests shouldn't be reading from there!

zancas commented 10 years ago

Understood.

I'm having some difficulty with this.

I mv'd the repo to check for spurious access to files outside leastauthority.com. I get the IOError showing the bug as expected.

When I attempt to patch out the reference to lae_automation.config.Config and replace it with a MockObject, the actual object is still referenced.

By examining the traceback I see that handlers/init.py is evaluated. I'm not sure why that is.

(LeastAuthority_env) 0 git_branch: master
/home/arc/LeastAuthority_env/LeastAuthority/website/buffer_directory/leastauthority.com :
$ trial lae_site.handlers.test.test_submit_subscription
lae_site.handlers
  test
    test_submit_subscription ...                                        [ERROR]

===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/home/arc/LeastAuthority_env/local/lib/python2.7/site-packages/twisted/trial/runner.py", line 588, in loadByNames
    things.append(self.findByName(name))
  File "/home/arc/LeastAuthority_env/local/lib/python2.7/site-packages/twisted/trial/runner.py", line 398, in findByName
    return reflect.namedAny(name)
  File "/home/arc/LeastAuthority_env/local/lib/python2.7/site-packages/twisted/python/_reflectpy3.py", line 266, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File "/home/arc/LeastAuthority_env/local/lib/python2.7/site-packages/twisted/python/_reflectpy3.py", line 205, in _importAndCheckStack
    return __import__(importName)
  File "/home/arc/LeastAuthority_env/LeastAuthority/website/buffer_directory/leastauthority.com/lae_site/handlers/__init__.py", line 9, in <module>
    from lae_site.handlers.submit_subscription import SubmitSubscriptionHandler
  File "/home/arc/LeastAuthority_env/LeastAuthority/website/buffer_directory/leastauthority.com/lae_site/handlers/submit_subscription.py", line 13, in <module>
    config = Config()
  File "/home/arc/LeastAuthority_env/LeastAuthority/website/buffer_directory/leastauthority.com/lae_automation/config.py", line 14, in __init__
    config = self._load_config_json(configFile)
  File "/home/arc/LeastAuthority_env/LeastAuthority/website/buffer_directory/leastauthority.com/lae_automation/config.py", line 33, in _load_config_json
    configFile = open(configFile, 'r')
exceptions.IOError: [Errno 2] No such file or directory: '../secret_config/lae_automation_config.json'

lae_site.handlers.test.test_submit_subscription
-------------------------------------------------------------------------------
Ran 1 tests in 0.001s

FAILED (errors=1)
zancas commented 10 years ago

Fixed:

https://github.com/LeastAuthority/leastauthority.com/commit/0eff1af8de0d2af1e54f449bea1903d5b83a9d2d

zancas commented 10 years ago

To close this issue, run the unittests on a leastauthority.com 0eff1af repo, that is in a directory isolated from "sisters" e.g. secret_config.

If your tests pass, then you can close the issue.

daira commented 10 years ago

LGTM.