/** * Test retry policy - retryN */ public function testRetryN() { $this->_executedRetries = 0; $this->_exceptionCount = 9; $policy = AbstractRetryPolicy::retryN(10, 100); $retries = $policy->execute(array($this, '_countRetriesAndThrowExceptions')); $this->assertEquals(10, $retries); }
protected function createStorageInstance() { $storageClient = null; if (TESTS_ZEND_SERVICE_WINDOWSAZURE_SESSIONHANDLER_RUNONPROD) { $storageClient = new Table(TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_HOST_PROD, TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_ACCOUNT_PROD, TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_KEY_PROD, false, AbstractRetryPolicy::retryN(10, 250)); } else { $storageClient = new Table(TESTS_ZEND_SERVICE_WINDOWSAZURE_TABLE_HOST_DEV, TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_ACCOUNT_DEV, TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_KEY_DEV, true, AbstractRetryPolicy::retryN(10, 250)); } if (TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_USEPROXY) { $storageClient->setProxy(TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_USEPROXY, TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_PROXY, TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_PROXY_PORT, TESTS_ZEND_SERVICE_WINDOWSAZURE_STORAGE_PROXY_CREDENTIALS); } return $storageClient; }
/** * Perform request using Client channel * * @param string $path Path * @param string $queryString Query string * @param string $httpVerb HTTP verb the request will use * @param array $headers x-ms headers to add * @param boolean $forTableStorage Is the request for table storage? * @param mixed $rawData Optional RAW HTTP data to be sent over the wire * @param string $resourceType Resource type * @param string $requiredPermission Required permission * @return Response */ protected function _performRequest( $path = '/', $queryString = '', $httpVerb = Request::METHOD_GET, $headers = array(), $forTableStorage = false, $rawData = null, $resourceType = Storage::RESOURCE_UNKNOWN, $requiredPermission = Credentials\AbstractCredentials::PERMISSION_READ ) { // Clean path if (strpos($path, '/') !== 0) { $path = '/' . $path; } // Clean headers if ($headers === null) { $headers = array(); } // Ensure cUrl will also work correctly: // - disable Content-Type if required // - disable Expect: 100 Continue if (!isset($headers["Content-Type"])) { $headers["Content-Type"] = ''; } $headers["Expect"] = ''; // Add version header $headers['x-ms-version'] = $this->_apiVersion; // URL encoding $path = self::urlencode($path); $queryString = self::urlencode($queryString); // Generate URL and sign request $requestUrl = $this->_credentials ->signRequestUrl($this->getBaseUrl() . $path . $queryString, $resourceType, $requiredPermission); $requestHeaders = $this->_credentials ->signRequestHeaders($httpVerb, $path, $queryString, $headers, $forTableStorage, $resourceType, $requiredPermission); // Prepare request $this->_httpClientChannel->resetParameters(true); $this->_httpClientChannel->setUri($requestUrl); $this->_httpClientChannel->setHeaders($requestHeaders); $this->_httpClientChannel->setRawBody($rawData); // Execute request $response = $this->_retryPolicy->execute( array($this->_httpClientChannel, 'request'), array($httpVerb) ); return $response; }