Author: sandervanderburg
Date: Sat Feb 19 13:24:22 2011
New Revision: 26031
URL: https://svn.nixos.org/websvn/nix/?rev=26031&sc=1

Log:
Some testcases for the mapAttr functions

Added:
   disnix/dydisnix/trunk/tests/qos/qos-mapattronattr.nix
   disnix/dydisnix/trunk/tests/qos/qos-mapattronlist.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   Sat Feb 19 09:56:35 2011        (r26030)
+++ disnix/dydisnix/trunk/release.nix   Sat Feb 19 13:24:22 2011        (r26031)
@@ -55,6 +55,75 @@
              };
          };
          testScript = ''
+           # Execute the mapAttrOnAttr method to map requireZone onto zone.
+           # testService1 should be assigned to testtarget1. testService2 and
+           # testService3 should be assigned to testtarget2. 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-mapattronattr.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] =~ /testtarget1/) {
+               print "line 12 contains testtarget1!\n";
+           } else {
+               die "line 12 should contain testtarget1!\n";
+           }
+           
+           if(@distribution[17] =~ /testtarget2/) {
+               print "line 17 contains testtarget2!\n";
+           } else {
+               die "line 17 should contain testtarget2!\n";
+           }
+         
+           # Execute the mapAttrOnList method to map types onto supportedTypes.
+           # All services must be assigned to both testtarget1 and testtarget2.
+           # 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-mapattronlist.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[8] =~ /testtarget2/) {
+               print "line 8 contains testtarget2!\n";
+           } else {
+               die "line 8 should contain testtarget2!\n";
+           }
+           
+           if(@distribution[13] =~ /testtarget1/) {
+               print "line 13 contains testtarget1!\n";
+           } else {
+               die "line 13 should contain testtarget1!\n";
+           }
+           
+           if(@distribution[14] =~ /testtarget2/) {
+               print "line 14 contains testtarget1!\n";
+           } else {
+               die "line 14 should contain testtarget1!\n";
+           }
+           
+           if(@distribution[19] =~ /testtarget1/) {
+               print "line 19 contains testtarget1!\n";
+           } else {
+               die "line 19 should contain testtarget1!\n";
+           }
+           
+           if(@distribution[20] =~ /testtarget2/) {
+               print "line 20 contains testtarget2!\n";
+           } else {
+               die "line 20 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.

Modified: disnix/dydisnix/trunk/tests/infrastructure.nix
==============================================================================
--- disnix/dydisnix/trunk/tests/infrastructure.nix      Sat Feb 19 09:56:35 
2011        (r26030)
+++ disnix/dydisnix/trunk/tests/infrastructure.nix      Sat Feb 19 13:24:22 
2011        (r26031)
@@ -3,11 +3,13 @@
     hostname = "testtarget1";
     supportedTypes = [ "echo" "process" "wrapper" ];
     mem = 524288;
+    zone = "US";
   };
   
   testtarget2 = {
     hostname = "testtarget2";
     supportedTypes = [ "echo" "process" "wrapper" ];
     mem = 655360;
+    zone = "Europe";
   };
 }

Added: disnix/dydisnix/trunk/tests/qos/qos-mapattronattr.nix
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ disnix/dydisnix/trunk/tests/qos/qos-mapattronattr.nix       Sat Feb 19 
13:24:22 2011        (r26031)
@@ -0,0 +1,8 @@
+{services, infrastructure, initialDistribution, previousDistribution, filters}:
+
+filters.mapAttrOnAttr {
+  inherit services infrastructure;
+  distribution = initialDistribution;
+  serviceProperty = "requireZone";
+  targetProperty = "zone";
+}

Added: disnix/dydisnix/trunk/tests/qos/qos-mapattronlist.nix
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ disnix/dydisnix/trunk/tests/qos/qos-mapattronlist.nix       Sat Feb 19 
13:24:22 2011        (r26031)
@@ -0,0 +1,8 @@
+{services, infrastructure, initialDistribution, previousDistribution, filters}:
+
+filters.mapAttrOnList {
+  inherit services infrastructure;
+  distribution = initialDistribution;
+  serviceProperty = "type";
+  targetPropertyList = "supportedTypes";
+}

Modified: disnix/dydisnix/trunk/tests/services.nix
==============================================================================
--- disnix/dydisnix/trunk/tests/services.nix    Sat Feb 19 09:56:35 2011        
(r26030)
+++ disnix/dydisnix/trunk/tests/services.nix    Sat Feb 19 13:24:22 2011        
(r26031)
@@ -8,6 +8,7 @@
     name = "testService1";
     pkg = customPkgs.testService1;
     type = "echo";
+    requireZone = "US";
     requireMem = 262144;
   };
   
@@ -18,6 +19,7 @@
       inherit testService1;
     };
     type = "echo";
+    requireZone = "US";
     requireMem = 262143;
   };
   
@@ -28,6 +30,7 @@
       inherit testService1 testService2;
     };
     type = "echo";
+    requireZone = "Europe";
     requireMem = 262145;
   };
 }
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

Reply via email to