diff --git a/lib/Pogo/Engine/Namespace.pm b/lib/Pogo/Engine/Namespace.pm index 81359ef..2ef6b28 100644 --- a/lib/Pogo/Engine/Namespace.pm +++ b/lib/Pogo/Engine/Namespace.pm @@ -244,6 +244,8 @@ sub fetch_all_slots { $hostslots{$hostname} = []; + #$DB::single = 1; + foreach my $app ( @{ $hostinfo->{apps} } ) { foreach my $envtype ( keys %{ $hostinfo->{envs} } ) @@ -267,10 +269,10 @@ sub fetch_all_slots } push @{ $hostslots{$hostname} }, $slot; - next unless exists $const->{$app} and - exists $const->{$app}->{$envtype}; + next unless exists $const->{$envtype} and + exists $const->{$envtype}->{$app}; - my $concur = $const->{$app}->{$envtype}; + my $concur = $const->{$envtype}->{$app}; if ( $concur !~ m{^(\d+)%$} ) { # not a percentage, a literal @@ -425,6 +427,8 @@ sub set_conf delete $conf_in->{envs}; + #$DB::single = 1; + # constraint processing foreach my $c_env_type ( keys %{ $conf_in->{constraints} } ) { @@ -467,9 +471,8 @@ sub set_conf # $second requires $first to go first within $env # $first is a predecessor of $second # $second is a successor of $first - # we just make sure these exist, don't define them - $conf->{seq}->{pred}->{$c_env_type}->{$second}->{$first}; - $conf->{seq}->{succ}->{$c_env_type}->{$first}->{$second}; + $conf->{seq}->{pred}->{$c_env_type}->{$second}->{$first} = 1; + $conf->{seq}->{succ}->{$c_env_type}->{$first}->{$second} = 1; } } @@ -628,7 +631,7 @@ sub get_cur { my ( $self, $app, $key ) = @_; my $c = store->get( $self->{path} . "/conf/cur/$app/$key" ); - return $c; + return JSON->new->utf8->allow_nonref->decode($c); } sub get_curs @@ -648,6 +651,23 @@ sub get_all_curs return { map { $_ => $self->get_curs($_) } store->get_children($path) }; } +sub app_members { + my $self = shift; + my $app = shift; + + my $path = $self->{path} . "/conf/apps/$app"; + return store->get_children("$path"); +} + +sub env_members { + my $self = shift; + my $envtype = shift; + my $envvalue = shift; + + my $path = $self->{path} . "/conf/envs/$envtype/$envvalue"; + return store->get_children("$path"); +} + sub get_all_seqs { my $self = shift; @@ -920,8 +940,8 @@ Env settings: Sequences: - /pogo/ns/nsname/conf/seq/pred/coast/frontend: [] - /pogo/ns/nsname/conf/seq/succ/coast/backend: [] + /pogo/ns/nsname/conf/seq/pred/coast/frontend/backend + /pogo/ns/nsname/conf/seq/succ/coast/backend/frontend And even the plugin gets stored: diff --git a/t/13_unit_constrained.t b/t/13_unit_constrained.t index b947a4b..77e53e4 100644 --- a/t/13_unit_constrained.t +++ b/t/13_unit_constrained.t @@ -49,7 +49,7 @@ use File::Basename; use Pogo::Engine::Store qw(store); use Data::Dumper; -# Log::Log4perl->easy_init({ level => $DEBUG, layout => "%F{1}-%L-%M: %m%n" }); +Log::Log4perl->easy_init({ level => $DEBUG, layout => "%F{1}-%L-%M: %m%n" }); my $ns = Pogo::Engine::Namespace->new( nsname => "wonk", @@ -135,29 +135,30 @@ my $job = Pogo::Engine::Job->new({ exe_data => "wonk", }); +$job->start( + sub { ok 0, "err cont on start(): @_" }, + sub { ok 1, "success cont on start()"; + my($nqueued, $nwaiting) = @_; + is($nqueued, 4, "4 hosts enqueued"); + is($nwaiting, 0, "0 hosts waiting"); + }, +); + $ns->fetch_runnable_hosts( $job, $host_meta, sub { die "err cont: ", Dumper( \@_ ); }, sub { $result = \@_; + print "result=", Dumper( \@_ ); }, ); ok(1, "at the end" ); -# print store->_dump(); +print store->_dump(); __END__ -$job->start( - sub { ok 0, "err cont on start(): @_" }, - sub { ok 1, "success cont on start()"; - my($nqueued, $nwaiting) = @_; - is($nqueued, 4, "4 hosts enqueued"); - is($nwaiting, 0, "0 hosts waiting"); - }, -); - print Dumper($result); __END__ diff --git a/t/conf/example.yaml b/t/conf/example.yaml index 7b2c63a..46b58fa 100644 --- a/t/conf/example.yaml +++ b/t/conf/example.yaml @@ -10,6 +10,8 @@ apps: backend: - bar[1-10].east.example.com - bar[1-10].west.example.com + tail: + - zar[1-10].west.example.com envs: coast: @@ -26,4 +28,4 @@ constraints: - frontend: 25% - backend: 1 sequence: - - [ backend, frontend ] + - [ backend, frontend, tail ]