public void TestAmazonS3FileStore() { var testKey = new TestValue.Key(accountId: Guid.NewGuid()); var testValueA = new TestValue( accountId: testKey.AccountId.Value, message: "Hello, world!"); var testValueB = new TestValue( accountId: testKey.AccountId.Value, message: "Kthx, world!"); var dataStore = new FileStoreDataStore <TestValue.Key, TestValue>( fileStore: new AmazonS3FileStore( accessKeyId: GetConfig("AccessKeyId"), secretAccessKey: GetConfig("SecretAccessKey"), bucketName: GetConfig("BucketName")), serializer: new JsonSerializer(), keyMap: "test-values/{AccountId}", fileExtension: ".json"); TestDataStore( dataStore, testKey, testValueA, testValueB); }
public void TestLocalFileStore_GZip_Json() { var rootPath = Path.Combine( Directory.GetCurrentDirectory(), "test-data-store"); //if (Directory.Exists(rootPath)) Directory.Delete(rootPath, true); var testKey = new TestValue.Key(accountId: Guid.NewGuid()); var testValueA = new TestValue( accountId: testKey.AccountId.Value, message: "Hello, world!"); var testValueB = new TestValue( accountId: testKey.AccountId.Value, message: "Kthx, world!"); var dataStore = new FileStoreDataStore <TestValue.Key, TestValue>( fileStore: new LocalFileStore(rootPath: rootPath), serializer: new JsonSerializer($"{JsonOptions.Default}"), compressor: new GZipCompressor(), keyMap: "test-values/{AccountId}", fileExtension: ".json.gzip"); UniversalIntegrationTest.TestDataStore( dataStore, testKey, testValueA, testValueB); }
public void TestSftpFileStore_FromRoot() { var testKey = new TestValue.Key(accountId: Guid.NewGuid()); var testValueA = new TestValue( accountId: testKey.AccountId.Value, message: "Hello, world!"); var testValueB = new TestValue( accountId: testKey.AccountId.Value, message: "Kthx, world!"); var dataStore = new FileStoreDataStore <TestValue.Key, TestValue>( fileStore: new SftpFileStore( host: Host, username: Username, password: Password), serializer: new JsonSerializer($"{JsonOptions.Default}"), keyMap: "{AccountId}", fileExtension: ".json"); TestDataStore( dataStore, testKey, testValueA, testValueB); }
public void TestGoogleDrive() { var testKey = new TestValue.Key(accountId: Guid.NewGuid()); var testValueA = new TestValue( accountId: testKey.AccountId.Value, message: "Hello, world!"); var testValueB = new TestValue( accountId: testKey.AccountId.Value, message: "Kthx, world!"); var dataStore = new FileStoreDataStore <TestValue.Key, TestValue>( fileStore: new GoogleDriveFileStore( applicationName: GetConfig("ApplicationName"), serviceAccountEmail: GetConfig("ServiceAccountEmail"), serviceAccountKey: GetConfig("ServiceAccountKey"), grantAccessToEmails: GetConfig("GrantAccessToEmails")), serializer: new JsonSerializer($"{JsonOptions.Default}"), keyMap: "test-values/{AccountId}", fileExtension: ".json"); TestDataStore( dataStore, testKey, testValueA, testValueB); }
public void TestLocalFileStore_Json() { InitializeLocalStorage(); var rootPath = Path.Combine( Directory.GetCurrentDirectory(), "test-data-store"); //if (Directory.Exists(rootPath)) Directory.Delete(rootPath, true); var testKey = new TestValue.Key(accountId: Guid.NewGuid()); var testValueA = new TestValue( accountId: testKey.AccountId.Value, message: "Hello, world!"); var testValueB = new TestValue( accountId: testKey.AccountId.Value, message: "Kthx, world!"); var dataStore = new FileStoreDataStore <TestValue.Key, TestValue>( fileStore: new LocalFileStore(rootPath: rootPath), serializer: new JsonSerializer(), keyMap: "test-values/{AccountId}", fileExtension: ".json"); TestDataStore( dataStore, testKey, testValueA, testValueB); }
public void TestBlobFileStore() { var testKey = new TestValue.Key(accountId: Guid.NewGuid()); var testValueA = new TestValue( accountId: testKey.AccountId.Value, message: "Hello, world!"); var testValueB = new TestValue( accountId: testKey.AccountId.Value, message: "Kthx, world!"); var dataStore = new FileStoreDataStore <TestValue.Key, TestValue>( fileStore: new BlobFileStore( GetConfig("ConnectionString"), "test-kvs", "application/json"), serializer: new JsonSerializer($"{JsonOptions.Default}"), keyMap: "test-values/{AccountId}", fileExtension: ".json"); TestDataStore( dataStore, testKey, testValueA, testValueB); }
public void TestLocalFileStore_Yaml() { InitializeLocalStorage(); var rootPath = Path.Combine( Directory.GetCurrentDirectory(), "test-file-store"); var testKey = new TestKey(accountId: Guid.NewGuid()); var testValueA = "Hello, world!"; var testValueB = "Kthx, world!"; var dataStore = new FileStoreDataStore <TestKey, string>( fileStore: new LocalFileStore(rootPath: rootPath), serializer: new ByteSerializer(), keyMap: "test-values/{AccountId}", fileExtension: ".txt"); TestDataStore( dataStore, testKey, testValueA, testValueB); }
public async Task TestSftpFileStore_Concurrent() { int concurrentCount = 30; var dataStore = new FileStoreDataStore <TestValue.Key, TestValue>( fileStore: new SftpFileStore( host: Host, username: Username, password: Password, maxConcurrentConnections: $"{concurrentCount}"), serializer: new JsonSerializer($"{JsonOptions.Default}"), keyMap: "test-values/another folder/moar_folder/{AccountId}", fileExtension: ".json"); var tasks = Enumerable .Range(0, concurrentCount) .Select(i => Task.Run(() => { var testKey = new TestValue.Key(accountId: Guid.NewGuid()); var testValueA = new TestValue( accountId: testKey.AccountId.Value, message: "Hello, world!"); var testValueB = new TestValue( accountId: testKey.AccountId.Value, message: "Kthx, world!"); _output.WriteLine($"Starting {i}"); TestDataStore( dataStore, testKey, testValueA, testValueB); _output.WriteLine($"Finished {i}"); })); await Task.WhenAll(tasks); }
public void TestBlobFileStore_OptimisticConcurrency() { var testKey = new TestValue.Key(accountId: Guid.NewGuid()); var testValueA = new TestValue( accountId: testKey.AccountId.Value, message: "Hello, world!"); var testValueB = new TestValue( accountId: testKey.AccountId.Value, message: "Kthx, world!"); var dataStore = new FileStoreDataStore <TestValue.Key, TestValue>( fileStore: new BlobFileStore( GetConfig("ConnectionString"), "test-kvs", "application/json"), serializer: new JsonSerializer($"{JsonOptions.Default}"), keyMap: "test-values/{AccountId}", fileExtension: ".json"); dataStore .Upsert(testKey, o => { Assert.Null(o); return(testValueB); }) .Wait(); dataStore .Upsert(testKey, o => { Assert.Equal(testValueB.AccountId, o.AccountId); Assert.Equal(testValueB.Message, o.Message); return(testValueA); }) .Wait(); }
public async Task RunBulkApiTests() { var dataStore = new FileStoreDataStore <TestValue.Key, TestValue>( fileStore: new AmazonS3FileStore( accessKeyId: GetConfig("AccessKeyId"), secretAccessKey: GetConfig("SecretAccessKey"), bucketName: GetConfig("BucketName")), serializer: new JsonSerializer($"{JsonOptions.Default}"), keyMap: "test-values/{AccountId}", fileExtension: ".json"); ClearDataStore(dataStore); await TestBulkApi(dataStore, (keyGen, dataGen) => { var accountId = keyGen.ToGuid(); return(new KeyValuePair <TestValue.Key, TestValue>(new TestValue.Key(accountId), new TestValue(accountId, $"Test: {dataGen}"))); }); }
public async Task RunBulkApiTests() { var dataStore = new FileStoreDataStore <TestValue.Key, TestValue>( fileStore: new SftpFileStore( host: Host, username: Username, password: Password), serializer: new JsonSerializer($"{JsonOptions.Default}"), keyMap: "test-values/another folder/moar_folder/{AccountId}", fileExtension: ".json"); ClearDataStore(dataStore); await TestBulkApi(dataStore, (keyGen, dataGen) => { var accountId = keyGen.ToGuid(); return(new KeyValuePair <TestValue.Key, TestValue>(new TestValue.Key(accountId), new TestValue(accountId, $"Test: {dataGen}"))); }); }
public async Task RunBulkApiTests() { var dataStore = new FileStoreDataStore <TestValue.Key, TestValue>( fileStore: new BlobFileStore( GetConfig("ConnectionString"), "test-kvs", "application/json"), serializer: new JsonSerializer($"{JsonOptions.Default}"), keyMap: "test-values/{AccountId}", fileExtension: ".json"); ClearDataStore(dataStore); await TestBulkApi(dataStore, (keyGen, dataGen) => { var accountId = keyGen.ToGuid(); return(new KeyValuePair <TestValue.Key, TestValue>(new TestValue.Key(accountId), new TestValue(accountId, $"Test: {dataGen}"))); }); }
public void TestLocalFileStore_Protobuf() { InitializeLocalStorage(); var rootPath = Path.Combine( Directory.GetCurrentDirectory(), "test-file-store"); //if (Directory.Exists(rootPath)) Directory.Delete(rootPath, true); var testKey = new ProtobufTestValue.Key(accountId: Guid.NewGuid()); var testValueA = new ProtobufTestValue { AccountId = testKey.AccountId.Value, Message = "Hello, world!" }; var testValueB = new ProtobufTestValue { AccountId = testKey.AccountId.Value, Message = "Kthx, world!" }; var dataStore = new FileStoreDataStore <ProtobufTestValue.Key, ProtobufTestValue>( fileStore: new LocalFileStore(rootPath: rootPath), serializer: new ProtobufSerializer(), keyMap: "test-values/{AccountId}", fileExtension: ".protobuf.data"); TestDataStore( dataStore, testKey, testValueA, testValueB); }
public void TestLocalFileStore_BondSimpleXml() { InitializeLocalStorage(); var rootPath = Path.Combine( Directory.GetCurrentDirectory(), "test-data-store"); //if (Directory.Exists(rootPath)) Directory.Delete(rootPath, true); var testKey = new BondTestValueKey(accountId: Guid.NewGuid()); var testValueA = new BondTestValue { AccountId = testKey.AccountId.Value, Message = "Hello, world!" }; var testValueB = new BondTestValue { AccountId = testKey.AccountId.Value, Message = "Kthx, world!" }; var dataStore = new FileStoreDataStore <BondTestValueKey, BondTestValue>( fileStore: new LocalFileStore(rootPath: rootPath), serializer: new BondSimpleXmlSerializer(), keyMap: "test-values/{AccountId}", fileExtension: ".bond.xml"); UniversalIntegrationTest.TestDataStore( dataStore, testKey, testValueA, testValueB); }
public async Task RunBulkApiTests() { var dataStore = new FileStoreDataStore <TestValue.Key, TestValue>( fileStore: new GoogleDriveFileStore( applicationName: GetConfig("ApplicationName"), serviceAccountEmail: GetConfig("ServiceAccountEmail"), serviceAccountKey: GetConfig("ServiceAccountKey"), grantAccessToEmails: GetConfig("GrantAccessToEmails")), serializer: new JsonSerializer($"{JsonOptions.Default}"), keyMap: "test-values/{AccountId}", fileExtension: ".json"); ClearDataStore(dataStore); await TestBulkApi(dataStore, (keyGen, dataGen) => { var accountId = keyGen.ToGuid(); return(new KeyValuePair <TestValue.Key, TestValue>(new TestValue.Key(accountId), new TestValue(accountId, $"Test: {dataGen}"))); }); }