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

[#2436] feat(IT): Add catalogs page to web e2e test #2528

Merged
merged 3 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
@@ -0,0 +1,156 @@
/*
* Copyright 2024 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/

package com.datastrato.gravitino.integration.test.web.ui;

import com.datastrato.gravitino.integration.test.container.ContainerSuite;
import com.datastrato.gravitino.integration.test.container.HiveContainer;
import com.datastrato.gravitino.integration.test.web.ui.pages.CatalogsPage;
import com.datastrato.gravitino.integration.test.web.ui.pages.MetalakePage;
import com.datastrato.gravitino.integration.test.web.ui.utils.AbstractWebIT;
import org.apache.hadoop.hive.conf.HiveConf;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;

@Tag("gravitino-docker-it")
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class CatalogsPageTest extends AbstractWebIT {
private static final ContainerSuite containerSuite = ContainerSuite.getInstance();
MetalakePage metalakePage = new MetalakePage();
CatalogsPage catalogsPage = new CatalogsPage();

private static final String metalakeName = "metalake_name";
String catalogName = "catalog_name";
String modifiedCatalogName = catalogName + "_edited";
String schemaName = "default";
String tableName = "employee";

@BeforeAll
public static void before() {
containerSuite.startHiveContainer();

// Initial hive client
HiveConf hiveConf = new HiveConf();
String hiveMetastoreUris =
String.format(
"thrift://%s:%d",
containerSuite.getHiveContainer().getContainerIpAddress(),
HiveContainer.HIVE_METASTORE_PORT);
hiveConf.set(HiveConf.ConfVars.METASTOREURIS.varname, hiveMetastoreUris);
}

@AfterAll
public static void after() {
try {
closer.close();
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
}

@Test
@Order(1)
public void testCreateHiveCatalog() throws InterruptedException {
// Create metalake first
clickAndWait(metalakePage.createMetalakeBtn);
metalakePage.setMetalakeNameField(metalakeName);
clickAndWait(metalakePage.submitHandleMetalakeBtn);
metalakePage.clickMetalakeLink(metalakeName);
// Create catalog
clickAndWait(catalogsPage.createCatalogBtn);
catalogsPage.setCatalogNameField(catalogName);
catalogsPage.setCatalogCommentField("catalog comment");
String hiveMetastoreUris =
String.format(
"thrift://%s:%d",
containerSuite.getHiveContainer().getContainerIpAddress(),
HiveContainer.HIVE_METASTORE_PORT);
catalogsPage.setHiveCatalogURI(hiveMetastoreUris);
catalogsPage.addCatalogPropsBtn.click();
catalogsPage.setCatalogProps(1, "key1", "value1");
catalogsPage.addCatalogPropsBtn.click();
catalogsPage.setCatalogProps(2, "key2", "value2");
clickAndWait(catalogsPage.handleSubmitCatalogBtn);

Assertions.assertTrue(catalogsPage.verifyCreateHiveCatalog(catalogName));
}

Copy link
Contributor

Choose a reason for hiding this comment

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

We can add a test case testCreateMultipleCatalogs and check the render table data is correct values when switch different catalog tree nodes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because other providers of catalogs require different environments, I will add these tests in the next pull request.

@Test
@Order(2)
public void testRefreshPage() {
driver.navigate().refresh();
Assertions.assertEquals(driver.getTitle(), "Gravitino");
Assertions.assertTrue(catalogsPage.verifyRefreshPage());
}

@Test
@Order(3)
public void testViewTabMetalakeDetails() throws InterruptedException {
clickAndWait(catalogsPage.tabDetailsBtn);
Assertions.assertTrue(catalogsPage.verifyShowDetailsContent());
clickAndWait(catalogsPage.tabTableBtn);
Assertions.assertTrue(catalogsPage.verifyShowTableContent());
}

@Test
@Order(4)
public void testViewCatalogDetails() throws InterruptedException {
catalogsPage.clickViewCatalogBtn(catalogName);
Assertions.assertTrue(catalogsPage.verifyShowCatalogDetails(catalogName));
}

@Test
@Order(5)
public void testEditCatalog() throws InterruptedException {
catalogsPage.clickEditCatalogBtn(catalogName);
catalogsPage.setCatalogNameField(modifiedCatalogName);
clickAndWait(catalogsPage.handleSubmitCatalogBtn);
Assertions.assertTrue(catalogsPage.verifyEditedCatalog(modifiedCatalogName));
}

@Test
@Order(6)
public void testClickCatalogLink() {
catalogsPage.clickCatalogLink(metalakeName, modifiedCatalogName);
Assertions.assertTrue(catalogsPage.verifyShowTableTitle("Schemas"));
}

@Test
@Order(7)
public void testClickSchemaLink() {
catalogsPage.clickSchemaLink(metalakeName, modifiedCatalogName, schemaName);
Assertions.assertTrue(catalogsPage.verifyShowTableTitle("Tables"));
}

@Test
@Order(8)
public void testClickTableLink() {
catalogsPage.clickTableLink(metalakeName, modifiedCatalogName, schemaName, tableName);
Assertions.assertTrue(catalogsPage.verifyShowTableTitle("Columns"));
Assertions.assertTrue(catalogsPage.verifyTableColumns());
}

@Test
@Order(9)
public void testDeleteCatalog() throws InterruptedException {
catalogsPage.clickBreadCrumbsToCatalogs();
catalogsPage.clickDeleteCatalogBtn(modifiedCatalogName);
clickAndWait(catalogsPage.confirmDeleteBtn);
Assertions.assertTrue(catalogsPage.verifyEmptyCatalog());
}

@Test
@Order(10)
public void testBackHomePage() throws InterruptedException {
clickAndWait(catalogsPage.backHomeBtn);
Assertions.assertTrue(catalogsPage.verifyBackHomePage());
}
}
Loading
Loading