Commit Graph

36 Commits

Author SHA1 Message Date
Mark Shroyer
f2cc4b4a82 Enable StartFakeEdenFSTest
Summary:
This is another case where we had issues with the long default temp path on
macOS.  Here, fake_edenfs was failing with SIGABRT on startup due to trying to
open a unix-domain socket with too long of a path.

D43925614 addressed this for tests based on EdenTestCase, but this doesn't help
with StartFakeEdenFSTestBase which only inherits from EdenTestCaseBase.  So
this diff moves the environment variable override one level up in the type
hierarchy to cover more test cases.

Reviewed By: kmancini

Differential Revision: D43988120

fbshipit-source-id: 9eca299c42aea819d3e93ed5bb408b4a4783d8ee
2023-03-14 13:25:16 -07:00
generatedunixname89002005307016
7942a4e360 upgrade pyre version in fbcode/eden - batch 1
Reviewed By: genevievehelsel

Differential Revision: D42946315

fbshipit-source-id: 38eff0b796fbbd78ba842787c5887390ff698e36
2023-02-01 20:39:41 -08:00
Pyre Bot Jr
e6149abe4d upgrade pyre version in fbcode/eden - batch 1
Differential Revision: D38447370

fbshipit-source-id: 24404529d137dbcd64f86ead8cc2896e96e84a42
2022-08-05 01:40:16 -07:00
John Reese
2940ae3a2a apply import merging for fbcode (4 of 11)
Summary:
Applies new import merging and sorting from µsort v1.0.

When merging imports, µsort will make a best-effort to move associated
comments to match merged elements, but there are known limitations due to
the diynamic nature of Python and developer tooling. These changes should
not produce any dangerous runtime changes, but may require touch-ups to
satisfy linters and other tooling.

Note that µsort uses case-insensitive, lexicographical sorting, which
results in a different ordering compared to isort. This provides a more
consistent sorting order, matching the case-insensitive order used when
sorting import statements by module name, and ensures that "frog", "FROG",
and "Frog" always sort next to each other.

For details on µsort's sorting and merging semantics, see the user guide:
https://usort.readthedocs.io/en/stable/guide.html#sorting

Reviewed By: lisroach

Differential Revision: D36402162

fbshipit-source-id: 6d180e9003d466c4f866fc9d454c6531766ca1dd
2022-05-15 12:53:03 -07:00
Pyre Bot Jr
41cff8e2c9 suppress errors in fbcode/eden - batch 1
Differential Revision: D36121058

fbshipit-source-id: 4dfe397e9b08d83218015292a53a8e7868e83e22
2022-05-03 22:59:26 -07:00
Pyre Bot Jr
bb5656edfc Add annotations to eden
Reviewed By: shannonzhu

Differential Revision: D34217873

fbshipit-source-id: 93794c9e7e63d12b709fca1d636e71916ef0eb5c
2022-02-14 12:17:43 -08:00
Xavier Deguillard
78d7369a18 test_support: shave 10 characters from EdenFS socket
Summary:
We've seen cases in CI where the length of the path to the socket is just over
108 characters, breaking tests. Let's shave 10 characters to be under the
limit.

Reviewed By: fanzeyi

Differential Revision: D34046658

fbshipit-source-id: 249b003db2a1f18f53c28702d81577ff55dcb237
2022-02-07 10:55:04 -08:00
Xavier Deguillard
a29d465ee8 fs: fix license header
Summary:
With Facebook having been renamed Meta Platforms, we need to change the license
headers.

Reviewed By: fanzeyi

Differential Revision: D33407812

fbshipit-source-id: b11bfbbf13a48873f0cea75f212cc7b07a68fb2e
2022-01-04 15:00:07 -08:00
Xavier Deguillard
303d37ab96 test_support: canonicalize the temporary directory path
Summary:
With D30320515, EdenFS internally canonicalize all the mount paths passed to
it. As a result, the output of `eden list` may not match the path given to
`eden mount` if one of the directory leading to the mount point was a symlink.
Since some tests are comparing both, this can lead to some test failures.

To solve this, we simply need to make sure that the temporary directory for the
test is canonicalized.

Reviewed By: fanzeyi

Differential Revision: D30349411

fbshipit-source-id: 139d4be02b5783c6a439270845239acab6a6c955
2021-08-16 16:08:45 -07:00
Katie Mancini
cca7ab3541 fix systemd tests locally
Reviewed By: fanzeyi

Differential Revision: D29640655

fbshipit-source-id: aa4e1377faf1a94789add86009a5b28ede2dd1d7
2021-07-09 17:24:11 -07:00
Pyre Bot Jr
b0a08b6a4f suppress errors in fbcode/eden - batch 1
Reviewed By: farnz

Differential Revision: D28962619

fbshipit-source-id: 7a2661eaa52fc019c8df647b8e23ff507178b3eb
2021-06-08 11:50:05 -07:00
John Reese
9fd86a4fae apply upgraded black 21.4b2 formatting to fbsource
Summary:
This applies the formatting changes from black v21.4b2 to all covered
projects in fbsource. Most changes are to single line docstrings, as black
will now remove leading and trailing whitespace to match PEP8. Any other
formatting changes are likely due to files that landed without formatting,
or files that previously triggered errors in black.

Any changes to code should be AST identical. Any test failures are likely
due to bad tests, or testing against the output of pyfmt.

Reviewed By: thatch

Differential Revision: D28204910

fbshipit-source-id: 804725bcd14f763e90c5ddff1d0418117c15809a
2021-05-04 22:16:51 -07:00
Xavier Deguillard
053d17f877 test_support: fix rmtree error function
Summary:
Somehow, rmtree can fail to open the file being removed, in which case the
function is `os.open` that requires a flag on top of the path. When that
happens a `TypeError` will be raised:

```
    ✗ Fail: eden/integration:integration - test_eden_start_fails_if_edenfs_fails_during_startup (eden.integration.start_test.StartFakeEdenFSTestSystemdEdenCLI) (4.363)
Test output:
> TypeError: open() missing required argument 'flags' (pos 2)
  File "/usr/local/fbcode/platform009/lib/python3.8/unittest/case.py", line 60, in testPartExecutor
    yield
  File "/usr/local/fbcode/platform009/lib/python3.8/unittest/case.py", line 717, in doCleanups
    self._callCleanup(function, *args, **kwargs)
  File "/usr/local/fbcode/platform009/lib/python3.8/unittest/async_case.py", line 72, in _callCleanup
    self._callMaybeAsync(function, *args, **kwargs)
  File "/usr/local/fbcode/platform009/lib/python3.8/unittest/async_case.py", line 84, in _callMaybeAsync
    ret = func(*args, **kwargs)
  File "/usr/local/fbcode/platform009/lib/python3.8/contextlib.py", line 533, in close
    self.__exit__(None, None, None)
  File "/usr/local/fbcode/platform009/lib/python3.8/contextlib.py", line 525, in __exit__
    raise exc_details[1]
  File "/usr/local/fbcode/platform009/lib/python3.8/contextlib.py", line 510, in __exit__
    if cb(*exc_details):
  File "/data/users/xavierd/fbsource/fbcode/buck-out/dev/gen/aab7ed39/eden/integration/integration#binary,link-tree/eden/test_support/temporary_directory.py", line 104, in __exit__
    self.cleanup(exc_type is not None)
  File "/data/users/xavierd/fbsource/fbcode/buck-out/dev/gen/aab7ed39/eden/integration/integration#binary,link-tree/eden/test_support/temporary_directory.py", line 117, in cleanup
    cleanup_tmp_dir(temp_dir)
  File "/data/users/xavierd/fbsource/fbcode/buck-out/dev/gen/aab7ed39/eden/integration/integration#binary,link-tree/eden/test_support/temporary_directory.py", line 71, in cleanup_tmp_dir
    shutil.rmtree(tmp_dir, onerror=_remove_readonly)
  File "/usr/local/fbcode/platform009/lib/python3.8/shutil.py", line 715, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/usr/local/fbcode/platform009/lib/python3.8/shutil.py", line 652, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/local/fbcode/platform009/lib/python3.8/shutil.py", line 652, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/local/fbcode/platform009/lib/python3.8/shutil.py", line 652, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/local/fbcode/platform009/lib/python3.8/shutil.py", line 648, in _rmtree_safe_fd
    onerror(os.open, fullname, sys.exc_info())
  File "/data/users/xavierd/fbsource/fbcode/buck-out/dev/gen/aab7ed39/eden/integration/integration#binary,link-tree/eden/test_support/temporary_directory.py", line 66, in _remove_readonly
    func(path)
```

To bypass this, let's simply test if the function is os.unlink or os.rmdir
first.

Reviewed By: chadaustin

Differential Revision: D27654126

fbshipit-source-id: 318c547f363c020e98e21d5f07a9c7a9b2e5102d
2021-04-08 19:00:42 -07:00
Mark Mendoza
246415f23b Manually upgrading eden, and fixing their config
Summary: I think that the broken config (wrong relative base for search_path), was what prevented the upgrade from going automatically.

Reviewed By: grievejia

Differential Revision: D22966243

fbshipit-source-id: 4ef42a8e2e6f2c79483301c6876509a3009a83d1
2020-08-06 12:37:04 -07:00
Chad Austin
46a89778ea enable asynchronous integration tests
Summary:
Python 3.8 provides the (poorly named)
unittest.IsolatedAsyncioTestCase base class that gives each test an
asyncio event loop and runs it. This allows us to write async
integration tests, required to use modern Thrift Python.

Reviewed By: genevievehelsel

Differential Revision: D21955584

fbshipit-source-id: 8366dc7c72b31e1667e72fe1e359587b74e2c614
2020-06-15 15:53:50 -07:00
Chad Austin
597c209fa1 disallow warnings in integration tests
Summary:
Unawaited coroutines are pernicious and not errors by default. In
advance of enabling asynchronous tests, fail our tests when Python
warnings are shown.

We record warnings and report them after the test body instead of
enabling an "error" warning filter because exceptions thrown by
finalizers are silently swallowed, and most important warnings occur
during finalization.

Reviewed By: genevievehelsel

Differential Revision: D21955210

fbshipit-source-id: b1fc52ddfa9f9befbde6800f85f090862af0ef15
2020-06-10 23:23:34 -07:00
Chad Austin
a96f374228 fix EDEN_TEST_NO_CLEANUP and add EDEN_TEST_NO_CLEANUP_ON_FAILURE
Summary:
It looks like a refactoring broke the EDEN_TEST_NO_CLEANUP feature
which was useful when trying to debug the eden state directory after a
failure.

While fixing it, I went ahead and added support for only saving the
state directory upon test failure.

Reviewed By: simpkins

Differential Revision: D21780122

fbshipit-source-id: 0cd6e9f274601eebd9b4a6978c0cf61fb1b85545
2020-06-10 19:29:17 -07:00
Adam Simpkins
606e928233 fix a file descriptor leak in the temporary file code
Summary:
The new temporary file code added in D20885160 was missing a call to close the
underlying file in the `__exit__()` function.

Reviewed By: xavierd

Differential Revision: D21271901

fbshipit-source-id: 653258d471421edd08b473654ae3d0503f3c6829
2020-04-28 12:11:51 -07:00
Shannon Zhu
6ec7546cab Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Reviewed By: grievejia

Differential Revision: D21207287

fbshipit-source-id: ab82cf81690cb847bd130ff3448345f5a0ea19af
2020-04-23 12:09:39 -07:00
Adam Simpkins
c763e922a2 kill off some of the integration test mixin classes
Summary:
This updates the various systemd-related tests to use EdenTestCaseBase,
and allows us to delete the EnvironmentVariableMixin and
SystemdUserServiceManagerMixin classes.

The main goal of this clean-up is to make it easier to consolidate most of the
systemd-related code into just a few locations, so that we can more easily
disable the systemd-related tests in build environments where systemd is not
supported.

Reviewed By: wez

Differential Revision: D21084098

fbshipit-source-id: d5e05254c689c28751fe48d2dc38d722c7e77ed3
2020-04-22 15:02:42 -07:00
Adam Simpkins
72f6ada7c2 add a new EdenTestCaseBase class
Summary:
This adds a new `EdenTestCaseBase` class to serve as the base class across a
number of our integration tests and some of our CLI tests.

The main goal of this is to allow eliminating many of the annoying `*Mixin`
classes used in a lot of our integration tests.  These mixin classes are
annoying since they result in complicated multiple inheritance, and it can be
tricky to ensure that the method resolution order behaves the way you want.
The systemd tests in particular use a lot of mixins, which gets complicated.
These mixin classes are also awkward from a Python typing perspective, and the
systemd tests end up resorting to just declaring different APIs in several
places when `typing.TYPE_CHECKING` is True.

The fact that `EdenTestCaseBase` has a `contextlib.ExitStack` member variable
should make it easier for us to eliminate these mixins moving forward: rather
than using mixins that use inheritance and assume a `self.cleanUp()` method
exists, we can transition this code to standalone functions or context
managers, and they can take the `ExitStack` variable as an argument if
necessary.

Reviewed By: wez

Differential Revision: D21084097

fbshipit-source-id: 77ee457b7debe6f584f630e3e30f79fe634a2026
2020-04-22 15:02:41 -07:00
Adam Simpkins
772369731c implement our own temporary file management during integration tests
Summary:
Unfortunately the Python standard library's `tempfile.NamedTemporaryFile`
class does not work very well on Windows: even though the temporary files are
named, they cannot actually be opened by other processes.  Attempting to open
the file fails with a permission denied error.

This code extends our existing temporary directory management logic to also
add APIs for creating individual temporary files.  This has the advantage of
better grouping all temporary files for a given test in the same directory.  I
also updated the code to include the test function name in the temporary
directory prefix.  This should make it a little easier to identify which test
is at fault when there are temporary files left behind after a test.  (This
can happen if the test gets killed or if it leaves behind files or mount
points that cannot be removed normally).

Reviewed By: wez

Differential Revision: D20885160

fbshipit-source-id: 7267b2352e51214354eab7ead839bf166d690974
2020-04-13 13:12:04 -07:00
Wez Furlong
43af241301 eden: remove hypothesis test bits
Summary:
Sadly, we didn't derive as much value from these as we would
have liked, and now they are a source of flakeyness in our tests.

Reviewed By: genevievehelsel

Differential Revision: D19460792

fbshipit-source-id: 48c82cc2d1fdbd81bece4057e93799fbcc4f4725
2020-01-23 11:37:27 -08:00
generatedunixname89002005307016
4c76d686a8 Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Reviewed By: grievejia

Differential Revision: D17956249

fbshipit-source-id: d5c8b5aa73151b3fea67aec35d70f332030da2c9
2019-10-16 16:56:29 -07:00
Andres Suarez
fbdb46f5cb Tidy up license headers
Reviewed By: chadaustin

Differential Revision: D17872966

fbshipit-source-id: cd60a364a2146f0dadbeca693b1d4a5d7c97ff63
2019-10-11 05:28:23 -07:00
Adam Simpkins
8ce111ef53 support building the integration tests with CMake
Summary:
Add initial support for building and running some of the integration tests
with CMake.  For now this just runs the tests from basic_test.py, just to
confirm that most of the framework code works in CMake-based builds.

Many of the other tests should also work as well, but a few of them we may
want to disable for CMake-based builds.  e.g., a couple of the tests depend on
hypothesis, and we would need to include hypothesis as a dependency.  Some of
the tests that use systemd might also require a little more work to get
working.

Reviewed By: fanzeyi

Differential Revision: D17659026

fbshipit-source-id: 67420fda9e1021a0cddee2d385fd21e34fb2fd70
2019-10-04 08:56:38 -07:00
generatedunixname89002005289445
9b9015c137 Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Reviewed By: grievejia

Differential Revision: D17255059

fbshipit-source-id: 4eb207bcefb699c1886d1f0c1511b6d26100ff0e
2019-09-09 07:41:21 -07:00
generatedunixname89002005289445
13e683608d Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Reviewed By: sinancepel

Differential Revision: D17135557

fbshipit-source-id: 07afef940271a277c75834892733901d070bfa5f
2019-08-30 13:37:34 -07:00
Adam Simpkins
9bfb48c921 update license headers in .py files
Summary:
Update the copyright & license headers in Python files to reflect the
relicensing to GPLv2

Reviewed By: wez

Differential Revision: D15487088

fbshipit-source-id: 9f2138dff41048d2c35f15e09a04ae5a9c9c80dd
2019-06-19 17:02:46 -07:00
Sinan Cepel
c281b44695 upgrade Pyre version for eden
Reviewed By: shannonzhu

Differential Revision: D15718331

fbshipit-source-id: 3c3df62e8feb058766bc639482deb8dc3b6d4ec7
2019-06-07 12:27:23 -07:00
Sinan Cepel
4547deafca Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Reviewed By: dkgi

Differential Revision: D15283973

fbshipit-source-id: b1451da50dbbee0f71260d50caece21799f008f2
2019-05-09 18:17:36 -07:00
Matt Glazar
c91b552ef5 Allow systemd opt-in via config
Summary:
Currently, users can opt into systemd for edenfs by setting EDEN_EXPERIMENTAL_SYSTEMD=1 every time they use Eden's CLI. Make it easier to opt in: use systemd if service.experimental_systemd is set in ~/.edenrc. Also allow opting out for a single command via EDEN_EXPERIMENTAL_SYSTEMD=0.

For users who don't set service.experimental_systemd or use EDEN_EXPERIMENTAL_SYSTEMD, this diff should not change behavior. (The EDEN_EXPERIMENTAL_SYSTEMD environment variable is still respected.)

Reviewed By: simpkins

Differential Revision: D13371186

fbshipit-source-id: d7b533ea3583f4b6c8a8f63c6a74eace2be7d783
2018-12-10 16:30:06 -08:00
Matt Glazar
4af60a78e0 Refactor should_use_experimental_systemd_mode into EdenInstance
Summary:
I want to allow opting into systemd using a setting in ~/.edenrc. Since should_use_experimental_systemd_mode is a global function, it can't read any configs. Make the config file visible to should_use_experimental_systemd_mode by moving it into EdenInstance.

This diff should not change behavior.

Reviewed By: simpkins

Differential Revision: D13370823

fbshipit-source-id: b604db66954d0a08973030daae38bf6b1433e821
2018-12-07 18:50:35 -08:00
Matt Glazar
506cf4ebf8 Use TemporaryDirectoryMixin in CLI tests
Summary: CLI tests use shutil.rmtree to clean up temporary directories. Reuse TemporaryDirectoryMixin which is more robust against errors and supports EDEN_TEST_NO_CLEANUP.

Reviewed By: chadaustin

Differential Revision: D13268108

fbshipit-source-id: d77e95a2def0dceb34cf14e19c0c0c0e3aeef3f2
2018-12-03 14:42:11 -08:00
Matt Glazar
1f981860ee Add systemd EnvironmentFile reader/writer
Summary:
EdenFS' systemd service will be configurable using config files.  The Eden CLI will communicate information, such as extra daemon arguments, to systemd using a file specified using EnvironmentFile= [1]. Write code to serialize and deserialize these files.

The code introduced by this diff isn't used yet, but it will be used in future diffs.

[1] https://www.freedesktop.org/software/systemd/man/systemd.exec.html#EnvironmentFile=

Reviewed By: chadaustin

Differential Revision: D12066543

fbshipit-source-id: 28ba38d823b92f7a3a7ad97c416120a7f95be122
2018-11-16 11:13:09 -08:00
Matt Glazar
cd9dd1f275 Move fuzzer config out of integration directory
Summary:
I want to use Hypothesis to fuzz some CLI code. Move EdenFS' Hypothesis configuration out of eden.integration.lib.testcase and into a place where both CLI tests and integration tests can use it.

This diff should not change behavior.

Reviewed By: wez

Differential Revision: D12813285

fbshipit-source-id: 3a1badd1e18b0e070295ea03dcb24be166cd42c1
2018-11-15 20:48:15 -08:00