Ensure new health endpoint builds on MacOS (#1215)

* Add mac build to CI

* Always return an error for Health when not linux

* Change macos workflow

* Rename macos tests

* Disable health API test on Mac

Co-authored-by: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
Paul Hauner 2020-06-01 21:18:31 +10:00 committed by GitHub
parent cb26ddebb1
commit 723c7cbd27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 2 deletions

View File

@ -26,6 +26,19 @@ jobs:
run: sudo npm install -g ganache-cli
- name: Run tests in release
run: make test-release
release-tests-and-install-macos:
runs-on: macos-latest
needs: cargo-fmt
steps:
- uses: actions/checkout@v1
- name: Get latest version of stable Rust
run: rustup update stable
- name: Install ganache-cli
run: sudo npm install -g ganache-cli
- name: Run tests in release
run: make test-release
- name: Install Lighthouse
run: make
debug-tests-ubuntu:
runs-on: ubuntu-latest
needs: cargo-fmt

View File

@ -105,6 +105,8 @@ pub fn get_prometheus<T: BeaconChainTypes>(
store::scrape_for_metrics(&db_path, &freezer_db_path);
beacon_chain::scrape_for_metrics(&beacon_chain);
// This will silently fail if we are unable to observe the health. This is desired behaviour
// since we don't support `Health` for all platforms.
if let Ok(health) = Health::observe() {
set_gauge(&PROCESS_NUM_THREADS, health.pid_num_threads as i64);
set_gauge(&PROCESS_RES_MEM, health.pid_mem_resident_set_size as i64);

View File

@ -1253,6 +1253,7 @@ mod validator_attestation {
}
}
#[cfg(target_os = "linux")]
#[test]
fn get_health() {
let mut env = build_env();

View File

@ -14,5 +14,7 @@ state_processing = { path = "../../consensus/state_processing" }
bls = { path = "../../crypto/bls" }
serde = { version = "1.0.110", features = ["derive"] }
rayon = "1.3.0"
[target.'cfg(target_os = "linux")'.dependencies]
psutil = "3.1.0"
procinfo = "0.4.2"

View File

@ -1,10 +1,11 @@
//! Collection of types for the /node HTTP
use procinfo::pid;
use psutil::process::Process;
use serde::{Deserialize, Serialize};
use ssz_derive::{Decode, Encode};
use types::Slot;
#[cfg(target_os = "linux")]
use {procinfo::pid, psutil::process::Process};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Encode, Decode)]
/// The current syncing status of the node.
pub struct SyncingStatus {
@ -63,6 +64,12 @@ pub struct Health {
}
impl Health {
#[cfg(not(target_os = "linux"))]
pub fn observe() -> Result<Self, String> {
Err("Health is only available on Linux".into())
}
#[cfg(target_os = "linux")]
pub fn observe() -> Result<Self, String> {
let process =
Process::current().map_err(|e| format!("Unable to get current process: {:?}", e))?;