Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm preinstalled on macos for testing #5158

Merged
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.

### Added

- Add fix to provision macOS endpoints with npm ([#5128](https://github.com/wazuh/wazuh-qa/pull/5158)) \- (Tests)
- Add alert.json file to Vulnerability Detector E2E test report ([#5147](https://github.com/wazuh/wazuh-qa/pull/5147)) \- (Framework)
- Add documentation about markers for system tests ([#5080](https://github.com/wazuh/wazuh-qa/pull/5080)) \- (Documentation)
- Add AWS Custom Buckets Integration tests ([#4675](https://github.com/wazuh/wazuh-qa/pull/4675)) \- (Framework + Tests)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,39 @@ def load_vulnerability_detector_configurations(host_manager):

return configurations

@pytest.fixture(scope='module', autouse=True)
def install_npm(host_manager: HostManager):
"""Check and install npm if not already installed"""

node_version = "v21.7.1"
node_package_url = f"https://nodejs.org/dist/{node_version}/node-{node_version}.pkg"

target_os_groups = ['macos']

for group in target_os_groups:
for host in host_manager.get_group_hosts(group):
# Check if Node and npm is installed
logger.info(f"Checking and installing npm on {host}")
node_check_command = "PATH=/usr/local/bin:$PATH && command -v node"
node_check_result = host_manager.get_host(host).ansible(
"shell",
node_check_command,
become=True,
become_user='vagrant',
check=False
)
logger.info(f"Node check result on {host}: {node_check_result}")
# Install node if it is not already installed.
Comment on lines +121 to +134

This comment was marked as resolved.

if node_check_result['rc'] != 0:
logger.info(f"Installing Node.js and npm using package: {node_package_url}")

# Use the install_package method to handle the installation.
install_result = host_manager.install_package(host, node_package_url, system='macos')

# Logging the result of installation attempt.
logger.info(f"Node.js and npm installation result on {host}: {install_result}")
else:
logger.info("Node.js and npm are already installed.")

@pytest.fixture(scope='module')
def setup_vulnerability_tests(host_manager: HostManager) -> Generator:
Expand Down
Loading