public void TestStorageSystemEvent()
        {
            Connect();

            storageSystemInfo ss = _ws.GetSampleStorageSystem();

            _ws.StorageSystemsAndPools.Add(ss, new storagePoolInfo[0]);

            Thread.Sleep(2000);

            // check cache isn't updated. It requires an event to be updated.
            Assert.AreEqual(0, _con.Cache.StorageSystems.Count);

            // add event to trigger storage-system refresh
            _ws.Events.Add(new @event()
            {
                eventId = "event.object.storage-system.add.{bla}.{bla}"
            });

            WaitFor(() => _con.Cache.StorageSystems.Count == 1);

            Assert.AreEqual(_con.Cache.StorageSystems[0].opaque_ref, ss.objectId);
            Assert.AreEqual(_con.Cache.StorageSystems[0].SerialNumber, ss.serialNum);
            Assert.AreEqual(_con.Cache.StorageSystems[0].Model, ss.model);
            Assert.AreEqual(_con.Cache.StorageSystems[0].FullName, ss.displayName);
            Assert.AreEqual((uint)_con.Cache.StorageSystems[0].Capabilities, ss.capabilities);
            Assert.AreEqual(_con.Cache.StorageSystems[0].FriendlyName, ss.friendlyName);

            EndConnect();
        }
        public storageSystemInfo GetSampleStorageSystem()
        {
            storageSystemInfo ss = new storageSystemInfo();
            ss.objectId = "storageSystemId";
            ss.serialNum = "serialNum";
            ss.model = "model";
            ss.displayName = "displayname";
            ss.capabilities = 231;
            ss.friendlyName = "friendlyName";
            ss.storageSystemId = "storageSystemId";
            ss.storageAdapterId = "storageAdapterId";

            return ss;
        }
Пример #3
0
        public storageSystemInfo GetSampleStorageSystem()
        {
            storageSystemInfo ss = new storageSystemInfo();

            ss.objectId         = "storageSystemId";
            ss.serialNum        = "serialNum";
            ss.model            = "model";
            ss.displayName      = "displayname";
            ss.capabilities     = 231;
            ss.friendlyName     = "friendlyName";
            ss.storageSystemId  = "storageSystemId";
            ss.storageAdapterId = "storageAdapterId";

            return(ss);
        }
        public void TestStorageSystemExistsOnConnect()
        {
            storageSystemInfo ss = _ws.GetSampleStorageSystem();
            storagePoolInfo   sp = _ws.GetSampleStoragePool();
            storageVolumeInfo sv = _ws.GetSampleStorageVolume();

            _ws.StorageSystemsAndPools.Add(ss, new[] { sp });
            _ws.StoragePoolsAndVolumes.Add(sp, new[] { sv });

            Connect();

            WaitFor(() => _con.Cache.StorageSystems.Count == 1, "Storage System didn't get added.");

            Assert.AreEqual(_con.Cache.StorageSystems[0].opaque_ref, ss.objectId);
            Assert.AreEqual(_con.Cache.StorageSystems[0].SerialNumber, ss.serialNum);
            Assert.AreEqual(_con.Cache.StorageSystems[0].Model, ss.model);
            Assert.AreEqual(_con.Cache.StorageSystems[0].FullName, ss.displayName);
            Assert.AreEqual((uint)_con.Cache.StorageSystems[0].Capabilities, ss.capabilities);
            Assert.AreEqual(_con.Cache.StorageSystems[0].FriendlyName, ss.friendlyName);

            Assert.AreEqual(_con.Cache.StoragePools[0].opaque_ref, sp.objectId);

            Assert.AreEqual(_con.Cache.StorageVolumes[0].opaque_ref, sv.objectId);
        }
        public void TestCacheWasRefreshedAfterTemporaryExceptionOnStorageSystemEnumeration()
        {
            const string message          = "test error";
            EventHandler exceptionThrower = (s, e) => { throw new WebException(message); };

            _ws.StorageSystemsEnumerating += exceptionThrower;

            _con.BeginConnect();

            WaitFor(() => _con.Error == message, "Error message wasn't shown");
            WaitFor(() => _con.ConnectionState == StorageLinkConnectionState.Disconnected, "Connection not shown as disconnected on exception");

            // add new storage-system
            storageSystemInfo ss = _ws.GetSampleStorageSystem();

            _ws.StorageSystemsAndPools.Add(ss, new storagePoolInfo[0]);

            // stop throwing the exception.
            _ws.StorageSystemsEnumerating -= exceptionThrower;

            // now check error has gone away and we connect
            WaitFor(() => _con.Error == "", "Error message didn't go away.");
            WaitFor(() => _con.ConnectionState == StorageLinkConnectionState.Connected, "Didn't connect after exception throwing stopped.");

            // now check cache refreshed
            WaitFor(() => _con.Cache.StorageSystems.Count == 1, "Storage System didn't get added.");

            Assert.AreEqual(_con.Cache.StorageSystems[0].opaque_ref, ss.objectId);
            Assert.AreEqual(_con.Cache.StorageSystems[0].SerialNumber, ss.serialNum);
            Assert.AreEqual(_con.Cache.StorageSystems[0].Model, ss.model);
            Assert.AreEqual(_con.Cache.StorageSystems[0].FullName, ss.displayName);
            Assert.AreEqual((uint)_con.Cache.StorageSystems[0].Capabilities, ss.capabilities);
            Assert.AreEqual(_con.Cache.StorageSystems[0].FriendlyName, ss.friendlyName);

            EndConnect();
        }
        public jobInfo enumStorageSystems(string filters, int flags, out storageSystemInfo[] storageSystemInfoList)
        {
            if (StorageSystemsEnumerating != null)
            {
                StorageSystemsEnumerating(this, EventArgs.Empty);
            }

            storageSystemInfoList = new List<storageSystemInfo>(StorageSystemsAndPools.Keys).ToArray();
            return null;
        }