summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rwxr-xr-xt/00-ping-from-dev.t18
-rwxr-xr-xt/01-ssh-from-dev.t36
-rwxr-xr-xt/lib/FAPG/TestSupport.pm55
3 files changed, 109 insertions, 0 deletions
diff --git a/t/00-ping-from-dev.t b/t/00-ping-from-dev.t
new file mode 100755
index 0000000..583db09
--- /dev/null
+++ b/t/00-ping-from-dev.t
@@ -0,0 +1,18 @@
+#!/usr/bin/env perl
+# -*- mode: perl-ts; -*-
+
+use 5.32.0;
+use strict;
+use warnings;
+
+use FindBin;
+use lib "${FindBin::Bin}/lib";
+use Test2::V0;
+use FAPG::TestSupport qw(@HOSTS);
+
+foreach my $h (@HOSTS) {
+ my $cmd = "ping -c 1 $h->{hostname} &> /dev/null";
+ ok system($cmd) == 0, "host $h->{hostname} can be pinged";
+}
+
+done_testing();
diff --git a/t/01-ssh-from-dev.t b/t/01-ssh-from-dev.t
new file mode 100755
index 0000000..d86649d
--- /dev/null
+++ b/t/01-ssh-from-dev.t
@@ -0,0 +1,36 @@
+#!/usr/bin/env perl
+# -*- mode: perl-ts; -*-
+
+use 5.32.0;
+use strict;
+use warnings;
+
+use FindBin;
+use lib "${FindBin::Bin}/lib";
+use Test2::V0;
+use FAPG::TestSupport qw(@HOSTS);
+use Net::SSH::Perl;
+
+foreach my $h (@HOSTS) {
+ my ( $out, $err, $exit );
+ my $timeout = 5;
+
+ my $ok = eval {
+ local $SIG{ALRM} = sub { die "SSH timeout after $timeout seconds.\n" };
+ alarm $timeout;
+
+ my $ssh = Net::SSH::Perl->new( $h->{hostname});
+ $ssh->login( $h->{user}, $h->{password} );
+ ( $out, $err, $exit ) = $ssh->cmd('true');
+
+ 1;
+ };
+
+ alarm 0;
+
+ ok $ok, "host $h->{hostname} can be reached via ssh";
+ diag $@ if $@;
+
+}
+
+done_testing();
diff --git a/t/lib/FAPG/TestSupport.pm b/t/lib/FAPG/TestSupport.pm
new file mode 100755
index 0000000..b7cd773
--- /dev/null
+++ b/t/lib/FAPG/TestSupport.pm
@@ -0,0 +1,55 @@
+#!/usr/bin/env perl
+# -*- mode: perl-ts; -*-
+
+package FAPG::TestSupport;
+
+use strict;
+use warnings;
+use Exporter 'import';
+
+our @EXPORT_OK = qw(
+ @HOSTS
+);
+
+our @HOSTS = (
+ {
+ user => 'pirou',
+ hostname => 'fapg-daq-five-01',
+ password => 'pipirou',
+ mqtt_from_vps => '10.77.0.2',
+ },
+ {
+ hostname => 'vps',
+ user => 'mpeter',
+ },
+ {
+ hostname => 'fapg-daq-zero-ph-01',
+ user => 'pirou',
+ password => 'pipirou',
+ probe => 'ph',
+ unit => 'pH',
+ },
+ {
+ hostname => 'fapg-daq-zero-do-01',
+ user => 'pirou',
+ password => 'pipirou',
+ probe => 'do',
+ unit => 'mg/L',
+ },
+ {
+ hostname => 'fapg-daq-zero-orp-01',
+ user => 'pirou',
+ password => 'pipirou',
+ probe => 'redox',
+ unit => 'mV',
+ },
+ {
+ hostname => 'fapg-daq-zero-ec-01',
+ user => 'pirou',
+ password => 'pipirou',
+ probe => 'ec',
+ unit => 'uS/cm',
+ },
+);
+
+1;
Copyright 2019--2026 Marius PETER