diff options
author | Chris Wilson <chris+github@qwirx.com> | 2015-07-31 21:12:08 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2015-07-31 21:12:08 +0000 |
commit | 20eada7b4c083658c117477c737359001c4d6110 (patch) | |
tree | 64d97ddfde3fcc622a0d542398211a800cad506c | |
parent | 2752d3fc35f9502178ca3308dbcf2af95a4d4e6e (diff) |
Add missing files for S3Store test.
-rw-r--r-- | test/s3store/testextra | 4 | ||||
-rw-r--r-- | test/s3store/testfiles/bbackupd.conf | 61 | ||||
-rw-r--r-- | test/s3store/testfiles/clientTrustedCAs.pem | 11 | ||||
-rw-r--r-- | test/s3store/testfiles/s3simulator.conf | 10 | ||||
-rw-r--r-- | test/s3store/testfiles/serverCerts.pem | 11 | ||||
-rw-r--r-- | test/s3store/testfiles/serverPrivKey.pem | 15 | ||||
-rw-r--r-- | test/s3store/testfiles/serverReq.pem | 10 | ||||
-rw-r--r-- | test/s3store/tests3store.cpp | 118 |
8 files changed, 240 insertions, 0 deletions
diff --git a/test/s3store/testextra b/test/s3store/testextra new file mode 100644 index 00000000..798c8c67 --- /dev/null +++ b/test/s3store/testextra @@ -0,0 +1,4 @@ +mkdir testfiles/0_0 +mkdir testfiles/0_1 +mkdir testfiles/0_2 +mkdir testfiles/bbackupd-data diff --git a/test/s3store/testfiles/bbackupd.conf b/test/s3store/testfiles/bbackupd.conf new file mode 100644 index 00000000..77640e5e --- /dev/null +++ b/test/s3store/testfiles/bbackupd.conf @@ -0,0 +1,61 @@ + +CertificateFile = testfiles/clientCerts.pem +PrivateKeyFile = testfiles/clientPrivKey.pem +TrustedCAsFile = testfiles/clientTrustedCAs.pem + +KeysFile = testfiles/bbackupd.keys + +DataDirectory = testfiles/bbackupd-data + +S3Store +{ + HostName = localhost + Port = 22080 + BasePath = /subdir/ + AccessKey = 0PN5J17HBGZHT7JJ3X82 + SecretKey = uV3F3YluFJax1cknvbcGwgjvx4QpvB+leU8dUj2o +} + +UpdateStoreInterval = 3 +BackupErrorDelay = 10 +MinimumFileAge = 4 +MaxUploadWait = 24 +DeleteRedundantLocationsAfter = 10 + +FileTrackingSizeThreshold = 1024 +DiffingUploadSizeThreshold = 1024 + +MaximumDiffingTime = 3 +KeepAliveTime = 1 + +ExtendedLogging = no +ExtendedLogFile = testfiles/bbackupd.log + +CommandSocket = testfiles/bbackupd.sock + +NotifyScript = /usr/bin/perl testfiles/notifyscript.pl +SyncAllowScript = /usr/bin/perl testfiles/syncallowscript.pl + +Server +{ + PidFile = testfiles/bbackupd.pid +} + +BackupLocations +{ + Test1 + { + Path = testfiles/TestDir1 + + ExcludeFile = testfiles/TestDir1/excluded_1 + ExcludeFile = testfiles/TestDir1/excluded_2 + ExcludeFilesRegex = \.excludethis$ + ExcludeFilesRegex = EXCLUDE + AlwaysIncludeFile = testfiles/TestDir1/dont.excludethis + ExcludeDir = testfiles/TestDir1/exclude_dir + ExcludeDir = testfiles/TestDir1/exclude_dir_2 + ExcludeDirsRegex = not_this_dir + AlwaysIncludeDirsRegex = ALWAYSINCLUDE + } +} + diff --git a/test/s3store/testfiles/clientTrustedCAs.pem b/test/s3store/testfiles/clientTrustedCAs.pem new file mode 100644 index 00000000..2a065879 --- /dev/null +++ b/test/s3store/testfiles/clientTrustedCAs.pem @@ -0,0 +1,11 @@ +-----BEGIN CERTIFICATE----- +MIIBjDCB9gIBADANBgkqhkiG9w0BAQUFADAPMQ0wCwYDVQQDEwRST09UMB4XDTAz +MTAwNzA4NTkzMloXDTMxMDIyMjA4NTkzMlowDzENMAsGA1UEAxMEUk9PVDCBnzAN +BgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAtZypR/5m5fuNMPNrSLdzwmXKqhdVZj/e +cZHUZvVuXQZboosAznDrbh8HgpuTw5vaZDEz8VfPwgIaROZDT3ztFIedLapJ7Ot9 +I4JNqSv/y3V9MKb7trTSPVvyYLqk9isLmw8wmEidJiLbWbIc2cHFXDvWNqTr2jF6 +u4Q8DvdVfAECAwEAATANBgkqhkiG9w0BAQUFAAOBgQAL1lyJ/5y44yjk2BK+tnrZ +hbK7Ghtqrq/uZ8RQq5sAme919TnPijh2tRBqSaUaD2K+Sgo3RNgUGbKhfHRU1pfM +USllHskTKiJu74ix/T3UOnjpQ946OLSl5zNsOdOgbjBDnozfPSrKeEGN0huBbmmt +SlL3iQzVXlF6NAhkzS54fQ== +-----END CERTIFICATE----- diff --git a/test/s3store/testfiles/s3simulator.conf b/test/s3store/testfiles/s3simulator.conf new file mode 100644 index 00000000..c9895e9f --- /dev/null +++ b/test/s3store/testfiles/s3simulator.conf @@ -0,0 +1,10 @@ +AccessKey = 0PN5J17HBGZHT7JJ3X82 +SecretKey = uV3F3YluFJax1cknvbcGwgjvx4QpvB+leU8dUj2o +StoreDirectory = testfiles/store +AddressPrefix = http://localhost:22080 + +Server +{ + PidFile = testfiles/s3simulator.pid + ListenAddresses = inet:localhost:22080 +} diff --git a/test/s3store/testfiles/serverCerts.pem b/test/s3store/testfiles/serverCerts.pem new file mode 100644 index 00000000..92467618 --- /dev/null +++ b/test/s3store/testfiles/serverCerts.pem @@ -0,0 +1,11 @@ +-----BEGIN CERTIFICATE----- +MIIBlzCCAQACAQQwDQYJKoZIhvcNAQEFBQAwDzENMAsGA1UEAxMEUk9PVDAeFw0w +MzEwMDcwOTAwMTFaFw0zMTAyMjIwOTAwMTFaMBkxFzAVBgNVBAMTDlNUT1JFLTAw +MDAwMDA4MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDNj1fGSCaSl/1w1lRV +I8qE6BqjvT6R0XXGdIV+dk/mHmE3NOCPcBq/gxZOYevp+QnwMc+nUSS7Px/n+q92 +cl3a8ttInfZjLqg9o/wpd6dBfH4gLTG4bEujhMt1x4bEUJk/uWfnk5FhsJXDBrlH +RJZNiS9Asme+5Zvjfz3Phy0YWwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBABhmdun/ +myn3l4SbH+PxSUaW/mSvBubFhbbl9wolwhzvGCrtY968jn464JUP1UwUnnvePUU2 +SSVPZOVCvobCfM6s20aOdlKvnn+7GZkjoFONuCw3O+1hIFTSyXFcJWBaYLuczVk1 +HfdIKKcVZ1CpAfnMhMxuu+nA7fjor4p1/K0t +-----END CERTIFICATE----- diff --git a/test/s3store/testfiles/serverPrivKey.pem b/test/s3store/testfiles/serverPrivKey.pem new file mode 100644 index 00000000..fd87607d --- /dev/null +++ b/test/s3store/testfiles/serverPrivKey.pem @@ -0,0 +1,15 @@ +-----BEGIN RSA PRIVATE KEY----- +MIICXQIBAAKBgQDNj1fGSCaSl/1w1lRVI8qE6BqjvT6R0XXGdIV+dk/mHmE3NOCP +cBq/gxZOYevp+QnwMc+nUSS7Px/n+q92cl3a8ttInfZjLqg9o/wpd6dBfH4gLTG4 +bEujhMt1x4bEUJk/uWfnk5FhsJXDBrlHRJZNiS9Asme+5Zvjfz3Phy0YWwIDAQAB +AoGBAI88mjo1noM528Wb4+nr5bvVDHMadJYhccMXAMqNYMGGW9GfS/dHc6wNiSaX +P0+rVIyF+R+rAEBmDTKV0Vxk9xZQuAaDKjLluDkxSxSR869D2YOWYUfvjDo3OFlT +LMZf0eE7u/3Pm0MtxPctXszqvNnmb+IvPXzttGRgUfU5G+tJAkEA+IphkGMI4A3l +4KfxotZZU+HiJbRDFpm81RzCc2709KCMkXMEz/+xkvnqlo28jqOf7PRBeq/ecsZN +8BGvtyoqVQJBANO6uj6sPI66GaRqxV83VyUUdMmL9uFOccIMqW5q0rx5UDi0mG7t +Pjjz+ul1D247+dvVxnEBeW4C85TSNbbKR+8CQQChpV7PCZo8Hs3jz1bZEZAHfmIX +I6Z+jH7EHHBbo06ty72g263FmgdkECcCxCxemQzqj/IGWVvUSiVmfhpKhqIBAkAl +XbjswpzVW4aW+7jlevDIPHn379mcHan54x4rvHKAjLBZsZWNThVDG9vWQ7B7dd48 +q9efrfDuN1shko+kOMLFAkAGIc5w0bJNC4eu91Wr6AFgTm2DntyVQ9keVhYbrwrE +xY37dgVhAWVeLDOk6eVOVSYqEI1okXPVqvfOIoRJUYkn +-----END RSA PRIVATE KEY----- diff --git a/test/s3store/testfiles/serverReq.pem b/test/s3store/testfiles/serverReq.pem new file mode 100644 index 00000000..7475d406 --- /dev/null +++ b/test/s3store/testfiles/serverReq.pem @@ -0,0 +1,10 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIBWDCBwgIBADAZMRcwFQYDVQQDEw5TVE9SRS0wMDAwMDAwODCBnzANBgkqhkiG +9w0BAQEFAAOBjQAwgYkCgYEAzY9Xxkgmkpf9cNZUVSPKhOgao70+kdF1xnSFfnZP +5h5hNzTgj3Aav4MWTmHr6fkJ8DHPp1Ekuz8f5/qvdnJd2vLbSJ32Yy6oPaP8KXen +QXx+IC0xuGxLo4TLdceGxFCZP7ln55ORYbCVwwa5R0SWTYkvQLJnvuWb4389z4ct +GFsCAwEAAaAAMA0GCSqGSIb3DQEBBQUAA4GBAIdlFo8gbik1K/+4Ra87cQDZzn0L +wE9bZrxRMPXqGjCQ8HBCfvQMFa1Oc6fEczCJ/nmmd76j0HIXW7uYOELIT8L/Zvf5 +jw/z9/OvEOQal7H2JN2d6W4ZmYpQko5+e/bJmlrOxyBpcXk34BvyQen9pTmI6J4E +pkBN/5XUUvVJSM67 +-----END CERTIFICATE REQUEST----- diff --git a/test/s3store/tests3store.cpp b/test/s3store/tests3store.cpp new file mode 100644 index 00000000..dad4289c --- /dev/null +++ b/test/s3store/tests3store.cpp @@ -0,0 +1,118 @@ +// -------------------------------------------------------------------------- +// +// File +// Name: tests3store.cpp +// Purpose: Test Amazon S3 storage VFS API and utilities +// Created: 2015/06/28 +// +// -------------------------------------------------------------------------- + +#include "Box.h" + +#ifndef WIN32 +# include <csignal> +#endif + +#include "BackupAccountControl.h" +#include "BackupClientCryptoKeys.h" +#include "BackupDaemonConfigVerify.h" +#include "BackupStoreInfo.h" +#include "Configuration.h" +#include "RaidFileController.h" +#include "ServerControl.h" +#include "SSLLib.h" +#include "Test.h" + +#include "MemLeakFindOn.h" + +#define DEFAULT_BBACKUPD_CONFIG_FILE "testfiles/bbackupd.conf" + +int s3simulator_pid = 0; + +bool StartSimulator() +{ + s3simulator_pid = StartDaemon(s3simulator_pid, + "../../bin/s3simulator/s3simulator " + bbstored_args + + " testfiles/s3simulator.conf", "testfiles/s3simulator.pid"); + return s3simulator_pid != 0; +} + +bool StopSimulator() +{ + bool result = StopDaemon(s3simulator_pid, "testfiles/s3simulator.pid", + "s3simulator.memleaks", true); + s3simulator_pid = 0; + return result; +} + +bool kill_running_daemons() +{ + TEST_THAT_OR(::system("test ! -r testfiles/s3simulator.pid || " + "kill `cat testfiles/s3simulator.pid`") == 0, FAIL); + TEST_THAT_OR(::system("rm -f testfiles/s3simulator.pid") == 0, FAIL); + return true; +} + +//! Simplifies calling setUp() with the current function name in each test. +#define SETUP_TEST_S3SIMULATOR() \ + SETUP(); \ + TEST_THAT(kill_running_daemons()); \ + TEST_THAT(StartSimulator()); \ + +#define TEARDOWN_TEST_S3SIMULATOR() \ + TEST_THAT(s3simulator_pid == 0 || StopSimulator()); \ + TEST_THAT(kill_running_daemons()); \ + TEARDOWN(); + +bool test_create_account_with_account_control() +{ + SETUP_TEST_S3SIMULATOR(); + + std::auto_ptr<Configuration> config = load_config_file(DEFAULT_BBACKUPD_CONFIG_FILE, + BackupDaemonConfigVerify); + S3BackupAccountControl control(*config); + control.CreateAccount("test", 1000, 2000); + + FileStream fs("testfiles/store/subdir/" S3_INFO_FILE_NAME); + std::auto_ptr<BackupStoreInfo> info = BackupStoreInfo::Load(fs, fs.GetFileName(), + true); // ReadOnly + TEST_EQUAL(0, info->GetAccountID()); + TEST_EQUAL(1, info->GetLastObjectIDUsed()); + TEST_EQUAL(1, info->GetBlocksUsed()); + TEST_EQUAL(0, info->GetBlocksInCurrentFiles()); + TEST_EQUAL(0, info->GetBlocksInOldFiles()); + TEST_EQUAL(0, info->GetBlocksInDeletedFiles()); + TEST_EQUAL(1, info->GetBlocksInDirectories()); + TEST_EQUAL(0, info->GetDeletedDirectories().size()); + TEST_EQUAL(1000, info->GetBlocksSoftLimit()); + TEST_EQUAL(2000, info->GetBlocksHardLimit()); + TEST_EQUAL(0, info->GetNumCurrentFiles()); + TEST_EQUAL(0, info->GetNumOldFiles()); + TEST_EQUAL(0, info->GetNumDeletedFiles()); + TEST_EQUAL(1, info->GetNumDirectories()); + TEST_EQUAL(true, info->IsAccountEnabled()); + TEST_EQUAL(true, info->IsReadOnly()); + TEST_EQUAL(0, info->GetClientStoreMarker()); + TEST_EQUAL("test", info->GetAccountName()); + + TEARDOWN_TEST_S3SIMULATOR(); +} + +int test(int argc, const char *argv[]) +{ + // SSL library + SSLLib::Initialise(); + + // Use the setup crypto command to set up all these keys, so that the bbackupquery command can be used + // for seeing what's going on. + BackupClientCryptoKeys_Setup("testfiles/bbackupd.keys"); + +#ifndef WIN32 + signal(SIGPIPE, SIG_IGN); +#endif + + TEST_THAT(test_create_account_with_account_control()); + + return finish_test_suite(); +} + |