Skip to content

Commit

Permalink
add testbench script for remotebackend development, thanks Aki. Closes
Browse files Browse the repository at this point in the history
…PowerDNS#742

git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@3171 d19b8d6e-7fed-0310-83ef-9ca221ded41b
  • Loading branch information
Peter van Dijk committed Apr 22, 2013
1 parent a8e2afd commit 62b38b0
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions contrib/remotebackend-pipe-test.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/perl
### This script is intended for testing/developing remotebackend scripts
### To use, please install libjson-any-perl (JSON::Any) and libjson-xs-perl (JSON::XS)
### (c) Aki Tuomi 2013 - Distributed under same license as PowerDNS Authoritative Server
use strict;
use warnings;
use 5.005;
use IPC::Open2;
use JSON::Any;

### CONFIGURATION SECTION

## Full path to your remotebackend script
my $script = "/home/cmouse/projects/pdns-v6-autorev/rev.pl";

## These are used to send initialize method before your actual code
my $initparams = { value => "foo", value2 => "bar" };

## END CONFIGURATION

$|=1;
my $in;
my $out;
my $pid = open2($in,$out,$script);

my $j = JSON::Any->new;

sub rpc {
my $meth = shift;
my %p = @_;

print $j->encode({method => $meth, parameters => \%p}),"\r\n";
print $out $j->encode({method => $meth, parameters => \%p}),"\r\n";
my $res = <$in>;
if ($res) {
chomp $res;
print $res,"\n";
}
}

rpc 'initialize', %$initparams;

if (@ARGV>1) {

## this lets you call whatever method with simple parameters
## like this:

# perl remotebackend-pipe-test.pl lookup qtype SOA qname powerdns.com

## this will execute
## {"parameters":{"qname":"powerdns.com","qtype":"SOA"},"method":"lookup"}
## on your remotebackend

my $meth = shift;
rpc $meth, @ARGV;


} else {

## Put whatever you want to run here. Or leave it empty if you
## only want to use the command line

#rpc 'lookup', qname => 'powerdns.com', qtype => 'SOA';

}

0 comments on commit 62b38b0

Please sign in to comment.