HADOOP-16041. Include Hadoop version in User-Agent string for ABFS. Contributed by Shweta Yakkali.
Signed-off-by: Sean Mackrory <mackrorysd@apache.org>
This commit is contained in:
parent
b3bc94ebfd
commit
02eb91856e
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience;
|
import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.classification.InterfaceStability;
|
import org.apache.hadoop.classification.InterfaceStability;
|
||||||
|
import org.apache.hadoop.util.VersionInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responsible to keep all constant keys used in abfs rest client here.
|
* Responsible to keep all constant keys used in abfs rest client here.
|
||||||
@ -43,7 +44,7 @@ public final class AbfsHttpConstants {
|
|||||||
public static final String OS_NAME = "os.name";
|
public static final String OS_NAME = "os.name";
|
||||||
public static final String OS_VERSION = "os.version";
|
public static final String OS_VERSION = "os.version";
|
||||||
|
|
||||||
public static final String CLIENT_VERSION = "Azure Blob FS/1.0";
|
public static final String CLIENT_VERSION = "Azure Blob FS/" + VersionInfo.getVersion();
|
||||||
|
|
||||||
// Abfs Http Verb
|
// Abfs Http Verb
|
||||||
public static final String HTTP_METHOD_DELETE = "DELETE";
|
public static final String HTTP_METHOD_DELETE = "DELETE";
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
import org.apache.hadoop.fs.azurebfs.utils.SSLSocketFactoryEx;
|
import org.apache.hadoop.fs.azurebfs.utils.SSLSocketFactoryEx;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys;
|
import org.apache.hadoop.fs.azurebfs.constants.ConfigurationKeys;
|
||||||
|
import org.apache.hadoop.util.VersionInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test useragent of abfs client.
|
* Test useragent of abfs client.
|
||||||
@ -49,12 +50,15 @@ private void validateUserAgent(String expectedPattern,
|
|||||||
}
|
}
|
||||||
String userAgent = client.initializeUserAgent(config, sslProviderName);
|
String userAgent = client.initializeUserAgent(config, sslProviderName);
|
||||||
Pattern pattern = Pattern.compile(expectedPattern);
|
Pattern pattern = Pattern.compile(expectedPattern);
|
||||||
Assert.assertTrue(pattern.matcher(userAgent).matches());
|
Assert.assertTrue("Incorrect User Agent String",
|
||||||
|
pattern.matcher(userAgent).matches());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void verifyUnknownUserAgent() throws Exception {
|
public void verifyUnknownUserAgent() throws Exception {
|
||||||
String expectedUserAgentPattern = "Azure Blob FS\\/1.0 \\(JavaJRE ([^\\)]+)\\)";
|
String clientVersion = "Azure Blob FS/" + VersionInfo.getVersion();
|
||||||
|
String expectedUserAgentPattern = String.format(clientVersion
|
||||||
|
+ " %s", "\\(JavaJRE ([^\\)]+)\\)");
|
||||||
final Configuration configuration = new Configuration();
|
final Configuration configuration = new Configuration();
|
||||||
configuration.unset(ConfigurationKeys.FS_AZURE_USER_AGENT_PREFIX_KEY);
|
configuration.unset(ConfigurationKeys.FS_AZURE_USER_AGENT_PREFIX_KEY);
|
||||||
AbfsConfiguration abfsConfiguration = new AbfsConfiguration(configuration, accountName);
|
AbfsConfiguration abfsConfiguration = new AbfsConfiguration(configuration, accountName);
|
||||||
@ -64,7 +68,9 @@ public void verifyUnknownUserAgent() throws Exception {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void verifyUserAgent() throws Exception {
|
public void verifyUserAgent() throws Exception {
|
||||||
String expectedUserAgentPattern = "Azure Blob FS\\/1.0 \\(JavaJRE ([^\\)]+)\\) Partner Service";
|
String clientVersion = "Azure Blob FS/" + VersionInfo.getVersion();
|
||||||
|
String expectedUserAgentPattern = String.format(clientVersion
|
||||||
|
+ " %s", "\\(JavaJRE ([^\\)]+)\\) Partner Service");
|
||||||
final Configuration configuration = new Configuration();
|
final Configuration configuration = new Configuration();
|
||||||
configuration.set(ConfigurationKeys.FS_AZURE_USER_AGENT_PREFIX_KEY, "Partner Service");
|
configuration.set(ConfigurationKeys.FS_AZURE_USER_AGENT_PREFIX_KEY, "Partner Service");
|
||||||
AbfsConfiguration abfsConfiguration = new AbfsConfiguration(configuration, accountName);
|
AbfsConfiguration abfsConfiguration = new AbfsConfiguration(configuration, accountName);
|
||||||
@ -74,7 +80,9 @@ public void verifyUserAgent() throws Exception {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void verifyUserAgentWithSSLProvider() throws Exception {
|
public void verifyUserAgentWithSSLProvider() throws Exception {
|
||||||
String expectedUserAgentPattern = "Azure Blob FS\\/1.0 \\(JavaJRE ([^\\)]+) SunJSSE-1.8\\) Partner Service";
|
String clientVersion = "Azure Blob FS/" + VersionInfo.getVersion();
|
||||||
|
String expectedUserAgentPattern = String.format(clientVersion
|
||||||
|
+ " %s", "\\(JavaJRE ([^\\)]+)\\) Partner Service");
|
||||||
final Configuration configuration = new Configuration();
|
final Configuration configuration = new Configuration();
|
||||||
configuration.set(ConfigurationKeys.FS_AZURE_USER_AGENT_PREFIX_KEY, "Partner Service");
|
configuration.set(ConfigurationKeys.FS_AZURE_USER_AGENT_PREFIX_KEY, "Partner Service");
|
||||||
configuration.set(ConfigurationKeys.FS_AZURE_SSL_CHANNEL_MODE_KEY,
|
configuration.set(ConfigurationKeys.FS_AZURE_SSL_CHANNEL_MODE_KEY,
|
||||||
|
Loading…
Reference in New Issue
Block a user