sapling/eden/integration/rage_test.py
Matt Glazar ad6c2d5b66 Always run doctor checks in 'eden rage'
Summary:
If edenfs is not running or is unhealthy, 'eden rage' does not run 'eden doctor'. This means 'eden rage' does not include helpful output such as ~/local/.eden/clients/* being on NFS, or the Linux kernel version being unsupported.

Make 'eden rage' run 'eden doctor' regardless of the health of edenfs.

Reviewed By: simpkins

Differential Revision: D13633381

fbshipit-source-id: 2439057ba7a7bbe5041991ddc4ede256e86634f3
2019-01-14 14:04:11 -08:00

56 lines
2.4 KiB
Python

#!/usr/bin/env python3
#
# Copyright (c) 2016-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
import logging
from .lib import repobase, testcase
class RageTest(testcase.EdenRepoTest):
def populate_repo(self) -> None:
self.repo.write_file("README.md", "docs\n")
self.repo.commit("Initial commit.")
def create_repo(self, name: str) -> repobase.Repository:
return self.create_hg_repo(name)
def test_rage_output(self) -> None:
output = self.eden.run_cmd("rage", "--stdout")
logging.info(f"Rage output:\n{output}")
self.assert_output_includes_unconditional_checks(output)
self.assertRegex(output, r"\nbuild_package_release\s*:")
self.assertRegex(output, r"\nbuild_package_version\s*:")
self.assertRegex(output, r"\nuptime\s*:")
self.assertIn(f"\nChecking {self.mount}\n", output)
self.assertIn("edenfs memory usage", output)
def test_rage_output_with_stopped_daemon(self) -> None:
self.eden.shutdown()
output = self.eden.run_cmd("rage", "--stdout")
logging.info(f"Rage output:\n{output}")
self.assert_output_includes_unconditional_checks(output)
def assert_output_includes_unconditional_checks(self, output: str) -> None:
# Check to make sure that various important sections of information
# are present in the rage output.
#
# We may need to update this in the future if we modify the rage output; the
# main purpose it simply to make sure that the rage command did not exit early
# or crash partway through the output.
self.assertRegex(output, r"^User\s*:")
self.assertRegex(output, r"\nHostname\s*:")
# Allow the test to succeed even if the fb-eden RPM is not installed
self.assertRegex(output, r"\n(Rpm Version\s*:|Error getting the Rpm version)")
self.assertIn("\neden doctor --dry-run", output)
self.assertIn("\nMost recent Eden logs:\n", output)
self.assertIn("\nList of running Eden processes:\n", output)
self.assertIn("\nList of mount points:\n", output)
self.assertIn(f"\nMount point info for path {self.mount}:\n", output)
self.assertIn(f"{self.mount}\n", output)