Skip to content

Commit

Permalink
Fix tests to work with embedded tomcat (#1779)
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-tchad authored Jan 10, 2024
1 parent d7b97e8 commit fbe9d7b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/org/labkey/test/tests/AuditLogTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.labkey.test.BaseWebDriverTest;
import org.labkey.test.Locator;
import org.labkey.test.TestFileUtils;
import org.labkey.test.TestProperties;
import org.labkey.test.TestTimeoutException;
import org.labkey.test.WebTestHelper;
import org.labkey.test.categories.Daily;
Expand Down Expand Up @@ -175,7 +174,7 @@ protected void turnOnAuditLogFile()
protected ArrayList<String> getAuditLogFromFile() throws IOException
{
ArrayList<String> auditLog = new ArrayList<>();
File auditLogFile = new File(TestProperties.getTomcatHome(), "logs/labkey-audit.log");
File auditLogFile = new File(TestFileUtils.getServerLogDir(), "labkey-audit.log");

try (FileReader fileReader = new FileReader(auditLogFile))
{
Expand Down
13 changes: 5 additions & 8 deletions src/org/labkey/test/tests/DatabaseDiagnosticsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
import org.junit.experimental.categories.Category;
import org.labkey.test.BaseWebDriverTest;
import org.labkey.test.Locator;
import org.labkey.test.TestProperties;
import org.labkey.test.TestFileUtils;
import org.labkey.test.WebTestHelper;
import org.labkey.test.categories.BVT;
import org.labkey.test.categories.CustomModules;
import org.labkey.test.categories.Daily;
import org.labkey.test.categories.Git;
import org.labkey.test.io.Grep;
import org.labkey.test.util.Maps;
import org.labkey.test.util.Order;
import org.labkey.test.util.PasswordUtil;
import org.labkey.test.util.PipelineStatusTable;
import org.labkey.test.util.Order;
import org.openqa.selenium.WebElement;

import java.io.File;
Expand Down Expand Up @@ -78,19 +78,16 @@ public void databaseCheckTest()
@Test
public void testTomcatLogs() throws Exception
{
File tomcatHome = TestProperties.getTomcatHome();
assertTrue("Specified tomcat.home does not exist: " + tomcatHome +
"\nMake sure CATALINA_HOME is set or specify 'tomcat.home' when running tests",
tomcatHome != null && tomcatHome.exists());
File logDir = new File(tomcatHome, "logs");
File logDir = TestFileUtils.getServerLogDir();
assertTrue("Server log directory does not exist: " + logDir, logDir.isDirectory());
File[] logs = logDir.listFiles();
Map<File, Integer> contaminatedLogs = Grep.grep(PasswordUtil.getPassword(), logs);
Map<String, String> failureFiles = new TreeMap<>();
contaminatedLogs.keySet().forEach(
file -> failureFiles.put(file.getName(), "line " + contaminatedLogs.get(file)));

assertTrue(String.format("These tomcat logs (in %s) contained unwanted text [%s]:\n%s",
tomcatHome.getAbsolutePath(), PasswordUtil.getPassword(), failureFiles.toString()),
logDir.getAbsolutePath(), PasswordUtil.getPassword(), failureFiles.toString()),
failureFiles.isEmpty());
}

Expand Down

0 comments on commit fbe9d7b

Please sign in to comment.