Author: sandervanderburg
Date: Mon Feb 21 14:35:42 2011
New Revision: 26041
URL: https://svn.nixos.org/websvn/nix/?rev=26041&sc=1
Log:
Added testcases for mapListOnAttr and minset cover approximation
Added:
disnix/dydisnix/trunk/tests/qos/qos-maplistonattr.nix
disnix/dydisnix/trunk/tests/qos/qos-minsetcover.nix
disnix/dydisnix/trunk/tests/qos/qos-minsetcover2.nix
Modified:
disnix/dydisnix/trunk/release.nix
disnix/dydisnix/trunk/tests/infrastructure.nix
disnix/dydisnix/trunk/tests/services.nix
Modified: disnix/dydisnix/trunk/release.nix
==============================================================================
--- disnix/dydisnix/trunk/release.nix Mon Feb 21 10:24:42 2011 (r26040)
+++ disnix/dydisnix/trunk/release.nix Mon Feb 21 14:35:42 2011 (r26041)
@@ -124,6 +124,38 @@
die "line 20 should contain testtarget2!\n";
}
+ # Execute the mapListOnAttr method to map requiredZones onto zones.
+ # testService1 must be assigned to testtarget1. testService2 must be
+ # assigned to testtarget2. testService3 must be assigned to both
+ # machines. This test should succeed.
+
+ my $result =
$machine->mustSucceed("NIXPKGS_ALL=${nixpkgs}/pkgs/top-level/all-packages.nix
dydisnix-gendist -s ${tests}/services.nix -i ${tests}/infrastructure.nix -q
${tests}/qos/qos-maplistonattr.nix");
+ my @distribution = split('\n', $machine->mustSucceed("cat
$result"));
+
+ if(@distribution[7] =~ /testtarget1/) {
+ print "line 7 contains testtarget1!\n";
+ } else {
+ die "line 7 should contain testtarget1!\n";
+ }
+
+ if(@distribution[12] =~ /testtarget2/) {
+ print "line 12 contains testtarget2!\n";
+ } else {
+ die "line 12 should contain testtarget2!\n";
+ }
+
+ if(@distribution[17] =~ /testtarget1/) {
+ print "line 17 contains testtarget1!\n";
+ } else {
+ die "line 17 should contain testtarget1!\n";
+ }
+
+ if(@distribution[18] =~ /testtarget2/) {
+ print "line 18 contains testtarget2!\n";
+ } else {
+ die "line 18 should contain testtarget2!\n";
+ }
+
# Execute the greedy division method. testService1 and testService2
# should be assigned to testtarget2. testService3 should be assigned
# to testtarget1. This test should succeed.
@@ -199,6 +231,39 @@
} else {
die "line 17 should contain testtarget2!\n";
}
+
+ # Execute minimum set cover approximation method, by looking to the
+ # cost attribute in the infrastructure model. All services should
+ # be distributed to testtarget1.
+
+ my $result =
$machine->mustSucceed("NIXPKGS_ALL=${nixpkgs}/pkgs/top-level/all-packages.nix
dydisnix-gendist -s ${tests}/services.nix -i ${tests}/infrastructure.nix -q
${tests}/qos/qos-minsetcover.nix");
+ my @distribution = split('\n', $machine->mustSucceed("cat
$result"));
+
+ if(@distribution[7] =~ /testtarget1/) {
+ print "line 7 contains testtarget1!\n";
+ } else {
+ print "line 7 should contain testtarget1!\n";
+ }
+
+ if(@distribution[12] =~ /testtarget1/) {
+ print "line 12 contains testtarget1!\n";
+ } else {
+ die "line 12 should contain testtarget1!\n";
+ }
+
+ if(@distribution[17] =~ /testtarget1/) {
+ print "line 17 contains testtarget1!\n";
+ } else {
+ die "line 17 should contain testtarget1!\n";
+ }
+
+ # Execute minimum set cover approximation method, by looking to the
+ # cost attribute in the infrastructure model. All services should
+ # be distributed to testtarget1.
+
+ my $result =
$machine->mustSucceed("NIXPKGS_ALL=${nixpkgs}/pkgs/top-level/all-packages.nix
dydisnix-gendist -s ${tests}/services.nix -i ${tests}/infrastructure.nix -q
${tests}/qos/qos-minsetcover2.nix");
+ print("result is: $result\n");
+ $machine->mustSucceed("(cat $result) >&2");
'';
};
};
Modified: disnix/dydisnix/trunk/tests/infrastructure.nix
==============================================================================
--- disnix/dydisnix/trunk/tests/infrastructure.nix Mon Feb 21 10:24:42
2011 (r26040)
+++ disnix/dydisnix/trunk/tests/infrastructure.nix Mon Feb 21 14:35:42
2011 (r26041)
@@ -4,6 +4,8 @@
supportedTypes = [ "echo" "process" "wrapper" ];
mem = 524288;
zone = "US";
+ cost = 100;
+ access = "public";
};
testtarget2 = {
@@ -11,5 +13,7 @@
supportedTypes = [ "echo" "process" "wrapper" ];
mem = 655360;
zone = "Europe";
+ cost = 200;
+ access = "private";
};
}
Added: disnix/dydisnix/trunk/tests/qos/qos-maplistonattr.nix
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ disnix/dydisnix/trunk/tests/qos/qos-maplistonattr.nix Mon Feb 21
14:35:42 2011 (r26041)
@@ -0,0 +1,8 @@
+{services, infrastructure, initialDistribution, previousDistribution, filters}:
+
+filters.mapListOnAttr {
+ inherit services infrastructure;
+ distribution = initialDistribution;
+ servicePropertyList = "requireZones";
+ targetProperty = "zone";
+}
Added: disnix/dydisnix/trunk/tests/qos/qos-minsetcover.nix
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ disnix/dydisnix/trunk/tests/qos/qos-minsetcover.nix Mon Feb 21 14:35:42
2011 (r26041)
@@ -0,0 +1,7 @@
+{services, infrastructure, initialDistribution, previousDistribution, filters}:
+
+filters.minsetcover {
+ inherit services infrastructure;
+ distribution = initialDistribution;
+ targetProperty = "cost";
+}
Added: disnix/dydisnix/trunk/tests/qos/qos-minsetcover2.nix
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ disnix/dydisnix/trunk/tests/qos/qos-minsetcover2.nix Mon Feb 21
14:35:42 2011 (r26041)
@@ -0,0 +1,14 @@
+{services, infrastructure, initialDistribution, previousDistribution, filters}:
+
+filters.minsetcover {
+ inherit services infrastructure;
+
+ distribution = filters.mapListOnAttr {
+ inherit services infrastructure;
+ distribution = initialDistribution;
+ servicePropertyList = "requireAccess";
+ targetProperty = "access";
+ };
+
+ targetProperty = "cost";
+}
Modified: disnix/dydisnix/trunk/tests/services.nix
==============================================================================
--- disnix/dydisnix/trunk/tests/services.nix Mon Feb 21 10:24:42 2011
(r26040)
+++ disnix/dydisnix/trunk/tests/services.nix Mon Feb 21 14:35:42 2011
(r26041)
@@ -9,7 +9,9 @@
pkg = customPkgs.testService1;
type = "echo";
requireZone = "US";
+ requireZones = [ "US" "Asia" ];
requireMem = 262144;
+ requireAccess = [ "public" "private" ];
};
testService2 = {
@@ -20,7 +22,9 @@
};
type = "echo";
requireZone = "US";
+ requireZones = [ "Europe" "Asia" ];
requireMem = 262143;
+ requireAccess = [ "public" "private" ];
};
testService3 = {
@@ -31,6 +35,8 @@
};
type = "echo";
requireZone = "Europe";
+ requireZones = [ "US" "Europe" ];
requireMem = 262145;
+ requireAccess = [ "private" ];
};
}
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits