aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--t/emi_non_mandatory.t240
1 files changed, 240 insertions, 0 deletions
diff --git a/t/emi_non_mandatory.t b/t/emi_non_mandatory.t
new file mode 100644
index 0000000..8aa2c94
--- /dev/null
+++ b/t/emi_non_mandatory.t
@@ -0,0 +1,240 @@
+use Test::More;
+use experimental 'smartmatch';
+
+my @commands;
+my @unlinked;
+
+BEGIN {
+ *CORE::GLOBAL::system = sub {
+ push @commands, @_;
+ return 0;
+ };
+ *CORE::GLOBAL::unlink = sub {
+ push @unlinked, @_;
+ return 1;
+ };
+}
+
+use Iurt::Emi;
+
+my $config = {
+ arch => ['i586', 'x86_64', 'armv5tl'],
+ mandatory_arch => ['i586', 'x86_64'],
+ queue => '.',
+};
+
+my %pkg_tree = (
+ '20160113183431.nobody.valstar.23515' => {
+ 'target' => 'cauldron',
+ 'media' => {
+ 'core/release' => {
+ 'arch' => {
+ 'armv5tl' => 1,
+ 'x86_64' => 1,
+ 'src' => 1
+ },
+ 'rpms' => [
+ 'iurt-test-package-debuginfo-1.4.0-2.mga6.armv5tl.rpm',
+ 'iurt-test-package-1.4.0-2.mga6.armv5tl.rpm',
+ 'iurt-test-package-debuginfo-1.4.0-2.mga6.x86_64.rpm',
+ '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
+ 'iurt-test-package-1.4.0-2.mga6.x86_64.rpm'
+ ],
+ 'path' => '/cauldron/core/release',
+ }
+ },
+ 'rpms' => [
+ 'iurt-test-package-debuginfo-1.4.0-2.mga6.x86_64.rpm',
+ '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
+ 'iurt-test-package-1.4.0-2.mga6.x86_64.rpm',
+ 'iurt-test-package-debuginfo-1.4.0-2.mga6.armv5tl.rpm',
+ 'iurt-test-package-1.4.0-2.mga6.armv5tl.rpm'
+ ],
+ 'srpms' => [
+ '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
+ ],
+ },
+ '20160113183432.nobody.valstar.23515' => {
+ 'target' => 'cauldron',
+ 'media' => {
+ 'core/release' => {
+ 'arch' => {
+ 'armv5tl' => 1,
+ 'i586' => 1,
+ 'x86_64' => 1,
+ 'src' => 1
+ },
+ 'rpms' => [
+ 'iurt-test-package-debuginfo-1.4.0-2.mga6.i586.rpm',
+ '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
+ 'iurt-test-package-1.4.0-2.mga6.i586.rpm',
+ 'iurt-test-package-debuginfo-1.4.0-2.mga6.x86_64.rpm',
+ 'iurt-test-package-1.4.0-2.mga6.x86_64.rpm',
+ 'iurt-test-package-debuginfo-1.4.0-2.mga6.armv5tl.rpm',
+ 'iurt-test-package-1.4.0-2.mga6.armv5tl.rpm'
+ ],
+ 'path' => '/cauldron/core/release',
+ }
+ },
+ 'rpms' => [
+ 'iurt-test-package-debuginfo-1.4.0-2.mga6.i586.rpm',
+ 'iurt-test-package-debuginfo-1.4.0-2.mga6.x86_64.rpm',
+ '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
+ 'iurt-test-package-1.4.0-2.mga6.i586.rpm',
+ 'iurt-test-package-1.4.0-2.mga6.x86_64.rpm',
+ 'iurt-test-package-debuginfo-1.4.0-2.mga6.armv5tl.rpm',
+ 'iurt-test-package-1.4.0-2.mga6.armv5tl.rpm'
+ ],
+ 'srpms' => [
+ '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
+ ],
+ },
+ '20160113183433.nobody.valstar.23515' => {
+ 'target' => 'cauldron',
+ 'media' => {
+ 'core/release' => {
+ 'arch' => {
+ 'armv5tl' => 1,
+ 'x86_64' => 1,
+ 'src' => 1
+ },
+ 'excluded_arch' => {
+ 'i586' => 1
+ },
+ 'rpms' => [
+ 'iurt-test-package-debuginfo-1.4.0-2.mga6.x86_64.rpm',
+ '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
+ 'iurt-test-package-1.4.0-2.mga6.x86_64.rpm',
+ 'iurt-test-package-debuginfo-1.4.0-2.mga6.armv5tl.rpm',
+ 'iurt-test-package-1.4.0-2.mga6.armv5tl.rpm'
+ ],
+ 'path' => '/cauldron/core/release',
+ }
+ },
+ 'rpms' => [
+ 'iurt-test-package-debuginfo-1.4.0-2.mga6.x86_64.rpm',
+ '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
+ 'iurt-test-package-1.4.0-2.mga6.x86_64.rpm',
+ 'iurt-test-package-debuginfo-1.4.0-2.mga6.armv5tl.rpm',
+ 'iurt-test-package-1.4.0-2.mga6.armv5tl.rpm'
+ ],
+ 'srpms' => [
+ '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
+ ],
+ },
+ '20160113183434.nobody.valstar.23515' => {
+ 'target' => 'cauldron',
+ 'media' => {
+ 'core/release' => {
+ 'uploaded' => 1,
+ 'arch' => {
+ 'armv5tl' => 1,
+ 'i586' => 1,
+ 'x86_64' => 1,
+ 'src' => 1
+ },
+ 'rpms' => [
+ 'iurt-test-package-debuginfo-1.4.0-2.mga6.armv5tl.rpm',
+ 'iurt-test-package-1.4.0-2.mga6.armv5tl.rpm',
+ '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
+ ],
+ 'path' => '/cauldron/core/release',
+ }
+ },
+ 'rpms' => [
+ '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
+ 'iurt-test-package-debuginfo-1.4.0-2.mga6.armv5tl.rpm',
+ 'iurt-test-package-1.4.0-2.mga6.armv5tl.rpm'
+ ],
+ 'srpms' => [
+ '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
+ ],
+ },
+ '20160113183435.nobody.valstar.23515' => {
+ 'target' => 'cauldron',
+ 'media' => {
+ 'core/release' => {
+ 'arch' => {
+ 'x86_64' => 1,
+ 'src' => 1
+ },
+ 'excluded_arch' => {
+ 'i586' => 1
+ },
+ 'rpms' => [
+ 'iurt-test-package-debuginfo-1.4.0-2.mga6.x86_64.rpm',
+ '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
+ 'iurt-test-package-1.4.0-2.mga6.x86_64.rpm',
+ ],
+ 'path' => '/cauldron/core/release',
+ }
+ },
+ 'rpms' => [
+ 'iurt-test-package-debuginfo-1.4.0-2.mga6.x86_64.rpm',
+ '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
+ 'iurt-test-package-1.4.0-2.mga6.x86_64.rpm',
+ ],
+ 'srpms' => [
+ '@922855:iurt-test-package-1.4.0-2.mga6.src.rpm',
+ ],
+ },
+);
+
+# ready == currently built rpms should be uploaded
+# srpm_uploaded == the src.rpm should be uploaded (not true for secondary uploads)
+# srpm_unlinked == original src.rpm should be deleted (when all arches are built)
+my %expectations = (
+ '20160113183431.nobody.valstar.23515' => {
+ ready => 0,
+ },
+ '20160113183432.nobody.valstar.23515' => {
+ ready => 1,
+ srpm_unlinked => 1,
+ srpm_uploaded => 1
+ },
+ '20160113183433.nobody.valstar.23515' => {
+ ready => 1,
+ srpm_unlinked => 1,
+ srpm_uploaded => 1
+ },
+ '20160113183434.nobody.valstar.23515' => {
+ ready => 1,
+ srpm_unlinked => 1,
+ srpm_uploaded => 0
+ },
+ '20160113183435.nobody.valstar.23515' => {
+ ready => 1,
+ srpm_unlinked => 0,
+ srpm_uploaded => 1
+ },
+);
+
+my %targets = find_prefixes_ready_to_upload($config, %pkg_tree);
+
+foreach my $prefix (sort keys %expectations) {
+ my $ready = $prefix ~~ @{$targets{'cauldron'}{'core/release'}{'to_upload'}};
+ ok($expectations{$prefix}{ready} == $ready);
+ next unless $expectations{$prefix}{ready};
+
+ @commands = ();
+ @unlinked = ();
+ upload_prefix_in_media($config, \%pkg_tree, $prefix, 'core/release');
+ my $all_uploaded = 1;
+ my $all_unlinked = 1;
+ foreach my $rpm (@{$pkg_tree{$prefix}{media}{'core/release'}{rpms}}) {
+ my $rpmfile = "./done/cauldron/core/release/${prefix}_${rpm}";
+ $all_uploaded = 0 unless @commands ~~ sub {
+ return 1 if !$expectations{$prefix}{srpm_uploaded} && $rpm =~ /\.src\.rpm$/;
+ index(@_[0], $rpmfile) != -1;
+ };
+ $all_unlinked = 0 unless $rpmfile ~~ @unlinked;
+ }
+ ok($all_uploaded);
+ ok($all_unlinked);
+ my $srpms_unlinked = @{$pkg_tree{$prefix}{srpms}} ~~ sub {
+ "./todo/cauldron/core/release/${prefix}_".@_[0] ~~ @unlinked
+ };
+ ok($expectations{$prefix}{srpm_unlinked} == $srpms_unlinked);
+}
+
+done_testing();