-
Notifications
You must be signed in to change notification settings - Fork 138
IGNITE-26345 Wrap ExceptionInInitializerError that happens in contructor of IgniteImpl when launched without JVM options "--add-opens=..." #7606
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ac003ea
IGNITE-26345 Error handling during ignite server start process is add…
JAkutenshi a81a925
IGNITE-26345 Javadoc fix
JAkutenshi 33e0479
IGNITE-26345 Move error handler out of common sync method to handle o…
JAkutenshi 8f0f6fa
IGNITE-26345 Review fixes
JAkutenshi 329480d
IGNITE-26345 Error messages in tests are fixed
JAkutenshi 571d874
IGNITE-26345 TODOs are added
JAkutenshi 2096c83
Merge branch 'main' into ignite-26345
JAkutenshi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
174 changes: 174 additions & 0 deletions
174
modules/runner/src/test/java/org/apache/ignite/internal/app/IgniteServerStartTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,174 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * 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 org.apache.ignite.internal.app; | ||
|
|
||
| import static java.util.concurrent.CompletableFuture.failedFuture; | ||
| import static org.apache.ignite.internal.testframework.IgniteTestUtils.assertThrows; | ||
| import static org.apache.ignite.internal.testframework.TestIgnitionManager.DEFAULT_CONFIG_NAME; | ||
| import static org.apache.ignite.internal.testframework.TestIgnitionManager.writeConfigurationFile; | ||
| import static org.apache.ignite.internal.util.Constants.MiB; | ||
| import static org.hamcrest.MatcherAssert.assertThat; | ||
| import static org.hamcrest.Matchers.equalToObject; | ||
| import static org.hamcrest.Matchers.is; | ||
| import static org.hamcrest.Matchers.notNullValue; | ||
| import static org.mockito.Mockito.reset; | ||
| import static org.mockito.Mockito.spy; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| import java.io.IOException; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import org.apache.ignite.IgniteServer; | ||
| import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest; | ||
| import org.apache.ignite.internal.testframework.WorkDirectory; | ||
| import org.apache.ignite.internal.testframework.WorkDirectoryExtension; | ||
| import org.apache.ignite.lang.NodeStartException; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.extension.ExtendWith; | ||
|
|
||
| /** | ||
| * Test for {@link IgniteServer} starting and errors handling during the process. | ||
| */ | ||
| @ExtendWith(WorkDirectoryExtension.class) | ||
| public class IgniteServerStartTest extends BaseIgniteAbstractTest { | ||
| private static final int IGNITE_SERVER_PORT = 3344; | ||
|
|
||
| private static final String IGNITE_SERVER_NAME = "test-node-" + IGNITE_SERVER_PORT; | ||
|
|
||
| private static final String IGNITE_SERVER_CONFIGURATION = "ignite {\n" | ||
| + " network: {\n" | ||
| + " port: " + IGNITE_SERVER_PORT + ",\n" | ||
| + " nodeFinder.netClusterNodes: [ \"localhost:" + IGNITE_SERVER_PORT + "\" ]\n" | ||
| + " },\n" | ||
| + " clientConnector.port: 10800,\n" | ||
| + " rest.port: 10300,\n" | ||
| + " failureHandler.dumpThreadsOnFailure: false,\n" | ||
| + " storage.profiles.default {engine: aipersist, sizeBytes: " + 256 * MiB + "}\n" | ||
| + "}"; | ||
|
|
||
| @WorkDirectory | ||
| private static Path workDir; | ||
|
|
||
| private IgniteServer server; | ||
|
|
||
| @BeforeEach | ||
| public void createIgniteServerMock() throws IOException { | ||
| server = spy(createIgniteServer()); | ||
| } | ||
|
|
||
| private static IgniteServer createIgniteServer() throws IOException { | ||
| Files.createDirectories(workDir); | ||
| Path configPath = workDir.resolve(DEFAULT_CONFIG_NAME); | ||
|
|
||
| writeConfigurationFile(IGNITE_SERVER_CONFIGURATION, configPath); | ||
|
|
||
| return IgniteServer | ||
| .builder(IGNITE_SERVER_NAME, configPath, workDir) | ||
| .build(); | ||
| } | ||
|
|
||
| @AfterEach | ||
| public void shutdownIgniteServerMock() { | ||
| if (server == null) { | ||
| return; | ||
| } | ||
|
|
||
| reset(server); | ||
|
|
||
| server.shutdown(); | ||
| } | ||
|
|
||
| @Test | ||
| void igniteServerStartTest() { | ||
| Assertions.assertDoesNotThrow(() -> server.start()); | ||
| } | ||
|
|
||
| @Test | ||
| void errorDuringIgniteServerStartTest() { | ||
| Error error = new Error("Test error."); | ||
|
|
||
| when(server.startAsync()).thenReturn(failedFuture(error)); | ||
|
|
||
| NodeStartException exception = assertThrows( | ||
| NodeStartException.class, | ||
| server::start, | ||
| "Error occurred during node start, make sure that classpath and JVM execution arguments are correct." | ||
| ); | ||
|
|
||
| Throwable cause = exception.getCause(); | ||
| assertThat(cause, is(notNullValue())); | ||
| assertThat(cause, is(equalToObject(error))); | ||
| } | ||
|
|
||
| @Test | ||
| void initializerErrorWithoutCauseDuringIgniteServerStartTest() { | ||
| ExceptionInInitializerError initializerError = new ExceptionInInitializerError("Test initializer error."); | ||
|
|
||
| when(server.startAsync()).thenReturn(failedFuture(initializerError)); | ||
|
|
||
| NodeStartException exception = assertThrows( | ||
| NodeStartException.class, | ||
| server::start, | ||
| "Error during static components initialization with unknown cause, " | ||
| + "make sure that classpath and JVM execution arguments are correct." | ||
| ); | ||
|
|
||
| Throwable cause = exception.getCause(); | ||
| assertThat(cause, is(notNullValue())); | ||
| assertThat(cause, is(equalToObject(initializerError))); | ||
| } | ||
|
|
||
| @Test | ||
| void initializerErrorWithIllegalAccessCauseDuringIgniteServerStartTest() { | ||
| IllegalAccessException illegalAccessCause = new IllegalAccessException("Test illegal access exception."); | ||
| ExceptionInInitializerError initializerError = new ExceptionInInitializerError(illegalAccessCause); | ||
|
|
||
| when(server.startAsync()).thenReturn(failedFuture(initializerError)); | ||
|
|
||
| NodeStartException exception = assertThrows( | ||
| NodeStartException.class, | ||
| server::start, | ||
| "Error during static components initialization due to illegal code access, check --add-opens JVM execution arguments." | ||
| ); | ||
|
|
||
| Throwable cause = exception.getCause(); | ||
| assertThat(cause, is(notNullValue())); | ||
| assertThat(cause, is(equalToObject(illegalAccessCause))); | ||
| } | ||
|
|
||
| @Test | ||
| void initializerErrorWithCommonCauseDuringIgniteServerStartTest() { | ||
| Throwable commonCause = new Throwable("Test common exception."); | ||
| ExceptionInInitializerError initializerError = new ExceptionInInitializerError(commonCause); | ||
|
|
||
| when(server.startAsync()).thenReturn(failedFuture(initializerError)); | ||
|
|
||
| NodeStartException exception = assertThrows( | ||
| NodeStartException.class, | ||
| server::start, | ||
| "Error during static components initialization, make sure that classpath and JVM execution arguments are correct." | ||
| ); | ||
|
|
||
| Throwable cause = exception.getCause(); | ||
| assertThat(cause, is(notNullValue())); | ||
| assertThat(cause, is(equalToObject(commonCause))); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.