Skip to content

Commit

Permalink
Fix up test to match reality of NFS client reporting. (#15244)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrimesix authored Dec 19, 2024
1 parent 9cfa6cd commit ae1daeb
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tests/api2/test_usage_reporting.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import time
from itertools import chain
from middlewared.test.integration.assets.nfs import nfs_server
from middlewared.test.integration.assets.ftp import ftp_server
Expand Down Expand Up @@ -52,20 +53,26 @@ def test_gather_types(get_usage_sample):


def test_nfs_reporting(get_usage_sample):
""" Confirm we are correctly reporting the number of connections """
# Initial state should have NFSv[3,4] and no connections
""" Confirm we are correctly reporting the number of NFS connections """
# NOTE: NFSv3 can be wildly inaccurate. Connections are recorded by mount requests.
# Connections get cleared by umount requests. Stale entries can easily accumulate.
# NFSv4 clients can be slow-ish to showup.
# Initial state should have NFSv[3,4] and possibly some stale NFSv3 connections from previous tests
assert set(get_usage_sample['NFS']['enabled_protocols']) == set(["NFSV3", "NFSV4"])
assert get_usage_sample['NFS']['num_clients'] == 0

# Establish two connections
nfs_path = f'/mnt/{pool_name}/test_nfs'
with nfs_dataset("test_nfs"):
with nfs_share(nfs_path):
with nfs_server():
# Wait a couple secs for clients to report in
time.sleep(2)
baseline_sample = call('usage.gather')['NFS']['num_clients']

# Establish a new connection.
with SSH_NFS(truenas_server.ip, nfs_path,
user=user, password=password, ip=truenas_server.ip):
usage_sample = call('usage.gather')
assert usage_sample['NFS']['num_clients'] == 1
assert usage_sample['NFS']['num_clients'] == baseline_sample + 1


def test_ftp_reporting(get_usage_sample):
Expand Down

0 comments on commit ae1daeb

Please sign in to comment.