Skip to content

Commit

Permalink
fixme
Browse files Browse the repository at this point in the history
  • Loading branch information
exodist committed May 31, 2024
1 parent 250729e commit 1f15e73
Show file tree
Hide file tree
Showing 111 changed files with 2,447 additions and 3,455 deletions.
27 changes: 20 additions & 7 deletions author_tools/regen_schema.pl
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,27 @@

skip_load_external => 1,

moniker_map => sub {
my ($table, $name) = @_;

return "JobTry" if $name eq 'JobTries';
return $name;
},

rel_name_map => sub {
my ($info) = @_;
return "facets" if $info->{name} eq 'facet';
return "orphans" if $info->{name} eq 'orphan';
return "reports" if $info->{name} eq 'reportings';
return "renderings" if $info->{name} eq 'renders';
return "children" if $info->{name} eq 'events' && $info->{local_class} eq 'App::Yath::Schema::Result::Event';
return "parent_event" if $info->{name} eq 'parent';

return 'children'
if $info->{remote_columns}
&& $info->{local_columns}
&& $info->{name} eq 'events'
&& $info->{local_class} eq 'App::Yath::Schema::Result::Event'
&& $info->{remote_class} eq 'App::Yath::Schema::Result::Event'
&& $info->{remote_columns}->[0] eq 'parent_event'
&& $info->{local_columns}->[0] eq 'event_id';

return "coverage" if $info->{name} eq 'coverages';
return "reports" if $info->{name} eq 'reportings';
return $info->{name};
},

Expand All @@ -106,7 +119,7 @@
"InflateColumn::DateTime",
"InflateColumn::Serializer",
"InflateColumn::Serializer::JSON",
"Tree::AdjacencyList",
#"Tree::AdjacencyList",
"UUIDColumns",
],
},
Expand Down
5 changes: 4 additions & 1 deletion dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ DBI = 0
DBIx::Class::UUIDColumns = 0
DBIx::QuickDB = 0.000020
Data::Dumper = 0
Data::UUID = 0
DateTime = 0
DateTime::Format::MySQL = 0
DateTime::Format::Pg = 0
Expand Down Expand Up @@ -200,6 +199,10 @@ System::Info = 0.064
Cpanel::JSON::XS = 0
DBD::Pg = 0
DBD::mysql = 0
UUID = 0.35
Data::UUID = 1.227
UUID::Tiny = 1.04
Data::UUID::MT = 1.001

DBIx::Class::Storage::DBI::MariaDB = 0
DBIx::Class::Storage::DBI::mysql::Retryable = 0
Expand Down
15 changes: 7 additions & 8 deletions lib/App/Yath/Command/db.pm
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ use feature 'state';
use App::Yath::Schema::Util qw/schema_config_from_settings/;
use App::Yath::Schema::UUID qw/gen_uuid/;
use Test2::Harness::Util::UUID qw/gen_uuid/;
use Test2::Harness::Util qw/clean_path/;
Expand Down Expand Up @@ -252,27 +252,26 @@ sub load_file {
$project //= "oops";
unless ($projects{$project}) {
my $p = $config->schema->resultset('Project')->find_or_create({name => $project, project_idx => gen_uuid()});
my $p = $config->schema->resultset('Project')->find_or_create({name => $project});
$projects{$project} = $p;
}
my $logfile = $config->schema->resultset('LogFile')->create({
log_file_idx => gen_uuid(),
name => $file,
local_file => $file =~ m{^/} ? $file : "./demo/$file",
});
state $user = $config->schema->resultset('User')->find_or_create({username => 'root', password => 'root', realname => 'root', user_idx => gen_uuid()});
state $user = $config->schema->resultset('User')->find_or_create({username => 'root', password => 'root', realname => 'root'});
my $run = $config->schema->resultset('Run')->create({
run_id => gen_uuid(),
user_idx => $user->user_idx,
user_id => $user->user_id,
mode => 'complete',
buffer => 'job',
status => 'pending',
project_idx => $projects{$project}->project_idx,
project_id => $projects{$project}->project_id,
log_file_idx => $logfile->log_file_idx,
log_file_id => $logfile->log_file_id,
});
return $run;
Expand Down Expand Up @@ -400,7 +399,7 @@ use App::Yath::Server::Config;
use App::Yath::Schema::Importer;
use App::Yath::Server;
use App::Yath::Schema::UUID qw/gen_uuid/;
use Test2::Harness::Util::UUID qw/gen_uuid/;
use DBIx::QuickDB;
use Plack::Builder;
Expand Down
20 changes: 17 additions & 3 deletions lib/App/Yath/Command/db/publish.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ use warnings;

our $VERSION = '2.000000';

use Time::HiRes qw/time/;

use IO::Uncompress::Bunzip2 qw($Bunzip2Error);
use IO::Uncompress::Gunzip qw($GunzipError);

use App::Yath::Schema::Util qw/schema_config_from_settings/;
use App::Yath::Schema::Util qw/schema_config_from_settings format_duration/;
use Test2::Harness::Util::JSON qw/decode_json/;

use App::Yath::Schema::RunProcessor;
Expand Down Expand Up @@ -72,9 +74,16 @@ sub run {
$project =~ s/^\s+//g;
$project =~ s/\s+$//g;

my $start = time;

my $cb = App::Yath::Schema::RunProcessor->process_lines($settings, project => $project);

my $run = eval { $cb->(scalar(<$fh>)) } or return $self->fail($@);
my $run;
eval {
my $ln = <$fh>;
$run = $cb->($ln);
1
} or return $self->fail($@);

$SIG{INT} = sub {
print STDERR "\nCought SIGINT...\n";
Expand Down Expand Up @@ -104,12 +113,17 @@ sub run {

$cb->();

print "Published Run (status: " . $run->status . ")\n";
my $end = time;

my $dur = format_duration($end - $start);

print "Published Run. [Status: " . $run->status . ", Duration: $dur]\n";

return 0;
}

sub fail {
print STDERR "FAIL!\n\n";
my $self = shift;
my ($err, $run) = @_;

Expand Down
20 changes: 9 additions & 11 deletions lib/App/Yath/Command/server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use feature 'state';
use App::Yath::Server;

use App::Yath::Schema::Util qw/schema_config_from_settings/;
use App::Yath::Schema::UUID qw/gen_uuid/;
use Test2::Harness::Util::UUID qw/gen_uuid/;
use App::Yath::Schema::ImportModes qw/is_mode/;

use Test2::Harness::Util qw/clean_path/;
Expand Down Expand Up @@ -174,14 +174,13 @@ sub load_file {
state $user = $config->schema->resultset('User')->find_or_create({username => 'root', password => 'root', realname => 'root'});

my $run = $config->schema->resultset('Run')->create({
run_id => gen_uuid(),
user_idx => $user->user_idx,
user_id => $user->user_id,
mode => $mode,
buffer => 'job',
status => 'pending',
project_idx => $projects{$project}->project_idx,
project_id => $projects{$project}->project_id,

log_file_idx => $logfile->log_file_idx,
log_file_id => $logfile->log_file_id,
});

return $run;
Expand Down Expand Up @@ -378,7 +377,7 @@ use App::Yath::Server::Config;
use App::Yath::Schema::Importer;
use App::Yath::Server;
use App::Yath::Schema::UUID qw/gen_uuid/;
use Test2::Harness::Util::UUID qw/gen_uuid/;
use DBIx::QuickDB;
use Plack::Builder;
Expand Down Expand Up @@ -457,18 +456,17 @@ sub run {
single_run => 1,
);
my $user = $config->schema->resultset('User')->create({username => 'root', password => 'root', realname => 'root', user_idx => gen_uuid()});
my $proj = $config->schema->resultset('Project')->create({name => 'default', project_idx => gen_uuid()});
my $user = $config->schema->resultset('User')->create({username => 'root', password => 'root', realname => 'root'});
my $proj = $config->schema->resultset('Project')->create({name => 'default'});
$config->schema->resultset('Run')->create({
run_id => gen_uuid(),
user_idx => $user->user_idx,
user_id => $user->user_id,
mode => 'complete',
status => 'pending',
project_idx => $proj->project_idx,
project_id => $proj->project_id,
log_file => {
log_file_idx => gen_uuid(),
name => $self->{+LOG_FILE},
local_file => $self->{+LOG_FILE},
},
Expand Down
8 changes: 4 additions & 4 deletions lib/App/Yath/Options/Publish.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ option_group {group => 'publish', prefix => 'publish', category => "Publish Opti
description => 'When buffering DB writes, force a flush when an event is recieved at least N seconds after the last flush.',
);

option buffering => (
option buffer_size => (
type => 'Scalar',
long_examples => [ ' none', ' job', ' diag', ' run' ],
description => 'Type of buffering to use, if "none" then events are written to the db one at a time, which is SLOW',
default => 'diag',
long_examples => [ ' 100' ],
description => 'Maximum number of events, coverage, or reporting items to buffer before flushing them (each has its own buffer of this size, and each job has its own event buffer of this size)',
default => 100,
);

option retry => (
Expand Down
3 changes: 2 additions & 1 deletion lib/App/Yath/Plugin/DB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;
our $VERSION = '2.000000';

use App::Yath::Schema::Util qw/schema_config_from_settings/;
use Test2::Harness::Util qw/mod2file looks_like_uuid/;
use Test2::Harness::Util qw/mod2file/;
use Test2::Harness::Util::UUID qw/looks_like_uuid/;

use Getopt::Yath;
use parent 'App::Yath::Plugin';
Expand Down
7 changes: 2 additions & 5 deletions lib/App/Yath/Plugin/Git.pm
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,8 @@ sub run_fields {

if ($branch) {
$data{branch} = $branch;

my $short = length($branch) > 20 ? substr($branch, 0, 20) : $branch;

$field->{details} = $short;
$field->{raw} = $branch;
$field->{details} = $branch;
$field->{raw} = $long_sha;
}
else {
$short_sha ||= substr($long_sha, 0, 16);
Expand Down
2 changes: 1 addition & 1 deletion lib/App/Yath/Renderer/DB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use Time::HiRes qw/time/;
use Test2::Harness::Util qw/clean_path/;
use Test2::Harness::IPC::Util qw/start_process/;
use Test2::Harness::Util::JSON qw/encode_ascii_json/;
use App::Yath::Schema::UUID qw/gen_uuid/;
use Test2::Harness::Util::UUID qw/gen_uuid/;

use parent 'App::Yath::Renderer';
use Test2::Harness::Util::HashBase qw{
Expand Down
2 changes: 1 addition & 1 deletion lib/App/Yath/Renderer/Server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use App::Yath::Schema::RunProcessor;
use Test2::Util qw/pkg_to_file/;
use Test2::Harness::Util qw/mod2file/;
use App::Yath::Server::Util qw/share_dir share_file dbd_driver qdb_driver/;
use App::Yath::Schema::UUID qw/gen_uuid/;
use Test2::Harness::Util::UUID qw/gen_uuid/;

use DBIx::QuickDB;
use Plack::Builder;
Expand Down
27 changes: 9 additions & 18 deletions lib/App/Yath/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ use strict;
use warnings;
use Carp qw/confess/;

use App::Yath::Schema::UUID qw/uuid_inflate/;

use Test2::Harness::Util::UUID qw/gen_uuid/;

our $VERSION = '2.000000';

use base 'DBIx::Class::Schema';
Expand Down Expand Up @@ -42,42 +38,37 @@ sub vague_run_search {
my ($project, $run, $user);

my $query = $params{query} // {status => 'complete'};
my $attrs = $params{attrs} // {order_by => {'-desc' => 'run_idx'}, rows => 1};
my $attrs = $params{attrs} // {order_by => {'-desc' => 'run_id'}, rows => 1};

$attrs->{offset} = $params{idx} if $params{idx};

if (my $username = $params{username}) {
$user = $self->resultset('User')->find({username => $username}) || die "Invalid Username ($username)";
$query->{user_idx} = $user->user_idx;
$query->{user_id} = $user->user_id;
}

if (my $project_name = $params{project_name}) {
$project = $self->resultset('Project')->find({name => $project_name}) || die "Invalid Project ($project)";
$query->{project_idx} = $project->project_idx;
$query->{project_id} = $project->project_id;
}

if (my $source = $params{source}) {
my $uuid = uuid_inflate($source);

if ($uuid) {
$run = $self->resultset('Run')->find({%$query, run_id => $uuid}, $attrs);
return $run if $run;
}
my $run = $self->resultset('Run')->find_by_id_or_uuid($source, $query, $attrs);
return $run if $run;

if (my $p = $self->resultset('Project')->find({name => $source})) {
die "Project mismatch ($source)"
if $project && $project->project_idx ne $p->project_idx;
if $project && $project->project_id ne $p->project_id;

$query->{project_idx} = $p->project_idx;
$query->{project_id} = $p->project_id;
}
elsif (my $u = $self->resultset('User')->find({username => $source})) {
die "User mismatch ($source)"
if $user && $user->user_idx ne $u->user_idx;
if $user && $user->user_id ne $u->user_id;

$query->{user_idx} = $u->user_idx;
$query->{user_id} = $u->user_id;
}
else {
die "No UUID match in runs ($uuid)" if $uuid;
die "No match for source ($source)";
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/App/Yath/Schema/Dumper.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ our $VERSION = '2.000000';

use App::Yath::Schema::Util qw/format_duration/;
use Test2::Harness::Util::JSON qw/encode_json/;
use App::Yath::Schema::UUID qw/uuid_inflate/;

use Time::HiRes qw/time/;
use Parallel::Runner;
use IO::Compress::Bzip2;
Expand Down Expand Up @@ -95,7 +95,7 @@ sub dump {
|| ($spec->{data_type} eq 'binary' && $spec->{size} == 16)
|| ($spec->{data_type} eq 'char' && $spec->{size} == 36);

$data{$col} = defined($data{$col}) ? uuid_inflate($data{$col})->string : undef;
$data{$col} = defined($data{$col}) ? $data{$col} : undef;
}

print $fh encode_json(\%data), "\n";
Expand Down
9 changes: 5 additions & 4 deletions lib/App/Yath/Schema/ImportModes.pm
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ sub record_all_events {

my $mode = _get_mode(%params);

my $job = $params{job};
my $try = $params{try};
my $job = $params{job} // $try ? $try->job : undef;
my $fail = $params{fail};
my $is_harness_out = $params{is_harness_out};

croak "must specify either 'job' or 'fail' and 'is_harness_out'"
unless $job || (defined($fail) && defined($is_harness_out));
croak "must specify either 'try' or 'fail' and 'is_harness_out'"
unless $try || (defined($fail) && defined($is_harness_out));

# Always true in complete mode
return 1 if $mode >= $MODES{complete};
Expand All @@ -86,7 +87,7 @@ sub record_all_events {
return 1 if $is_harness_out;

# QVF and QVFD are all events when failing
$fail //= $job->fail;
$fail //= $try->fail;
return 1 if $fail && $mode >= $MODES{qvf};

return 0;
Expand Down
Loading

0 comments on commit 1f15e73

Please sign in to comment.