Beispiel #1
0
        /// <summary>
        ///     Break leases on vhd blobs
        /// </summary>
        /// <param name="hostedServiceName"></param>
        /// <param name="vhdBlobContainer"></param>
        public void BreakVhdLeases(string hostedServiceName, string vhdBlobContainer = "vhds")
        {
            var storageManager = new AzureStorageServiceManager();
            var vhdManager     = new AzureVirtualMachineManager();
            var vhdsLeased     = vhdManager.GetVirtualHardDisks().Where(vhd => vhd.UsageDetails.HostedServiceName == hostedServiceName);

            foreach (var vhd in vhdsLeased)
            {
                var storage = storageManager.GetStorageServiceForBlob(vhd.MediaLinkUri);
                var blob    = storage.GetBlob(Path.GetFileName(vhd.MediaLinkUri.ToString()), vhdBlobContainer);

                TestEasyLog.Instance.Info("Breaking lease on [" + blob.Uri + "]");

                blob.BreakLease(TimeSpan.FromSeconds(1));
            }

            TestEasyLog.Instance.Info("Waiting for VHDs to be released");
            // now wait a short while for the lease to actually expire.
            RetryHelper.RetryUntil(() =>
            {
                var remainingVhdsLeased = vhdManager.GetVirtualHardDisks().Where(vhd => vhd.UsageDetails.HostedServiceName == hostedServiceName);
                return(!remainingVhdsLeased.Any());
            }, 30, TimeSpan.FromSeconds(5));
        }
Beispiel #2
0
 public bool WaitForRoleToRespond(string url, int timeoutInMilliSeconds = 900000)
 {
     return(RetryHelper.RetryUntil(() => _webRequestor.PingUrl(url), timeoutInMilliSeconds / 1000, TimeSpan.FromSeconds(1)));
 }