Skip to content

Conversation

leoparente
Copy link
Contributor

This pull request introduces a "dry-run" mode to the networkDiscoveryBackend and snmpDiscoveryBackend components, enabling safer testing by simulating operations without executing them. It also adds corresponding configurations and unit tests to ensure the functionality works as expected.

Backend Enhancements:

  • Added diodeDryRun and diodeDryRunOutputDir fields to networkDiscoveryBackend and snmpDiscoveryBackend structs to support dry-run mode. (agent/backend/networkdiscovery/network_discovery.go: [1] agent/backend/snmpdiscovery/snmp_discovery.go: [2]
  • Updated Configure methods to populate dry-run-related fields from configuration and handle optional parameters. (agent/backend/networkdiscovery/network_discovery.go: [1] agent/backend/snmpdiscovery/snmp_discovery.go: [2]
  • Modified Start methods to adjust command-line arguments based on dry-run mode, ensuring safe execution and proper logging. (agent/backend/networkdiscovery/network_discovery.go: [1] agent/backend/snmpdiscovery/snmp_discovery.go: [2]

Testing Additions:

  • Added unit tests for dry-run mode in networkDiscoveryBackend and snmpDiscoveryBackend, verifying configuration, startup behavior, and command-line arguments. (agent/backend/networkdiscovery/network_discovery_test.go: [1] agent/backend/snmpdiscovery/snmp_discovery_test.go: [2]

@leoparente leoparente requested a review from Copilot June 25, 2025 18:45
@leoparente leoparente self-assigned this Jun 25, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a dry-run mode for both SNMP and network discovery backends, allowing simulated execution without side effects.

  • Added diodeDryRun and diodeDryRunOutputDir configuration fields to the relevant backend structs.
  • Modified Configure and Start methods to conditionally build command-line arguments based on the dry-run setting.
  • Added unit tests to verify the dry-run behavior in both discovery backends.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
agent/backend/snmpdiscovery/snmp_discovery_test.go Added a unit test for dry-run mode for the SNMP discovery backend (note potential misnaming of the test function).
agent/backend/snmpdiscovery/snmp_discovery.go Updated the SNMP discovery backend to support dry-run mode with conditional command-line option construction.
agent/backend/networkdiscovery/network_discovery_test.go Added a unit test for dry-run mode for the network discovery backend.
agent/backend/networkdiscovery/network_discovery.go Updated the network discovery backend to support dry-run mode with conditional command-line argument construction.
Comments suppressed due to low confidence (1)

agent/backend/snmpdiscovery/snmp_discovery_test.go:205

  • The test function name suggests it is for network discovery, but this file is for the SNMP discovery backend; consider renaming it to TestSNMPDiscoveryBackendDryRun for clarity.
func TestNetworkDiscoveryBackendDryRun(t *testing.T) {

Copy link

github-actions bot commented Jun 25, 2025

Go test coverage

STATUS ELAPSED PACKAGE COVER PASS FAIL SKIP
🟢 PASS 0.32s github.com/netboxlabs/orb-agent/agent 0.0% 0 0 0
🟢 PASS 0.32s github.com/netboxlabs/orb-agent/agent/backend 0.0% 0 0 0
🟢 PASS 5.03s github.com/netboxlabs/orb-agent/agent/backend/devicediscovery 76.0% 3 0 0
🟢 PASS 0.01s github.com/netboxlabs/orb-agent/agent/backend/mocks 0.0% 0 0 0
🟢 PASS 5.03s github.com/netboxlabs/orb-agent/agent/backend/networkdiscovery 75.8% 3 0 0
🟢 PASS 4.04s github.com/netboxlabs/orb-agent/agent/backend/otel 76.4% 2 0 0
🟢 PASS 3.02s github.com/netboxlabs/orb-agent/agent/backend/pktvisor 65.6% 2 0 0
🟢 PASS 5.03s github.com/netboxlabs/orb-agent/agent/backend/snmpdiscovery 75.8% 3 0 0
🟢 PASS 5.03s github.com/netboxlabs/orb-agent/agent/backend/worker 76.0% 3 0 0
🟢 PASS 1.01s github.com/netboxlabs/orb-agent/agent/config 100.0% 6 0 0
🟢 PASS 1.04s github.com/netboxlabs/orb-agent/agent/configmgr 49.2% 9 0 0
🟢 PASS 1.01s github.com/netboxlabs/orb-agent/agent/policies 100.0% 15 0 0
🟢 PASS 1.02s github.com/netboxlabs/orb-agent/agent/policymgr 70.3% 10 0 0
🟢 PASS 2.50s github.com/netboxlabs/orb-agent/agent/secretsmgr 45.7% 45 0 0
🟢 PASS 1.01s github.com/netboxlabs/orb-agent/agent/version 100.0% 1 0 0

Total coverage: 58.0%

@leoparente leoparente requested a review from jajeffries June 25, 2025 18:52
@leoparente leoparente marked this pull request as ready for review June 25, 2025 18:52
Copy link
Contributor

@jajeffries jajeffries left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@leoparente leoparente merged commit 1fa0983 into develop Jun 26, 2025
5 checks passed
@leoparente leoparente deleted the feat/OBS-1189-golang-dry-run-mode branch June 26, 2025 17:37
Copy link

🎉 This PR is included in version 2.3.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants