Skip to content

Commit

Permalink
Fix Autoyast merge fallout found by tests.
Browse files Browse the repository at this point in the history
- test old Import as ImportAny (passing a list)
- Export now produces a map
  • Loading branch information
mvidner committed Jul 30, 2013
1 parent b516c8c commit 8d7557f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 41 deletions.
20 changes: 12 additions & 8 deletions src/modules/Nfs.ycp
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,7 @@
});
}

/**
* Get all NFS configuration from a map.
* When called by nfs_auto (preparing autoinstallation data)
* the map may be empty.
* @param settings a map($) of nfs_entries
* @return success
*/
global boolean Import (map <string, any> settings) {
boolean ImportAny (any settings) {
// ($) since oS-1x.x, settings was changed to be a map,
// which is incompatible with the sle profiles;
// it owuld be nice to make it compatible again
Expand Down Expand Up @@ -203,6 +196,17 @@
return true;
}

/**
* Get all NFS configuration from a map.
* When called by nfs_auto (preparing autoinstallation data)
* the map may be empty.
* @param settings a map($) of nfs_entries
* @return success
*/
global boolean Import (map <string, any> settings) {
return ImportAny(settings);
}

/**
* Dump the NFS settings to a map, for autoinstallation use.
* @return a list of nfs entries.
Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/autoyast.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ Dump Nfs::Import
Dump - basic, SLE11-SP2
Read .sysconfig.nfs.NFS4_SUPPORT "no"
Read .sysconfig.nfs.NFS_SECURITY_GSS "no"
Read .etc.idmapd_conf "Domain" "localdomain"
Read .etc.idmapd_conf.value.General.Domain "localdomain"
Return true
Dump -- and Export
Dump - empty
Read .sysconfig.nfs.NFS4_SUPPORT "no"
Read .sysconfig.nfs.NFS_SECURITY_GSS "no"
Read .etc.idmapd_conf "Domain" "localdomain"
Read .etc.idmapd_conf.value.General.Domain "localdomain"
Return true
Dump - invalid, missing basic data
Log Missing at Import: 'mount_point'.
Expand Down
66 changes: 35 additions & 31 deletions testsuite/tests/autoyast.ycp
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,25 @@
];

TEST (``(
Nfs::Import([ entry1 ])
Nfs::ImportAny([ entry1 ])
), [READ, $[], $[]], nil);
Assert::Equal(1, size(Nfs::nfs_entries));
Assert::Equal("data.example.com:/mirror", Nfs::nfs_entries[0, "spec"]:"");

DUMP("-- and Export");
list e = Nfs::Export();
Assert::Equal(2, size(e));
Assert::Equal(true, haskey(e[0]:$[], "enable_nfs4"));
Assert::Equal(true, haskey(e[0]:$[], "idmapd_domain"));
Assert::Equal("data.example.com:/mirror", e[1, "server_path"]:"");
Assert::Equal("/mirror", e[1, "mount_point"]:"");
Assert::Equal("defaults", e[1, "nfs_options"]:"");
map ex = Nfs::Export();
list e = ex["nfs_entries"]:[];
Assert::Equal(1, size(e));
Assert::Equal(true, haskey(ex, "enable_nfs4"));
Assert::Equal(true, haskey(ex, "idmapd_domain"));
Assert::Equal("data.example.com:/mirror", e[0, "server_path"]:"");
Assert::Equal("/mirror", e[0, "mount_point"]:"");
Assert::Equal("defaults", e[0, "nfs_options"]:"");

// ---------
DUMP("- empty");
TEST (``(
Nfs::Import([])
Nfs::ImportAny([])
), [READ, $[], $[]], nil);
Assert::Equal(0, size(Nfs::nfs_entries));

Expand All @@ -61,7 +62,7 @@
"server_path": "data.example.com:/mirror",
];

Nfs::Import([ entry_invalid ]);
Nfs::ImportAny([ entry_invalid ]);
Assert::Equal(0, size(Nfs::nfs_entries));

// ---------
Expand All @@ -71,7 +72,7 @@
"idmapd_domain": "example.com"
];
TEST (``(
Nfs::Import([
Nfs::ImportAny([
global_options,
entry1
])
Expand All @@ -82,13 +83,14 @@
Assert::Equal("data.example.com:/mirror", Nfs::nfs_entries[0, "spec"]:"");

DUMP("-- and Export");
e = Nfs::Export();
Assert::Equal(2, size(e));
Assert::Equal(true, e[0, "enable_nfs4"]:false);
Assert::Equal("example.com", e[0, "idmapd_domain"]:"");
Assert::Equal("data.example.com:/mirror", e[1, "server_path"]:"");
Assert::Equal("/mirror", e[1, "mount_point"]:"");
Assert::Equal("defaults", e[1, "nfs_options"]:"");
ex = Nfs::Export();
e = ex["nfs_entries"]:[];
Assert::Equal(1, size(e));
Assert::Equal(true, ex["enable_nfs4"]:false);
Assert::Equal("example.com", ex["idmapd_domain"]:"");
Assert::Equal("data.example.com:/mirror", e[0, "server_path"]:"");
Assert::Equal("/mirror", e[0, "mount_point"]:"");
Assert::Equal("defaults", e[0, "nfs_options"]:"");

// ---------
DUMP("- NFSv4 via vfstype");
Expand All @@ -103,7 +105,7 @@
];

TEST (``(
Nfs::Import([
Nfs::ImportAny([
global_options2,
entry2
])
Expand All @@ -115,13 +117,14 @@
Assert::Equal("data.example.com:/mirror", Nfs::nfs_entries[0, "spec"]:"");

DUMP("-- and Export");
e = Nfs::Export();
Assert::Equal(2, size(e));
Assert::Equal(true, e[0, "enable_nfs4"]:false);
Assert::Equal("example.com", e[0, "idmapd_domain"]:"");
Assert::Equal("data.example.com:/mirror", e[1, "server_path"]:"");
Assert::Equal("/mirror", e[1, "mount_point"]:"");
Assert::Equal("defaults", e[1, "nfs_options"]:"");
ex = Nfs::Export();
e = ex["nfs_entries"]:[];
Assert::Equal(1, size(e));
Assert::Equal(true, ex["enable_nfs4"]:false);
Assert::Equal("example.com", ex["idmapd_domain"]:"");
Assert::Equal("data.example.com:/mirror", e[0, "server_path"]:"");
Assert::Equal("/mirror", e[0, "mount_point"]:"");
Assert::Equal("defaults", e[0, "nfs_options"]:"");

// ---------
DUMP("- with GSS");
Expand All @@ -131,7 +134,7 @@
"idmapd_domain": "example.com"
];
TEST (``(
Nfs::Import([
Nfs::ImportAny([
global_options,
entry1
])
Expand All @@ -142,8 +145,9 @@
Assert::Equal("data.example.com:/mirror", Nfs::nfs_entries[0, "spec"]:"");

DUMP("-- and Export");
e = Nfs::Export();
Assert::Equal(2, size(e));
Assert::Equal(true, e[0, "enable_nfs_gss"]:false);
Assert::Equal("data.example.com:/mirror", e[1, "server_path"]:"");
ex = Nfs::Export();
e = ex["nfs_entries"]:[];
Assert::Equal(1, size(e));
Assert::Equal(true, ex["enable_nfs_gss"]:false);
Assert::Equal("data.example.com:/mirror", e[0, "server_path"]:"");
}

0 comments on commit 8d7557f

Please sign in to comment.