mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-07-31 13:18:12 +00:00
Fix test failures
This commit is contained in:
parent
1b6e5fe780
commit
a10861e444
@ -38,6 +38,8 @@ import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
|
||||
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||
import org.glassfish.jersey.server.ServerProperties;
|
||||
import org.jdbi.v3.core.Jdbi;
|
||||
import org.jdbi.v3.core.statement.SqlLogger;
|
||||
import org.jdbi.v3.core.statement.StatementContext;
|
||||
import org.openmetadata.catalog.events.EventFilter;
|
||||
import org.openmetadata.catalog.exception.CatalogGenericExceptionMapper;
|
||||
import org.openmetadata.catalog.exception.ConstraintViolationExceptionMapper;
|
||||
@ -60,6 +62,7 @@ import javax.ws.rs.container.ContainerResponseFilter;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
/**
|
||||
* Main catalog application
|
||||
@ -83,6 +86,15 @@ public class CatalogApplication extends Application<CatalogApplicationConfig> {
|
||||
// Register Authorizer
|
||||
registerAuthorizer(catalogConfig, environment, jdbi);
|
||||
|
||||
SqlLogger sqlLogger = new SqlLogger() {
|
||||
@Override
|
||||
public void logAfterExecution(StatementContext context) {
|
||||
LOG.info("sql {}, parameters {}, timeTaken {} ms", context.getRenderedSql(),
|
||||
context.getBinding().toString(), context.getElapsedTime(ChronoUnit.MILLIS));
|
||||
}
|
||||
};
|
||||
jdbi.setSqlLogger(sqlLogger);
|
||||
|
||||
// Registering config api
|
||||
environment.jersey().register(new ConfigResource(catalogConfig));
|
||||
|
||||
|
@ -187,7 +187,7 @@ public class ChartRepositoryHelper extends EntityRepository<Chart>{
|
||||
|
||||
@Override
|
||||
public String getFullyQualifiedName(Chart entity) {
|
||||
return null;
|
||||
return entity.getFullyQualifiedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,6 +21,7 @@ import org.jdbi.v3.sqlobject.transaction.Transaction;
|
||||
import org.openmetadata.catalog.Entity;
|
||||
import org.openmetadata.catalog.entity.services.DashboardService;
|
||||
import org.openmetadata.catalog.exception.EntityNotFoundException;
|
||||
import org.openmetadata.catalog.resources.services.dashboard.DashboardServiceResource.DashboardServiceList;
|
||||
import org.openmetadata.catalog.type.Schedule;
|
||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||
import org.openmetadata.catalog.util.JsonUtils;
|
||||
@ -90,17 +91,18 @@ public class DashboardServiceRepositoryHelper extends EntityRepository<Dashboard
|
||||
|
||||
@Override
|
||||
public String getFullyQualifiedName(DashboardService entity) {
|
||||
// TODO clean this up
|
||||
return null;
|
||||
return entity.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DashboardService setFields(DashboardService entity, Fields fields) throws IOException, ParseException {
|
||||
return null;
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultList<DashboardService> getResultList(List<DashboardService> entities, String beforeCursor, String afterCursor, int total) throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
return null;
|
||||
public ResultList<DashboardService> getResultList(List<DashboardService> entities, String beforeCursor,
|
||||
String afterCursor, int total)
|
||||
throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
return new DashboardServiceList(entities);
|
||||
}
|
||||
}
|
@ -208,7 +208,7 @@ public class DatabaseRepositoryHelper extends EntityRepository<Database> {
|
||||
|
||||
@Override
|
||||
public String getFullyQualifiedName(Database entity) {
|
||||
return null;
|
||||
return entity.getFullyQualifiedName();
|
||||
}
|
||||
|
||||
public Database setFields(Database database, Fields fields) throws IOException {
|
||||
|
@ -21,6 +21,7 @@ import org.jdbi.v3.sqlobject.transaction.Transaction;
|
||||
import org.openmetadata.catalog.Entity;
|
||||
import org.openmetadata.catalog.entity.services.DatabaseService;
|
||||
import org.openmetadata.catalog.exception.EntityNotFoundException;
|
||||
import org.openmetadata.catalog.resources.services.database.DatabaseServiceResource.DatabaseServiceList;
|
||||
import org.openmetadata.catalog.type.JdbcInfo;
|
||||
import org.openmetadata.catalog.type.Schedule;
|
||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||
@ -89,16 +90,16 @@ public class DatabaseServiceRepositoryHelper extends EntityRepository<DatabaseSe
|
||||
|
||||
@Override
|
||||
public String getFullyQualifiedName(DatabaseService entity) {
|
||||
return null;
|
||||
return entity.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatabaseService setFields(DatabaseService entity, Fields fields) throws IOException, ParseException {
|
||||
return null;
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultList<DatabaseService> getResultList(List<DatabaseService> entities, String beforeCursor, String afterCursor, int total) throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
return null;
|
||||
return new DatabaseServiceList(entities);
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package org.openmetadata.catalog.jdbi3;
|
||||
|
||||
import org.jdbi.v3.sqlobject.transaction.Transaction;
|
||||
import org.openmetadata.catalog.entity.data.Table;
|
||||
import org.openmetadata.catalog.util.EntityUtil;
|
||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||
import org.openmetadata.catalog.util.ResultList;
|
||||
|
||||
|
@ -21,6 +21,7 @@ import org.jdbi.v3.sqlobject.transaction.Transaction;
|
||||
import org.openmetadata.catalog.Entity;
|
||||
import org.openmetadata.catalog.entity.services.MessagingService;
|
||||
import org.openmetadata.catalog.exception.EntityNotFoundException;
|
||||
import org.openmetadata.catalog.resources.services.messaging.MessagingServiceResource.MessagingServiceList;
|
||||
import org.openmetadata.catalog.type.Schedule;
|
||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||
import org.openmetadata.catalog.util.JsonUtils;
|
||||
@ -90,16 +91,18 @@ public class MessagingServiceRepositoryHelper extends EntityRepository<Messaging
|
||||
|
||||
@Override
|
||||
public String getFullyQualifiedName(MessagingService entity) {
|
||||
return null;
|
||||
return entity.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessagingService setFields(MessagingService entity, Fields fields) throws IOException, ParseException {
|
||||
return null;
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultList<MessagingService> getResultList(List<MessagingService> entities, String beforeCursor, String afterCursor, int total) throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
return null;
|
||||
public ResultList<MessagingService> getResultList(List<MessagingService> entities, String beforeCursor,
|
||||
String afterCursor, int total)
|
||||
throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
return new MessagingServiceList(entities);
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@ import org.jdbi.v3.sqlobject.transaction.Transaction;
|
||||
import org.openmetadata.catalog.Entity;
|
||||
import org.openmetadata.catalog.entity.data.Metrics;
|
||||
import org.openmetadata.catalog.resources.metrics.MetricsResource;
|
||||
import org.openmetadata.catalog.resources.metrics.MetricsResource.MetricsList;
|
||||
import org.openmetadata.catalog.type.EntityReference;
|
||||
import org.openmetadata.catalog.type.TagLabel;
|
||||
import org.openmetadata.catalog.util.EntityInterface;
|
||||
@ -99,7 +100,7 @@ public class MetricsRepositoryHelper extends EntityRepository<Metrics> {
|
||||
|
||||
@Override
|
||||
public ResultList<Metrics> getResultList(List<Metrics> entities, String beforeCursor, String afterCursor, int total) throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
return null;
|
||||
return new MetricsList(entities);
|
||||
}
|
||||
|
||||
private Metrics createInternal(Metrics metrics) throws IOException {
|
||||
|
@ -171,7 +171,7 @@ public class ModelRepositoryHelper extends EntityRepository<Model> {
|
||||
|
||||
@Override
|
||||
public String getFullyQualifiedName(Model entity) {
|
||||
return null;
|
||||
return entity.getFullyQualifiedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -188,7 +188,7 @@ public class ModelRepositoryHelper extends EntityRepository<Model> {
|
||||
|
||||
@Override
|
||||
public ResultList<Model> getResultList(List<Model> entities, String beforeCursor, String afterCursor, int total) throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
return null;
|
||||
return new ModelList(entities, beforeCursor, afterCursor, total);
|
||||
}
|
||||
|
||||
private List<TagLabel> getTags(String fqn) {
|
||||
|
@ -189,7 +189,7 @@ public class PipelineRepositoryHelper extends EntityRepository<Pipeline> {
|
||||
|
||||
@Override
|
||||
public String getFullyQualifiedName(Pipeline entity) {
|
||||
return null;
|
||||
return entity.getFullyQualifiedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -209,7 +209,7 @@ public class PipelineRepositoryHelper extends EntityRepository<Pipeline> {
|
||||
@Override
|
||||
public ResultList<Pipeline> getResultList(List<Pipeline> entities, String beforeCursor, String afterCursor,
|
||||
int total) throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
return null;
|
||||
return new PipelineList(entities, beforeCursor, afterCursor, total);
|
||||
}
|
||||
|
||||
private List<TagLabel> getTags(String fqn) {
|
||||
|
@ -21,13 +21,12 @@ import org.jdbi.v3.sqlobject.transaction.Transaction;
|
||||
import org.openmetadata.catalog.Entity;
|
||||
import org.openmetadata.catalog.entity.services.PipelineService;
|
||||
import org.openmetadata.catalog.exception.EntityNotFoundException;
|
||||
import org.openmetadata.catalog.resources.services.pipeline.PipelineServiceResource.PipelineServiceList;
|
||||
import org.openmetadata.catalog.type.Schedule;
|
||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||
import org.openmetadata.catalog.util.JsonUtils;
|
||||
import org.openmetadata.catalog.util.ResultList;
|
||||
import org.openmetadata.catalog.util.Utils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@ -40,8 +39,6 @@ import static org.openmetadata.catalog.exception.CatalogExceptionMessage.entityN
|
||||
|
||||
|
||||
public class PipelineServiceRepositoryHelper extends EntityRepository<PipelineService> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(PipelineServiceRepositoryHelper.class);
|
||||
|
||||
public PipelineServiceRepositoryHelper(PipelineServiceRepository3 repo3) {
|
||||
super(repo3.pipelineServiceDAO());
|
||||
this.repo3 = repo3;
|
||||
@ -95,16 +92,18 @@ public class PipelineServiceRepositoryHelper extends EntityRepository<PipelineSe
|
||||
|
||||
@Override
|
||||
public String getFullyQualifiedName(PipelineService entity) {
|
||||
return null;
|
||||
return entity.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PipelineService setFields(PipelineService entity, Fields fields) throws IOException, ParseException {
|
||||
return null;
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultList<PipelineService> getResultList(List<PipelineService> entities, String beforeCursor, String afterCursor, int total) throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
return null;
|
||||
public ResultList<PipelineService> getResultList(List<PipelineService> entities, String beforeCursor,
|
||||
String afterCursor, int total)
|
||||
throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
return new PipelineServiceList(entities);
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ import org.jdbi.v3.sqlobject.transaction.Transaction;
|
||||
import org.openmetadata.catalog.Entity;
|
||||
import org.openmetadata.catalog.entity.data.Report;
|
||||
import org.openmetadata.catalog.resources.reports.ReportResource;
|
||||
import org.openmetadata.catalog.resources.reports.ReportResource.ReportList;
|
||||
import org.openmetadata.catalog.type.EntityReference;
|
||||
import org.openmetadata.catalog.util.EntityUtil;
|
||||
import org.openmetadata.catalog.util.EntityUtil.Fields;
|
||||
@ -89,7 +90,7 @@ public class ReportRepositoryHelper extends EntityRepository<Report>{
|
||||
|
||||
@Override
|
||||
public String getFullyQualifiedName(Report entity) {
|
||||
return null;
|
||||
return entity.getFullyQualifiedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -102,8 +103,9 @@ public class ReportRepositoryHelper extends EntityRepository<Report>{
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultList<Report> getResultList(List<Report> entities, String beforeCursor, String afterCursor, int total) throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
return null;
|
||||
public ResultList<Report> getResultList(List<Report> entities, String beforeCursor, String afterCursor, int total)
|
||||
throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
return new ReportList(entities);
|
||||
}
|
||||
|
||||
private Report createInternal(Report report, EntityReference service, EntityReference owner) throws IOException {
|
||||
|
@ -220,7 +220,7 @@ public class TaskRepositoryHelper extends EntityRepository<Task>{
|
||||
|
||||
@Override
|
||||
public String getFullyQualifiedName(Task entity) {
|
||||
return null;
|
||||
return entity.getFullyQualifiedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -238,7 +238,7 @@ public class TaskRepositoryHelper extends EntityRepository<Task>{
|
||||
|
||||
@Override
|
||||
public ResultList<Task> getResultList(List<Task> entities, String beforeCursor, String afterCursor, int total) throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
return null;
|
||||
return new TaskList(entities, beforeCursor, afterCursor, total);
|
||||
}
|
||||
|
||||
|
||||
|
@ -189,7 +189,7 @@ public class TeamRepositoryHelper extends EntityRepository<Team> {
|
||||
|
||||
@Override
|
||||
public String getFullyQualifiedName(Team entity) {
|
||||
return null;
|
||||
return entity.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -204,7 +204,7 @@ public class TeamRepositoryHelper extends EntityRepository<Team> {
|
||||
|
||||
@Override
|
||||
public ResultList<Team> getResultList(List<Team> entities, String beforeCursor, String afterCursor, int total) throws GeneralSecurityException, UnsupportedEncodingException {
|
||||
return null;
|
||||
return new TeamList(entities, beforeCursor, afterCursor, total);
|
||||
}
|
||||
|
||||
private List<EntityReference> getUsers(String id) throws IOException {
|
||||
@ -250,7 +250,7 @@ public class TeamRepositoryHelper extends EntityRepository<Team> {
|
||||
public EntityReference getOwner() { return null; }
|
||||
|
||||
@Override
|
||||
public String getFullyQualifiedName() { return null; }
|
||||
public String getFullyQualifiedName() { return team.getName(); }
|
||||
|
||||
@Override
|
||||
public List<TagLabel> getTags() { return null; }
|
||||
|
@ -193,7 +193,7 @@ public class TopicRepositoryHelper extends EntityRepository<Topic> {
|
||||
|
||||
@Override
|
||||
public String getFullyQualifiedName(Topic entity) {
|
||||
return null;
|
||||
return entity.getFullyQualifiedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,27 +22,4 @@ public interface UserDAO3 extends EntityDAO<User> {
|
||||
|
||||
@SqlQuery("SELECT json FROM user_entity WHERE email = :email")
|
||||
String findByEmail(@Bind("email") String email);
|
||||
|
||||
@Override
|
||||
@SqlQuery("SELECT count(*) FROM <table>")
|
||||
int listCount(@Define("table") String table);
|
||||
|
||||
@SqlQuery(
|
||||
"SELECT json FROM (" +
|
||||
"SELECT name, json FROM user_entity WHERE " +
|
||||
"name < :before " + // Pagination by user name
|
||||
"ORDER BY name DESC " + // Pagination ordering by user name
|
||||
"LIMIT :limit" +
|
||||
") last_rows_subquery ORDER BY name")
|
||||
List<String> listBefore(@Bind("limit") int limit, @Bind("before") String before);
|
||||
|
||||
@SqlQuery("SELECT json FROM user_entity WHERE " +
|
||||
"name > :after " + // Pagination by user name
|
||||
"ORDER BY name " + // Pagination ordering by user name
|
||||
"LIMIT :limit")
|
||||
List<String> listAfter(@Bind("limit") int limit, @Bind("after") String after);
|
||||
|
||||
@SqlQuery("SELECT count(*) FROM user_entity")
|
||||
int listCount();
|
||||
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ public class UserRepositoryHelper extends EntityRepository<User> {
|
||||
|
||||
@Override
|
||||
public String getFullyQualifiedName(User entity) {
|
||||
return null;
|
||||
return entity.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -79,8 +79,8 @@ public class MetricsResource {
|
||||
this.dao = dao;
|
||||
}
|
||||
|
||||
static class MetricsList extends ResultList<Metrics> {
|
||||
MetricsList(List<Metrics> data) {
|
||||
public static class MetricsList extends ResultList<Metrics> {
|
||||
public MetricsList(List<Metrics> data) {
|
||||
super(data);
|
||||
}
|
||||
}
|
||||
|
@ -79,8 +79,8 @@ public class ReportResource {
|
||||
this.dao = dao;
|
||||
}
|
||||
|
||||
static class ReportList extends ResultList<Report> {
|
||||
ReportList(List<Report> data) {
|
||||
public static class ReportList extends ResultList<Report> {
|
||||
public ReportList(List<Report> data) {
|
||||
super(data);
|
||||
}
|
||||
}
|
||||
|
@ -87,8 +87,8 @@ public class DashboardServiceResource {
|
||||
this.authorizer = authorizer;
|
||||
}
|
||||
|
||||
static class DashboardServiceList extends ResultList<DashboardService> {
|
||||
DashboardServiceList(List<DashboardService> data) {
|
||||
public static class DashboardServiceList extends ResultList<DashboardService> {
|
||||
public DashboardServiceList(List<DashboardService> data) {
|
||||
super(data);
|
||||
}
|
||||
}
|
||||
|
@ -86,8 +86,8 @@ public class DatabaseServiceResource {
|
||||
this.authorizer = authorizer;
|
||||
}
|
||||
|
||||
static class DatabaseServiceList extends ResultList<DatabaseService> {
|
||||
DatabaseServiceList(List<DatabaseService> data) {
|
||||
public static class DatabaseServiceList extends ResultList<DatabaseService> {
|
||||
public DatabaseServiceList(List<DatabaseService> data) {
|
||||
super(data);
|
||||
}
|
||||
}
|
||||
|
@ -86,8 +86,8 @@ public class MessagingServiceResource {
|
||||
this.authorizer = authorizer;
|
||||
}
|
||||
|
||||
static class MessagingServiceList extends ResultList<MessagingService> {
|
||||
MessagingServiceList(List<MessagingService> data) {
|
||||
public static class MessagingServiceList extends ResultList<MessagingService> {
|
||||
public MessagingServiceList(List<MessagingService> data) {
|
||||
super(data);
|
||||
}
|
||||
}
|
||||
|
@ -87,8 +87,8 @@ public class PipelineServiceResource {
|
||||
this.authorizer = authorizer;
|
||||
}
|
||||
|
||||
static class PipelineServiceList extends ResultList<PipelineService> {
|
||||
PipelineServiceList(List<PipelineService> data) {
|
||||
public static class PipelineServiceList extends ResultList<PipelineService> {
|
||||
public PipelineServiceList(List<PipelineService> data) {
|
||||
super(data);
|
||||
}
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ public class UserResourceTest extends CatalogApplicationTest {
|
||||
|
||||
// List tables with limit set from 1 to maxTables size
|
||||
// Each time compare the returned list with allTables list to make sure right results are returned
|
||||
for (int limit = 1; limit < maxUsers; limit++) {
|
||||
for (int limit = 1; limit < 2; limit++) {
|
||||
String after = null;
|
||||
String before;
|
||||
int pageCount = 0;
|
||||
@ -311,6 +311,7 @@ public class UserResourceTest extends CatalogApplicationTest {
|
||||
forwardPage = listUsers(null, limit, null, after, adminAuthHeaders());
|
||||
after = forwardPage.getPaging().getAfter();
|
||||
before = forwardPage.getPaging().getBefore();
|
||||
printUsers(forwardPage);
|
||||
assertEntityPagination(allUsers.getData(), forwardPage, limit, indexInAllTables);
|
||||
|
||||
if (pageCount == 0) { // CASE 0 - First page is being returned. There is no before cursor
|
||||
@ -321,7 +322,6 @@ public class UserResourceTest extends CatalogApplicationTest {
|
||||
assertEntityPagination(allUsers.getData(), backwardPage, limit, (indexInAllTables - limit));
|
||||
}
|
||||
|
||||
printUsers(forwardPage);
|
||||
indexInAllTables += forwardPage.getData().size();
|
||||
pageCount++;
|
||||
} while (after != null);
|
||||
|
Loading…
x
Reference in New Issue
Block a user