Exemplo n.º 1
0
        public void Delete_all_objects_for_all_containers()
        {
            swiftConnectionData = KeystoneData.GetKeystoneToken();
            tokenSource         = new CancellationTokenSource();

            swiftclient = new Swift(swiftConnectionData.Item1, swiftConnectionData.Item2, KeystoneData.keystoneTenant);

            ContainerCollection containerCollection = null;

            Assert.DoesNotThrow(() => {
                var tsk             = swiftclient.GetContainers(tokenSource.Token);
                containerCollection = tsk.Result;
            });

            Assert.NotNull(containerCollection);

            List <Tuple <Container, SwiftObjectsCollection> > listOfEverything = new List <Tuple <Container, SwiftObjectsCollection> >();

            containerCollection.ForEach(container => {
                Assert.DoesNotThrow(() => {
                    var tsk2 = swiftclient.GetObjects(container, tokenSource.Token);
                    listOfEverything.Add(new Tuple <Container, SwiftObjectsCollection>(container, tsk2.Result));
                });
            });

            Assert.True(listOfEverything.Count > 0);

            foreach (Tuple <Container, SwiftObjectsCollection> record in listOfEverything)
            {
                SwiftObjectsCollection originalCollection  = record.Item2;
                SwiftObjectsCollection generatedCollection = null;

                originalCollection.ForEach(obj => {
                    Assert.DoesNotThrow(() => {
                        System.Diagnostics.Trace.WriteLine("[Objects] Going to delete object: " + obj.Name + " from container: " + record.Item1.Name);

                        var tsk3            = swiftclient.DeleteObject(record.Item1, obj, tokenSource.Token);
                        generatedCollection = tsk3.Result;
                    });

                    Assert.NotNull(generatedCollection);

                    Assert.False(originalCollection.Intersect(generatedCollection).Count() == originalCollection.Count);
                });
            }
        }
Exemplo n.º 2
0
        public void Bring_all_objects(Container targetContainer)
        {
            swiftConnectionData = KeystoneData.GetKeystoneToken();
            tokenSource         = new CancellationTokenSource();

            swiftclient = new Swift(swiftConnectionData.Item1, swiftConnectionData.Item2, KeystoneData.keystoneTenant);

            SwiftObjectsCollection swiftObjectCollection = null;

            Assert.DoesNotThrow(() => {
                var tsk = swiftclient.GetObjects(targetContainer, tokenSource.Token);
                swiftObjectCollection = tsk.Result;
            });

            //
            // Even if they are not objects the 'data' could not be null
            Assert.NotNull(swiftObjectCollection);

            System.Diagnostics.Trace.WriteLine("Container: " + targetContainer.Name + " has " + swiftObjectCollection.Count.ToString() + " objects inside it");
            swiftObjectCollection.AsParallel().ForAll(obj => System.Diagnostics.Trace.WriteLine("Swift object name: " + obj.Name + " Hash: " + obj.MD5Hash + " length: " + obj.Length + " Endpoint: " + obj.Endpoint.ToString()));
        }