New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow tests to run with isolated stores #6743

Merged
merged 1 commit into from Nov 9, 2018

Conversation

Projects
None yet
2 participants
@illicitonion
Contributor

illicitonion commented Nov 8, 2018

Also, add a decorator to explicitly use an empty store for a block of
code.

Each unique scheduler will have a unique store. This will be important
soon, as I'm about to add tests for caching of file downloads which
relies on the in-store state.

@illicitonion illicitonion requested a review from stuhood Nov 8, 2018

@illicitonion illicitonion force-pushed the twitter:dwagnerhall/isolatedstores branch from 06685b4 to d10c58a Nov 8, 2018

Allow tests to run with isolated stores
Also, add a decorator to explicitly use an empty store for a block of
code.

Each unique scheduler will have a unique store. This will be important
soon, as I'm about to add tests for caching of file downloads which
relies on the in-store state.

@illicitonion illicitonion force-pushed the twitter:dwagnerhall/isolatedstores branch from d10c58a to 66df8dc Nov 8, 2018

@stuhood

stuhood approved these changes Nov 9, 2018

@@ -100,6 +101,7 @@ def create_scheduler(rules, validate=True, native=None):
native,
FileSystemProjectTree(os.getcwd()),
'./.pants.d',
safe_mkdtemp(),

This comment has been minimized.

@stuhood

stuhood Nov 9, 2018

Member

See my comment on the other review.

This comment has been minimized.

@illicitonion

illicitonion Nov 9, 2018

Contributor

I think isolation by default is good, because:

  1. Isolation is generally good. I think @dotordogh or I ran into issues where
    def test_materialize_directories(self):
    # I tried passing in the digest of a file, but it didn't make it to the
    # rust code due to all of the checks we have in place (which is probably a good thing).
    self.prime_store_with_roland_digest()
    with temporary_dir() as temp_dir:
    dir_path = os.path.join(temp_dir, "containing_roland")
    digest = Digest(
    text_type("63949aa823baf765eff07b946050d76ec0033144c785a94d3ebd82baa931cd16"),
    80
    )
    scheduler = self.mk_scheduler(rules=create_fs_rules())
    scheduler.materialize_directories((DirectoryToMaterialize(text_type(dir_path), digest),))
    created_file = os.path.join(dir_path, "roland")
    with open(created_file, 'r') as f:
    content = f.read()
    self.assertEqual(content, "European Burmese")
    was either failing when it should pass, or passing when it should fail, before the prime_store_with_roland_digest was added, because it relied on the store already happening to have the digest in question in it.
  2. The speedup of re-using an existing store should be pretty small.

(The "force isolation" function is handy because the default in this PR is actually to share a store across an test class)

Happy to re-visit if you are convinced otherwise :)

@illicitonion illicitonion merged commit 37dc938 into pantsbuild:master Nov 9, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@illicitonion illicitonion deleted the twitter:dwagnerhall/isolatedstores branch Nov 9, 2018

wisechengyi added a commit to wisechengyi/pants that referenced this pull request Nov 12, 2018

Allow tests to run with isolated stores (pantsbuild#6743)
Also, add a decorator to explicitly use an empty store for a block of
code.

Each unique scheduler will have a unique store. This will be important
soon, as I'm about to add tests for caching of file downloads which
relies on the in-store state.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment