Skip to content

Commit

Permalink
Updated tests to exclude those that are bound to fail in DHS (#1761)
Browse files Browse the repository at this point in the history
* Updated tests to exclude those that are bound to fail in DHS. These are known issues.

* Correcting IgnoreIf for groovey test
  • Loading branch information
bsrikan authored and aebadirad committed Jan 21, 2019
1 parent c1a9ddb commit aa07b49
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static void setupAll() throws Exception
@BeforeEach
public void setup()
{
Assumptions.assumeTrue(!(isCertAuth() || isSslRun()));
Assumptions.assumeTrue(!(isCertAuth() || isSslRun() || getHubAdminConfig().getIsProvisionedEnvironment()));
clearDatabases(HubConfig.DEFAULT_STAGING_NAME, HubConfig.DEFAULT_FINAL_NAME);
installHubModules();
installUserModules(getHubAdminConfig(), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.marklogic.hub.ApplicationConfig;
import org.apache.commons.io.FileUtils;
import org.custommonkey.xmlunit.XMLUnit;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
Expand Down Expand Up @@ -89,6 +90,7 @@ public void testTelemetryInstallCount() throws IOException {

@Test
public void testInstallHubModules() throws IOException {
Assumptions.assumeFalse(getHubAdminConfig().getIsProvisionedEnvironment());
assertTrue(getDataHub().isInstalled().isInstalled());

assertTrue(getModulesFile("/com.marklogic.hub/config.xqy").startsWith(getResource("data-hub-test/core-modules/config.xqy")));
Expand All @@ -108,6 +110,7 @@ public void getHubModulesVersion() throws IOException {

@Test
public void testInstallUserModules() throws IOException, ParserConfigurationException, SAXException, URISyntaxException {
Assumptions.assumeFalse(getHubAdminConfig().getIsProvisionedEnvironment());
URL url = DataHubInstallTest.class.getClassLoader().getResource("data-hub-test");
String path = Paths.get(url.toURI()).toFile().getAbsolutePath();
File srcDir = new File(path);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.marklogic.hub.HubTestBase;
import com.marklogic.hub.error.DataHubConfigurationException;

import org.junit.jupiter.api.*;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -35,7 +36,7 @@ public void setup() {
createProjectDir();
dataHub.initProject();
}

@AfterEach
public void cleanup() {
resetProperties();
Expand All @@ -53,7 +54,8 @@ public void testAppConfigDefaultProps() {

@Test
public void applyFinalConnectionPropsToDefaultRestConnection() {

Assumptions.assumeFalse(getHubAdminConfig().getIsProvisionedEnvironment());

AppConfig config = adminHubConfig.getAppConfig();

assertEquals(new Integer(8011), config.getRestPort(),
Expand All @@ -71,7 +73,7 @@ public void applyFinalConnectionPropsToDefaultRestConnection() {
String certPassword = adminHubConfig.getCertPassword(DatabaseKind.FINAL);
String extName = adminHubConfig.getExternalName(DatabaseKind.FINAL);
Boolean sslMethod = adminHubConfig.getSimpleSsl(DatabaseKind.FINAL);

Properties props = new Properties();
props.put("mlFinalAuth", "basic");
props.put("mlFinalPort", "8123");
Expand All @@ -83,22 +85,22 @@ public void applyFinalConnectionPropsToDefaultRestConnection() {
resetProperties();
adminHubConfig.refreshProject(props, true);

config = adminHubConfig.getAppConfig();
config = adminHubConfig.getAppConfig();

assertEquals(SecurityContextType.BASIC, config.getRestSecurityContextType());
assertEquals(new Integer(8123), config.getRestPort());
assertEquals("/path/to/file", config.getRestCertFile());
assertEquals("changeme", config.getRestCertPassword());
assertEquals("somename", config.getRestExternalName());
assertNotNull(config.getRestSslContext(), "Should have been set because mlFinalSimpleSsl=true");
assertNotNull(config.getRestSslHostnameVerifier(), "Should have been set because mlFinalSimpleSsl=true");
assertNotNull(config.getRestTrustManager(), "Should have been set because mlFinalSimpleSsl=true");
assertNotNull(config.getRestTrustManager(), "Should have been set because mlFinalSimpleSsl=true");

props = new Properties();
//reset them
props.put("mlFinalAuth", authMethod);
props.put("mlFinalPort", port);

//these values not set by dhf-default, so checking for null
if(certFile != null)
props.put("mlFinalCertFile", certFile);
Expand All @@ -113,8 +115,8 @@ public void applyFinalConnectionPropsToDefaultRestConnection() {
adminHubConfig.setSslHostnameVerifier(DatabaseKind.FINAL, null);
adminHubConfig.setTrustManager(DatabaseKind.FINAL, null);
}


}

@Test
Expand All @@ -123,17 +125,17 @@ public void testLoadBalancerProps() {
resetProperties();
adminHubConfig.refreshProject();
assertNull(getHubFlowRunnerConfig().getLoadBalancerHost());

writeProp("mlIsHostLoadBalancer", "true");
resetProperties();
adminHubConfig.refreshProject();
assertTrue(getHubFlowRunnerConfig().getIsHostLoadBalancer());

writeProp("mlLoadBalancerHosts", getHubFlowRunnerConfig().getHost());
resetProperties();
adminHubConfig.refreshProject();
assertEquals(getHubFlowRunnerConfig().getHost(), getHubFlowRunnerConfig().getLoadBalancerHost());

try {
writeProp("mlLoadBalancerHosts", "host1");
resetProperties();
Expand All @@ -142,7 +144,7 @@ public void testLoadBalancerProps() {
catch (DataHubConfigurationException e){
assertEquals( "\"mlLoadBalancerHosts\" must be the same as \"mlHost\"", e.getMessage());
}

deleteProp("mlLoadBalancerHosts");
deleteProp("mlIsHostLoadBalancer");
resetProperties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -34,7 +34,7 @@ public class HubProjectTest extends HubTestBase {

@BeforeEach
public void setupDir() {
deleteProjectDir();
deleteProjectDir();
}

@AfterEach
Expand Down Expand Up @@ -152,10 +152,10 @@ public void testInit() throws IOException {
File gradleLocalProperties = new File(projectPath, "gradle-local.properties");
assertTrue(gradleLocalProperties.exists());
}

@Test
public void upgrade300To403ToCurrentVersion() throws Exception {
Assumptions.assumeFalse((isCertAuth() || isSslRun()));
Assumptions.assumeFalse((isCertAuth() || isSslRun() || getHubAdminConfig().getIsProvisionedEnvironment()));
final String projectPath = "build/tmp/upgrade-projects/dhf403from300";
final File projectDir = Paths.get(projectPath).toFile();

Expand All @@ -175,6 +175,6 @@ public void upgrade300To403ToCurrentVersion() throws Exception {
.resolve("src/main/hub-internal-config-4.0.3/databases/final-database.json").toFile().exists());
Assertions.assertTrue(adminHubConfig.getHubProject().getProjectDir()
.resolve("src/main/ml-config-4.0.3").toFile().exists());

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.custommonkey.xmlunit.XMLAssert;
import org.custommonkey.xmlunit.XMLUnit;
import org.junit.Assert;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -249,6 +250,7 @@ public void testEnvelopeSJSXML() throws IOException, SAXException {

@Test
public void testCreateandDeployFlowWithHubUser() throws IOException {
Assumptions.assumeFalse(getHubAdminConfig().getIsProvisionedEnvironment());

scaffolding.createFlow(ENTITY, "FlowWithHubUser", FlowType.HARMONIZE,
CodeFormat.XQUERY, DataFormat.JSON, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.marklogic.hub.scaffold.Scaffolding;
import com.marklogic.hub.util.FileUtil;
import org.custommonkey.xmlunit.XMLUnit;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -144,6 +145,7 @@ public void runCollector() {
// there is a custom content plugin that throws an error. This code uses the stopOnFailure
// option to halt execution. This allows us to test that the collector runs to completion while not
// having to wait for the entire harmonize flow to finish.
Assumptions.assumeFalse(getHubAdminConfig().getIsProvisionedEnvironment());
assertEquals(DOC_COUNT, getStagingDocCount());
assertEquals(0, getFinalDocCount());
Flow harmonizeFlow = fm.getFlow(ENTITY, "testharmonize",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/

package com.marklogic.gradle.task
Expand All @@ -24,6 +24,7 @@ import org.gradle.testkit.runner.UnexpectedBuildSuccess
import com.marklogic.hub.HubConfig
import com.marklogic.hub.HubProject
import com.marklogic.hub.util.FileUtil
import spock.lang.IgnoreIf

import java.nio.file.Files
import java.nio.file.Path
Expand All @@ -38,7 +39,7 @@ class UpdateIndexesTaskTest extends BaseTest {
createGradleFiles()
println(runTask("hubInit"))
}

def setup() {
// Creating an Order Entity
propertiesFile << """
Expand All @@ -53,43 +54,44 @@ class UpdateIndexesTaskTest extends BaseTest {
// Copying Order.entity.json file to plugins/entities/my-unique-order-entity directory
String entityStream = new File("src/test/resources/update-indexes/my-unique-order-entity.entity.json").getAbsolutePath()
Files.copy(new File(entityStream).toPath(), entityDir.toPath().resolve("my-unique-order-entity.entity.json"), StandardCopyOption.REPLACE_EXISTING)

// Loading modules to databases
runTask('mlLoadModules')

// Copying Staging and Final database Index info files to src/main/entity-config dir
Path dir = hubConfig().getEntityDatabaseDir()
if (!dir.toFile().exists()) {
dir.toFile().mkdirs()
}

File dstFile = Paths.get(dir.toString(), HubConfig.STAGING_ENTITY_DATABASE_FILE).toFile()
String entityConfigStream = new File("src/test/resources/update-indexes/staging-database.json").getAbsolutePath()
Files.copy(new File(entityConfigStream).toPath(), dstFile.toPath(), StandardCopyOption.REPLACE_EXISTING)

dstFile = Paths.get(dir.toString(), HubConfig.FINAL_ENTITY_DATABASE_FILE).toFile();
entityConfigStream = new File("src/test/resources/update-indexes/final-database.json").getAbsolutePath()
Files.copy(new File(entityConfigStream).toPath(), dstFile.toPath(), StandardCopyOption.REPLACE_EXISTING)

dir = hubConfig().getHubConfigDir()
dstFile = Paths.get(dir.toString(), "databases", "job-database.json").toFile()
entityConfigStream = new File("src/test/resources/update-indexes/job-database.json").getAbsolutePath();
Files.copy(new File(entityConfigStream).toPath(), dstFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
}


@IgnoreIf({ System.getProperty('mlIsProvisionedEnvironment') })
def "test to deploy indexes to STAGING/FINAL/JOBS Database"() {
given:
int stagingIndexCount = getStagingRangePathIndexSize()
int finalIndexCount = getFinalRangePathIndexSize()
int jobIndexCount = getJobsRangePathIndexSize()

when:
def result = runTask('mlUpdateIndexes')

then:
notThrown(UnexpectedBuildFailure)
result.task(":mlUpdateIndexes").outcome == SUCCESS

assert (getStagingRangePathIndexSize() == stagingIndexCount+1)
assert (getFinalRangePathIndexSize() == finalIndexCount+1)
assert (getJobsRangePathIndexSize() == jobIndexCount+1)
Expand Down

0 comments on commit aa07b49

Please sign in to comment.