Author: dmacvicar
Date: Sat Jul 12 01:44:35 2008
New Revision: 10553
URL: http://svn.opensuse.org/viewcvs/zypp?rev=10553&view=rev
Log:
rename expireTimestamp to suggestedExpireTimestamp
add testcase skeleton
Added:
trunk/libzypp/tests/repo/OutdatedMetadata_test.cc
trunk/libzypp/tests/repo/yum/data/extensions/
trunk/libzypp/tests/repo/yum/data/extensions/repodata/
trunk/libzypp/tests/repo/yum/data/extensions/repodata/filelists.xml.gz
trunk/libzypp/tests/repo/yum/data/extensions/repodata/other.xml.gz
trunk/libzypp/tests/repo/yum/data/extensions/repodata/primary.xml.gz
trunk/libzypp/tests/repo/yum/data/extensions/repodata/repomd.xml
Modified:
trunk/libzypp/tests/repo/CMakeLists.txt
trunk/libzypp/zypp/Repository.cc
trunk/libzypp/zypp/Repository.h
Modified: trunk/libzypp/tests/repo/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/repo/CMakeLists.txt?rev=10553&r1=10552&r2=10553&view=diff
==============================================================================
--- trunk/libzypp/tests/repo/CMakeLists.txt (original)
+++ trunk/libzypp/tests/repo/CMakeLists.txt Sat Jul 12 01:44:35 2008
@@ -1,4 +1,7 @@
ADD_SUBDIRECTORY( yum )
ADD_SUBDIRECTORY( susetags )
-ADD_TESTS(RepoVariables)
+# to find the KeyRingTest receiver
+INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/tests/zypp )
+
+ADD_TESTS(RepoVariables OutdatedMetadata)
Added: trunk/libzypp/tests/repo/OutdatedMetadata_test.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/repo/OutdatedMetadata_test.cc?rev=10553&view=auto
==============================================================================
--- trunk/libzypp/tests/repo/OutdatedMetadata_test.cc (added)
+++ trunk/libzypp/tests/repo/OutdatedMetadata_test.cc Sat Jul 12 01:44:35 2008
@@ -0,0 +1,57 @@
+#include <iostream>
+#include <sstream>
+#include <fstream>
+#include <list>
+#include <string>
+
+#include
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/Exception.h"
+#include "zypp/PathInfo.h"
+#include "zypp/TmpPath.h"
+#include "zypp/RepoManager.h"
+#include "zypp/sat/Pool.h"
+#include "KeyRingTestReceiver.h"
+
+using boost::unit_test::test_case;
+
+using namespace std;
+using namespace zypp;
+using namespace zypp::repo;
+using namespace zypp::filesystem;
+
+#define TEST_DIR TESTS_SRC_DIR "/repo/yum/data/extensions"
+
+BOOST_AUTO_TEST_CASE(extensions)
+{
+ KeyRingTestReceiver rec;
+ //rec.answerAcceptUnknownKey(true);
+ rec.answerAcceptUnsignedFile(true);
+
+
+// rec.answerImportKey(true);
+ Pathname repodir(TEST_DIR );
+
+ TmpDir tmpCachePath;
+ RepoManagerOptions opts( RepoManagerOptions::makeTestSetup( tmpCachePath ) ) ;
+ RepoManager rm(opts);
+
+ RepoInfo updates;
+ updates.setAlias("updates");
+ updates.addBaseUrl(Url(string("dir:") + repodir.absolutename().asString() ));
+
+ try
+ {
+ rm.buildCache(updates);
+ rm.loadFromCache(updates);
+ }
+ catch (const Exception & e)
+ {
+ BOOST_FAIL( string("Problem getting the data: ")+ e.msg()) ;
+ }
+ sat::Pool pool(sat::Pool::instance());
+
+
+ rm.cleanCache(updates);
+}
Added: trunk/libzypp/tests/repo/yum/data/extensions/repodata/filelists.xml.gz
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/repo/yum/data/extensions/repodata/filelists.xml.gz?rev=10553&view=auto
==============================================================================
Files trunk/libzypp/tests/repo/yum/data/extensions/repodata/filelists.xml.gz (added) and trunk/libzypp/tests/repo/yum/data/extensions/repodata/filelists.xml.gz Sat Jul 12 01:44:35 2008 differ
Added: trunk/libzypp/tests/repo/yum/data/extensions/repodata/other.xml.gz
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/repo/yum/data/extensions/repodata/other.xml.gz?rev=10553&view=auto
==============================================================================
Files trunk/libzypp/tests/repo/yum/data/extensions/repodata/other.xml.gz (added) and trunk/libzypp/tests/repo/yum/data/extensions/repodata/other.xml.gz Sat Jul 12 01:44:35 2008 differ
Added: trunk/libzypp/tests/repo/yum/data/extensions/repodata/primary.xml.gz
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/repo/yum/data/extensions/repodata/primary.xml.gz?rev=10553&view=auto
==============================================================================
Files trunk/libzypp/tests/repo/yum/data/extensions/repodata/primary.xml.gz (added) and trunk/libzypp/tests/repo/yum/data/extensions/repodata/primary.xml.gz Sat Jul 12 01:44:35 2008 differ
Added: trunk/libzypp/tests/repo/yum/data/extensions/repodata/repomd.xml
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/repo/yum/data/extensions/repodata/repomd.xml?rev=10553&view=auto
==============================================================================
--- trunk/libzypp/tests/repo/yum/data/extensions/repodata/repomd.xml (added)
+++ trunk/libzypp/tests/repo/yum/data/extensions/repodata/repomd.xml Sat Jul 12 01:44:35 2008
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<repomd xmlns="http://linux.duke.edu/metadata/repo" expire="3600">
+ <data type="other">
+ <location href="repodata/other.xml.gz"/>
+ <checksum type="sha">73917678784071a9e1f66d333a3a265d01469098</checksum>
+ <timestamp>1215823452</timestamp>
+ <open-checksum type="sha">34cde52910a161664291bd93e8a9cd24f751af6b</open-checksum>
+ </data>
+ <data type="filelists">
+ <location href="repodata/filelists.xml.gz"/>
+ <checksum type="sha">5df72494136a4e4b608ce3119802d6aa8d0f1167</checksum>
+ <timestamp>1215823452</timestamp>
+ <open-checksum type="sha">fdabcfd9c056109ab25acf0644823bdec94b6cfd</open-checksum>
+ </data>
+ <data type="primary">
+ <location href="repodata/primary.xml.gz"/>
+ <checksum type="sha">52969c92f9c595108376cd37df7d5ada41851f6a</checksum>
+ <timestamp>1215823452</timestamp>
+ <open-checksum type="sha">c6bd3c6099de74d97ed045163235be10ffa8a85f</open-checksum>
+ </data>
+</repomd>
Modified: trunk/libzypp/zypp/Repository.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Repository.cc?rev=10553&r1=10552&r2=10553&view=diff
==============================================================================
--- trunk/libzypp/zypp/Repository.cc (original)
+++ trunk/libzypp/zypp/Repository.cc Sat Jul 12 01:44:35 2008
@@ -79,10 +79,12 @@
}
else
ERR << "the extra does not exist in the repo" << endl;
+
+ return Date();
}
- zypp::Date Repository::expirationTimestamp() const
+ zypp::Date Repository::suggestedExpirationTimestamp() const
{
::Dataiterator di;
::dataiterator_init(&di, get(), -1, 0, 0, SEARCH_EXTRA | SEARCH_NO_STORAGE_SOLVABLE);
@@ -103,12 +105,14 @@
}
else
ERR << "the extra does not exist in the repo" << endl;
+
+ return Date();
}
bool Repository::maybeOutdated() const
{
- return expirationTimestamp() < Date::now();
+ return suggestedExpirationTimestamp() < Date::now();
}
bool Repository::solvablesEmpty() const
Modified: trunk/libzypp/zypp/Repository.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Repository.h?rev=10553&r1=10552&r2=10553&view=diff
==============================================================================
--- trunk/libzypp/zypp/Repository.h (original)
+++ trunk/libzypp/zypp/Repository.h Sat Jul 12 01:44:35 2008
@@ -90,17 +90,44 @@
/**
* Timestamp when this repository was generated
+ *
+ * Usually this value is calculated as the newer
+ * timestamp from the timestamp of all the resources
+ * that conform the repository's metadata.
+ *
+ * For example in a rpm-md repository, it would be
+ * the resource specified in the xml file whith
+ * the newest timestamp attribute (which is the
+ * timestamp of the file in the server ).
+ *
+ * The timestamp is 0 if the repository does not
+ * specify when it was generated.
+ *
*/
zypp::Date generatedTimestamp() const;
/**
- * Expiration date
+ * Suggested expiration timestamp.
+ *
+ * Repositories can define an amount of time
+ * they expire, with the generated timestamp as
+ * the base point of time.
+ *
+ * Note that is the responsability of the repository
+ * to freshen the generated timestamp to tell the
+ * client that the repo is alive and updating the
+ * metadata.
+ *
+ * The timestamp is 0 if the repository does not specify
+ * an expiration date.
+ *
*/
- zypp::Date expirationTimestamp() const;
+ zypp::Date suggestedExpirationTimestamp() const;
/**
- * The expiration date of this repository
+ * The suggested expiration date of this repository
* already passed
+ *
*/
bool maybeOutdated() const;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org