Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,61 @@ jobs:
uses: SimenB/github-actions-cpu-cores@v2
- name: Run tests
run: prove --timer --lib --recurse --jobs ${{ steps.cores.outputs.count }} --shuffle t/

tests-extra-runners:
needs: build

strategy:
fail-fast: false
matrix:
os:
- dragonflybsd
- freebsd
- netbsd
- openbsd
- solaris

runs-on: ubuntu-latest

timeout-minutes: 20

steps:
- name: Download build results
uses: actions/download-artifact@v4
with:
name: build.tar
- name: Extract build tarball
run: tar xvf build.tar
- name: Set environment variables based on OS
uses: thaitype/actions-switch-case@v1
id: env_cmd
with:
default: 'echo Using default environment'
conditionals-with-values: |
${{ matrix.os == 'dragonflybsd' }} => setenv LANG C
${{ matrix.os == 'solaris' }} => export PATH=/usr/perl5/bin:/usr/gnu/bin:$PATH
- name: Set system setup command based on OS
uses: thaitype/actions-switch-case@v1
id: system_cmd
with:
default: '$VM_INSTALL_CMD augeas git'
conditionals-with-values: |
${{ matrix.os == 'solaris' }} => $VM_INSTALL_CMD developer/gcc/gcc-c developer/versioning/git system/management/augeas
- name: Set cpanm setup command based on OS
uses: thaitype/actions-switch-case@v1
id: cpanm_cmd
with:
default: '$VM_INSTALL_CMD p5-App-cpanminus'
conditionals-with-values: |
${{ matrix.os == 'openbsd' }} => cpan install App::cpanminus
${{ matrix.os == 'solaris' }} => cpan install App::cpanminus
- name: Run tests on ${{ matrix.os }}
uses: jenseng/dynamic-uses@v1
with:
uses: vmactions/${{ matrix.os }}-vm@v1
with: |
{
"envs": "LANG PERL_CPANM_OPT VM_INSTALL_CMD",
"prepare": "cd $GITHUB_WORKSPACE; ${{ steps.env_cmd.outputs.match }}; ${{ steps.system_cmd.outputs.match }}; ${{ steps.cpanm_cmd.outputs.match }}; cpanm --installdeps --with-all-features .; cpanm Parallel::ForkManager",
"run": "cd $GITHUB_WORKSPACE; ${{ steps.env_cmd.outputs.match }}; prove --timer --lib --recurse --jobs 4 --shuffle t/"
}
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Revision history for Rex
[API CHANGES]

[BUG FIXES]
- Fix FQDN parsing
- Handle SMBios errors gracefully
- Fix parsing free memory on Solaris
- Fix shared variable lockfile on Solaris
- Prefer GNU tools on Solaris

[DOCUMENTATION]

Expand Down
15 changes: 11 additions & 4 deletions lib/Rex/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ The value should be set as an array reference, and will be dereferenced as such
Default is

qw(
/usr/gnu/bin
/bin
/sbin
/usr/bin
Expand All @@ -750,10 +751,16 @@ sub set_path {

sub get_path {
if ( !$path ) {
return (
"/bin", "/sbin", "/usr/bin",
"/usr/sbin", "/usr/local/bin", "/usr/local/sbin",
"/usr/pkg/bin", "/usr/pkg/sbin"
return qw(
/usr/gnu/bin
/bin
/sbin
/usr/bin
/usr/sbin
/usr/local/bin
/usr/local/sbin
/usr/pkg/bin
/usr/pkg/sbin
);
}
return @{$path};
Expand Down
2 changes: 1 addition & 1 deletion lib/Rex/Hardware/Host.pm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ sub get {
else {
my @out = i_run "hostname -f 2>/dev/null", fail_ok => 1;

if ( $? == 0 ) {
if ( $? == 0 && defined $out[0] ) {
( $hostname, $domain ) = split( /\./, $out[0], 2 );
}
else {
Expand Down
3 changes: 2 additions & 1 deletion lib/Rex/Hardware/Memory.pm
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ sub get {
if ( $CHILD_ERROR == 0 ) {
my ($free_cache) =
map { /\D+\d+\s+(\d+)/ } grep { /^Free \(cache/ } @data;
my ($free_list) = map { /\D+\d+\s+(\d+)/ } grep { /^Free \(freel/ } @data;
my ($free_list) =
map { /\D+\d+\s+(\d+)/ } grep { /^Free (\s+|\(freel)/ } @data;
my ($page_cache) = map { /\s+\d+\s+(\d+)/ } grep { /^Page cache/ } @data;

my $free = $free_cache + $free_list;
Expand Down
7 changes: 7 additions & 0 deletions lib/Rex/Inventory/SMBios.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use Data::Dumper;
use Rex::Logger;
use Rex::Commands::Run;
use Rex::Helper::Run;
use English qw(-no_match_vars);

use Rex::Inventory::SMBios::BaseBoard;
use Rex::Inventory::SMBios::Bios;
Expand Down Expand Up @@ -115,6 +116,12 @@ sub _read_smbios {

my @data = i_run( "smbios", fail_ok => 1 );

if ( $CHILD_ERROR != 0 ) {
Rex::Logger::debug('Error running smbios. Output:');
Rex::Logger::debug( join "\n", @data );
return;
}

my ( $current_section, %section, $key, $val, %cur_data );
for my $line (@data) {
next if ( $line =~ /^$/ );
Expand Down
4 changes: 2 additions & 2 deletions lib/Rex/Shared/Var/Common.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ our $LOCK_FILE =
File::Spec->catfile( File::Spec->tmpdir(), "vars.db.lock.$PARENT_PID" );

sub __lock {
sysopen( my $dblock, $LOCK_FILE, O_RDONLY | O_CREAT ) or die($!);
flock( $dblock, LOCK_EX ) or die($!);
sysopen( my $dblock, $LOCK_FILE, O_RDWR | O_CREAT ) or die($!);
flock( $dblock, LOCK_EX ) or die($!);

my $ret = $_[0]->();

Expand Down
63 changes: 37 additions & 26 deletions t/augeas.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ use Test::More;
use Test::Warnings;
use Test::Output;

use English qw(-no_match_vars);
use File::Temp qw(tmpnam);
use Module::Load::Conditional qw(check_install);
use Rex::Commands::Augeas;
use Rex::Commands::Run;

$::QUIET = 1;

my $augeas_binary = 'augtool';
my $augeas_module = 'Config::Augeas';

Expand Down Expand Up @@ -41,51 +44,59 @@ for my $backend (@augeas_backends) {
Rex::Config->set_local_augeas_backend($backend);

subtest "Simplelines lens with $backend" => sub {
plan tests => 7;
TODO: {
local $TODO = undef;

if ( $OSNAME eq 'netbsd' ) {
$TODO = 'Augeas tests fail on NetBSD';
}

plan tests => 7;

Rex::Config->set_augeas_commands_prepend(
[ "transform Simplelines incl $file", 'load', ] );
Rex::Config->set_augeas_commands_prepend(
[ "transform Simplelines incl $file", 'load', ] );

my $path = '/files' . $file . '/1';
my $path = '/files' . $file . '/1';

is( -e $file, undef, 'test file does not exist yet' );
is( -e $file, undef, 'test file does not exist yet' );

# modify
# modify

augeas modify => $path => $test_value;
augeas modify => $path => $test_value;

is( -e $file, 1, 'test file created' );
is( -e $file, 1, 'test file created' );

# exists
# exists

my $has_first_entry = augeas exists => $path;
my $has_first_entry = augeas exists => $path;

is( $has_first_entry, 1, 'first entry exists' );
is( $has_first_entry, 1, 'first entry exists' );

# get
# get

my $retrieved_value = augeas get => $path;
my $retrieved_value = augeas get => $path;

is( $retrieved_value, $test_value, 'test value retrieved' );
is( $retrieved_value, $test_value, 'test value retrieved' );

# dump
# dump

stdout_is(
sub { augeas dump => $path },
qq($path = "$test_value"\n),
'correct dump output'
);
stdout_is(
sub { augeas dump => $path },
qq($path = "$test_value"\n),
'correct dump output'
);

# remove
# remove

augeas remove => $path;
augeas remove => $path;

my $still_has_first_entry = augeas exists => $path;
my $still_has_first_entry = augeas exists => $path;

is( $still_has_first_entry, 0, 'first entry removed' );
is( $still_has_first_entry, 0, 'first entry removed' );

unlink $file;
unlink $file;

is( -e $file, undef, 'test file cleaned up' );
is( -e $file, undef, 'test file cleaned up' );
}
};
}