Search in sources :

Example 1 with LoggingTester

use of io.cdap.cdap.logging.appender.LoggingTester in project cdap by caskdata.

the class TestFileLogging method testGetLogNext.

@Test
public void testGetLogNext() throws Exception {
    LoggingContext loggingContext = new WorkerLoggingContext("TFL_NS_1", "APP_1", "WORKER_1", "RUN1", "INSTANCE1");
    FileLogReader logReader = injector.getInstance(FileLogReader.class);
    LoggingTester tester = new LoggingTester();
    tester.testGetNext(logReader, loggingContext);
}
Also used : LoggingTester(io.cdap.cdap.logging.appender.LoggingTester) WorkerLoggingContext(io.cdap.cdap.logging.context.WorkerLoggingContext) LoggingContext(io.cdap.cdap.common.logging.LoggingContext) WorkerLoggingContext(io.cdap.cdap.logging.context.WorkerLoggingContext) FileLogReader(io.cdap.cdap.logging.read.FileLogReader) Test(org.junit.Test)

Example 2 with LoggingTester

use of io.cdap.cdap.logging.appender.LoggingTester in project cdap by caskdata.

the class TestKafkaLogging method init.

@BeforeClass
public static void init() throws Exception {
    KafkaLogAppender appender = KAFKA_TESTER.getInjector().getInstance(KafkaLogAppender.class);
    new LogAppenderInitializer(appender).initialize("TestKafkaLogging");
    Logger logger = LoggerFactory.getLogger("TestKafkaLogging");
    LoggingTester loggingTester = new LoggingTester();
    loggingTester.generateLogs(logger, new WorkerLoggingContext("TKL_NS_1", "APP_1", "FLOW_1", "RUN1", "INSTANCE1"));
    appender.stop();
}
Also used : LoggingTester(io.cdap.cdap.logging.appender.LoggingTester) LogAppenderInitializer(io.cdap.cdap.logging.appender.LogAppenderInitializer) WorkerLoggingContext(io.cdap.cdap.logging.context.WorkerLoggingContext) Logger(org.slf4j.Logger) BeforeClass(org.junit.BeforeClass)

Example 3 with LoggingTester

use of io.cdap.cdap.logging.appender.LoggingTester in project cdap by caskdata.

the class TestKafkaLogging method testGetNext.

@Test
public void testGetNext() throws Exception {
    // Check with null runId and null instanceId
    LoggingContext loggingContext = new WorkerLoggingContext("TKL_NS_1", "APP_1", "FLOW_1", "RUN1", "INSTANCE1");
    KafkaLogReader logReader = KAFKA_TESTER.getInjector().getInstance(KafkaLogReader.class);
    LoggingTester tester = new LoggingTester();
    tester.testGetNext(logReader, loggingContext);
}
Also used : KafkaLogReader(io.cdap.cdap.logging.read.KafkaLogReader) LoggingTester(io.cdap.cdap.logging.appender.LoggingTester) WorkerLoggingContext(io.cdap.cdap.logging.context.WorkerLoggingContext) LoggingContext(io.cdap.cdap.common.logging.LoggingContext) WorkerLoggingContext(io.cdap.cdap.logging.context.WorkerLoggingContext) Test(org.junit.Test)

Example 4 with LoggingTester

use of io.cdap.cdap.logging.appender.LoggingTester in project cdap by caskdata.

the class TestFileLogging method setUpContext.

@BeforeClass
public static void setUpContext() throws Exception {
    Configuration hConf = HBaseConfiguration.create();
    final CConfiguration cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TMP_FOLDER.newFolder().getAbsolutePath());
    cConf.setInt(LoggingConfiguration.LOG_MAX_FILE_SIZE_BYTES, 20 * 1024);
    String logBaseDir = cConf.get(LoggingConfiguration.LOG_BASE_DIR) + "/" + TestFileLogging.class.getSimpleName();
    cConf.set(LoggingConfiguration.LOG_BASE_DIR, logBaseDir);
    injector = Guice.createInjector(new ConfigModule(cConf, hConf), new NonCustomLocationUnitTestModule(), new TransactionModules().getInMemoryModules(), new LocalLogAppenderModule(), new DataSetsModules().getInMemoryModules(), new SystemDatasetRuntimeModule().getInMemoryModules(), new AuthorizationTestModule(), new AuthorizationEnforcementModule().getInMemoryModules(), new AuthenticationContextModules().getNoOpModule(), new StorageModule(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class);
            bind(OwnerAdmin.class).to(DefaultOwnerAdmin.class);
            bind(UGIProvider.class).to(UnsupportedUGIProvider.class);
            bind(NamespaceQueryAdmin.class).to(SimpleNamespaceQueryAdmin.class);
        }
    });
    txManager = injector.getInstance(TransactionManager.class);
    txManager.startAndWait();
    StoreDefinition.LogFileMetaStore.create(injector.getInstance(StructuredTableAdmin.class));
    LogAppender appender = injector.getInstance(LocalLogAppender.class);
    new LogAppenderInitializer(appender).initialize("TestFileLogging");
    Logger logger = LoggerFactory.getLogger("TestFileLogging");
    LoggingTester loggingTester = new LoggingTester();
    loggingTester.generateLogs(logger, new WorkerLoggingContext("TFL_NS_1", "APP_1", "WORKER_1", "RUN1", "INSTANCE1"));
    appender.stop();
}
Also used : StorageModule(io.cdap.cdap.data.runtime.StorageModule) WorkerLoggingContext(io.cdap.cdap.logging.context.WorkerLoggingContext) Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) LoggingConfiguration(io.cdap.cdap.logging.LoggingConfiguration) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) StructuredTableAdmin(io.cdap.cdap.spi.data.StructuredTableAdmin) LogAppender(io.cdap.cdap.logging.appender.LogAppender) LocalLogAppender(io.cdap.cdap.logging.framework.local.LocalLogAppender) UGIProvider(io.cdap.cdap.security.impersonation.UGIProvider) UnsupportedUGIProvider(io.cdap.cdap.security.impersonation.UnsupportedUGIProvider) Logger(org.slf4j.Logger) LoggingTester(io.cdap.cdap.logging.appender.LoggingTester) LogAppenderInitializer(io.cdap.cdap.logging.appender.LogAppenderInitializer) NamespaceQueryAdmin(io.cdap.cdap.common.namespace.NamespaceQueryAdmin) SimpleNamespaceQueryAdmin(io.cdap.cdap.common.namespace.SimpleNamespaceQueryAdmin) SystemDatasetRuntimeModule(io.cdap.cdap.data.runtime.SystemDatasetRuntimeModule) NoOpMetricsCollectionService(io.cdap.cdap.common.metrics.NoOpMetricsCollectionService) MetricsCollectionService(io.cdap.cdap.api.metrics.MetricsCollectionService) AuthenticationContextModules(io.cdap.cdap.security.auth.context.AuthenticationContextModules) DataSetsModules(io.cdap.cdap.data.runtime.DataSetsModules) DefaultOwnerAdmin(io.cdap.cdap.security.impersonation.DefaultOwnerAdmin) OwnerAdmin(io.cdap.cdap.security.impersonation.OwnerAdmin) NonCustomLocationUnitTestModule(io.cdap.cdap.common.guice.NonCustomLocationUnitTestModule) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) AuthorizationTestModule(io.cdap.cdap.security.authorization.AuthorizationTestModule) AbstractModule(com.google.inject.AbstractModule) TransactionModules(org.apache.tephra.runtime.TransactionModules) LocalLogAppenderModule(io.cdap.cdap.logging.guice.LocalLogAppenderModule) TransactionManager(org.apache.tephra.TransactionManager) AuthorizationEnforcementModule(io.cdap.cdap.security.authorization.AuthorizationEnforcementModule) BeforeClass(org.junit.BeforeClass)

Example 5 with LoggingTester

use of io.cdap.cdap.logging.appender.LoggingTester in project cdap by caskdata.

the class TestFileLogging method testGetLogPrev.

@Test
public void testGetLogPrev() throws Exception {
    LoggingContext loggingContext = new WorkerLoggingContext("TFL_NS_1", "APP_1", "WORKER_1", "RUN1", "INSTANCE1");
    FileLogReader logReader = injector.getInstance(FileLogReader.class);
    LoggingTester tester = new LoggingTester();
    tester.testGetPrev(logReader, loggingContext);
}
Also used : LoggingTester(io.cdap.cdap.logging.appender.LoggingTester) WorkerLoggingContext(io.cdap.cdap.logging.context.WorkerLoggingContext) LoggingContext(io.cdap.cdap.common.logging.LoggingContext) WorkerLoggingContext(io.cdap.cdap.logging.context.WorkerLoggingContext) FileLogReader(io.cdap.cdap.logging.read.FileLogReader) Test(org.junit.Test)

Aggregations

LoggingTester (io.cdap.cdap.logging.appender.LoggingTester)7 WorkerLoggingContext (io.cdap.cdap.logging.context.WorkerLoggingContext)6 LoggingContext (io.cdap.cdap.common.logging.LoggingContext)5 Test (org.junit.Test)5 LogAppenderInitializer (io.cdap.cdap.logging.appender.LogAppenderInitializer)3 Logger (org.slf4j.Logger)3 FileLogReader (io.cdap.cdap.logging.read.FileLogReader)2 KafkaLogReader (io.cdap.cdap.logging.read.KafkaLogReader)2 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)1 AbstractModule (com.google.inject.AbstractModule)1 MetricsCollectionService (io.cdap.cdap.api.metrics.MetricsCollectionService)1 CConfiguration (io.cdap.cdap.common.conf.CConfiguration)1 ConfigModule (io.cdap.cdap.common.guice.ConfigModule)1 NonCustomLocationUnitTestModule (io.cdap.cdap.common.guice.NonCustomLocationUnitTestModule)1 NoOpMetricsCollectionService (io.cdap.cdap.common.metrics.NoOpMetricsCollectionService)1 NamespaceQueryAdmin (io.cdap.cdap.common.namespace.NamespaceQueryAdmin)1 SimpleNamespaceQueryAdmin (io.cdap.cdap.common.namespace.SimpleNamespaceQueryAdmin)1 DataSetsModules (io.cdap.cdap.data.runtime.DataSetsModules)1 StorageModule (io.cdap.cdap.data.runtime.StorageModule)1 SystemDatasetRuntimeModule (io.cdap.cdap.data.runtime.SystemDatasetRuntimeModule)1