Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHOENIX-7266 Fix SSLConfigDir in ITs #150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private void setHdfsSecuredConfiguration(Configuration conf) throws Exception {
// Generate SSL certs
File keystoresDir = new File(UTIL.getDataTestDir("keystore").toUri().getPath());
keystoresDir.mkdirs();
String sslConfDir = TlsUtil.getClasspathDir(QueryServerEnvironment.class);
String sslConfDir = TlsUtil.TEST_CLASSES_DIR.getPath();
TlsUtil.setupSSLConfig(keystoresDir.getAbsolutePath(), sslConfDir, conf, false);

// Magic flag to tell hdfs to not fail on using ports above 1024
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private static void setHdfsSecuredConfiguration(Configuration conf) throws Excep
// Generate SSL certs
File keystoresDir = new File(UTIL.getDataTestDir("keystore").toUri().getPath());
keystoresDir.mkdirs();
String sslConfDir = TlsUtil.getClasspathDir(SecureQueryServerPhoenixDBIT.class);
String sslConfDir = TlsUtil.TEST_CLASSES_DIR.getPath();
TlsUtil.setupSSLConfig(keystoresDir.getAbsolutePath(), sslConfDir, conf, false);

// Magic flag to tell hdfs to not fail on using ports above 1024
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public class TlsUtil {
protected static final String TARGET_DIR_NAME = System.getProperty("target.dir", "target");
protected static final File TARGET_DIR =
new File(System.getProperty("user.dir"), TARGET_DIR_NAME);
protected static final String TEST_CLASSES_DIR_NAME =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few lines of comments on what is happening here would be useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this, as these are just directory names, there isn't really a complex logic behind them. There are very similar definitions in the preceding lines without comments as well.

System.getProperty("test-classes.dir", "test-classes");
public static final File TEST_CLASSES_DIR =
new File(TARGET_DIR, TEST_CLASSES_DIR_NAME);
protected static final File KEYSTORE = new File(TARGET_DIR, "avatica-test-ks.jks");
protected static final File TRUSTSTORE = new File(TARGET_DIR, "avatica-test-ts.jks");

Expand Down Expand Up @@ -142,15 +146,6 @@ private static X509Certificate generateCertificate(String dn, KeyPair pair, int
return cert;
}

public static String getClasspathDir(Class<?> klass) throws Exception {
String file = klass.getName();
file = file.replace('.', '/') + ".class";
URL url = Thread.currentThread().getContextClassLoader().getResource(file);
String baseDir = url.toURI().getPath();
baseDir = baseDir.substring(0, baseDir.length() - file.length() - 1);
return baseDir;
}

/**
* Performs complete setup of SSL configuration in preparation for testing an
* SSLFactory. This includes keys, certs, keystores, truststores, the server
Expand Down