/** * @throws Exception If fail. */ @Test public void testNoExceptionOnServerNode() throws Exception { ldr = new URLClassLoader(URLS, getClass().getClassLoader()); clientMode = false; setExternalLoader = true; final Ignite ignite0 = startGrid(1); executeContinuousQuery(ignite0.cache("simple")); log = new GridStringLogger(); startGrid(2); assertTrue(!log.toString().contains("class org.apache.ignite.IgniteCheckedException: " + "Failed to find class with given class loader for unmarshalling")); }
/** * @param e Exception. * @param msg Log message. * @param isLogExpected Is log expected or not. */ private void check(Exception e, String msg, boolean isLogExpected) { String sep = System.getProperty("line.separator"); if (isLogExpected) { String s = msg; if (e != null) s += sep + "java.lang.RuntimeException: " + e.getMessage(); assertTrue(log0.toString().contains(s)); } else assertEquals(log0.toString(), ""); log0.reset(); } }
/** {@inheritDoc} */ @Override public synchronized void error(String msg, @Nullable Throwable e) { log(msg); if (e != null) logThrowable(e); }
/** */ @Override protected void beforeTest() throws Exception { super.beforeTest(); strLog = new GridStringLogger(false, log); strLog.logLength(1024 * 1024); }
/** * @throws Exception If failed. */ @Test public void testJulMessage() throws Exception { this.strLog = new GridStringLogger(true); strLog.logLength(300000); startGrid(0); assertTrue(strLog.toString().contains("LongJVMPauseDetector was successfully started")); }
/** * @throws Exception If failed. */ @Test public void testPdsDirWarningSuppressed() throws Exception { startGrid(); assertFalse(log0.toString().contains(WARN_MSG_PREFIX)); }
/** Check that dev-only messages appear in the log. */ @Test public void testDevOnlyVerboseMessage() throws Exception { additionalArgs = Collections.singletonList("-D" + IgniteSystemProperties.IGNITE_QUIET + "=false"); log = new GridStringLogger(false, grid(0).log()); Ignite ignite = startGrid(1); String msg = getMessage(ignite); warnDevOnly(msg); assertTrue(log.toString().contains(msg)); }
final GridStringLogger strLog = new GridStringLogger(false, log); assertTrue("No expected message in log: " + strLog.toString(), strLog.toString().contains("Cache mode mismatch")); strLog.reset(); assertTrue("No expected message in log: " + strLog.toString(), strLog.toString().contains("Cache mode mismatch"));
/** {@inheritDoc} */ @Override public void trace(String msg) { log(msg); }
/** * @param msg Message to log. */ private synchronized void log(String msg) { buf.append(msg).append(U.nl()); if (echo != null) echo.info("[GridStringLogger echo] " + msg); int logLength = logLength(); if (buf.length() > logLength) { if (echo != null) echo.warning("Cleaning GridStringLogger history."); buf.delete(0, buf.length() - logLength); } assert buf.length() <= logLength; }
/** * */ @Test public void testIgnoreNestedTxAutocommitOn() throws SQLException { try (Connection c = c(true, NestedTxMode.IGNORE)) { doNestedTxStart(c, false); } assertTrue(log.toString().contains("ignoring BEGIN command")); }
GridStringLogger gridStrLog = new GridStringLogger(); gridStrLog.logLength(1024 * 100); .collect(Collectors.toSet()); String log = gridStrLog.toString(); boolean containsMsg = log.contains("Setting the rebalance pool size has no effect on the client mode");
/** Check that dev-only messages appear in the log. */ @Ignore("https://issues.apache.org/jira/browse/IGNITE-9328") @Test public void testDevOnlyQuietMessage() throws Exception { additionalArgs = Collections.singletonList("-D" + IgniteSystemProperties.IGNITE_QUIET + "=true"); log = new GridStringLogger(false, grid(0).log()); Ignite ignite = startGrid(1); String msg = getMessage(ignite); warnDevOnly(msg); assertTrue(log.toString().contains(msg)); }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); if (srvcCfg != null) cfg.setServiceConfiguration(srvcCfg); if (useStrLog) { GridStringLogger strLog = new GridStringLogger(false, cfg.getGridLogger()); strLog.logLength(100 * 1024); cfg.setGridLogger(strLog); strLoggers.add(strLog); } return cfg; }
/** {@inheritDoc} */ @Override public void debug(String msg) { log(msg); }
/** * @throws Exception If fail. */ @Test public void testNoWarningMessageOnClientNode() throws Exception { ldr = new URLClassLoader(URLS, getClass().getClassLoader()); setExternalLoader = true; clientMode = false; final Ignite ignite0 = startGrid(1); executeContinuousQuery(ignite0.cache("simple")); log = new GridStringLogger(); clientMode = true; startGrid(2); assertTrue(!log.toString().contains("Failed to unmarshal continuous query remote filter on client node. " + "Can be ignored.")); }
/** * */ @Test public void testCommitNestedTxAutocommitOffBatched() throws SQLException { try (Connection c = c(false, NestedTxMode.COMMIT)) { doNestedTxStart(c, true); } assertFalse(log.toString().contains("ignoring BEGIN command")); }
GridStringLogger strLog = this.strLog = new GridStringLogger(); strLog.logLength(1024 * 100); String log = strLog.toString();
/** * Check that {@link IgniteUtils#warnDevOnly(IgniteLogger, Object)} * doesn't print anything if {@link org.apache.ignite.IgniteSystemProperties#IGNITE_DEV_ONLY_LOGGING_DISABLED} * is set to {@code true}. */ @Test public void testDevOnlyDisabledProperty() throws Exception { additionalArgs = Collections.singletonList("-D" + IgniteSystemProperties.IGNITE_DEV_ONLY_LOGGING_DISABLED + "=true"); log = new GridStringLogger(false, grid(0).log()); Ignite ignite = startGrid(1); String msg = getMessage(ignite); warnDevOnly(msg); assertFalse(log.toString().contains(msg)); }
/** * @throws Exception In case of an error. */ @Test public void testEntryWriteCreateTable() throws Exception { Ignite ignite = startGridWithLogCapture(); IgniteCache def = ignite.createCache("default"); def.query(new SqlFieldsQuery("CREATE TABLE binary (id INT PRIMARY KEY, str VARCHAR) " + "WITH \"cache_name=binary, key_type=IdKey, value_type=Payload\"").setSchema("PUBLIC")); IgniteCache<Integer, Payload> binary = ignite.cache("binary"); binary.put(1, new Payload("foo")); binary.put(2, new Payload("bar")); assertEquals(0, countRows(binary)); assertContainsExactlyOnce(capture.toString(), MESSAGE_PAYLOAD_VALUE); capture.reset(); def.query(new SqlFieldsQuery("CREATE TABLE binary2 (id INT PRIMARY KEY, str VARCHAR) " + "WITH \"cache_name=binary2, key_type=IdKey, value_type=Payload\"").setSchema("PUBLIC")); IgniteCache<Integer, Payload> binary2 = ignite.cache("binary2"); binary2.put(1, new Payload("foo")); binary2.put(2, new Payload("bar")); assertEquals(0, countRows(binary2)); assertContainsExactlyOnce(capture.toString(), MESSAGE_PAYLOAD_VALUE); }