blob: a63aee636da159c67257bf32bb94a0d502511a79 [file] [log] [blame]
/*
* 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.runner.app;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Lists;
import org.apache.ignite.app.Ignite;
import org.apache.ignite.app.IgnitionManager;
import org.apache.ignite.internal.testframework.WorkDirectory;
import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
import org.apache.ignite.internal.util.IgniteUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
/**
* Ignition interface tests.
*/
@ExtendWith(WorkDirectoryExtension.class)
class ITIgnitionTest {
/** Nodes bootstrap configuration. */
private final Map<String, String> nodesBootstrapCfg = new LinkedHashMap<>() {{
put("node0", "{\n" +
" \"node\": {\n" +
" \"metastorageNodes\":[ \"node0\" ]\n" +
" },\n" +
" \"network\": {\n" +
" \"port\":3344,\n" +
" \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
" }\n" +
"}");
put("node1", "{\n" +
" \"node\": {\n" +
" \"metastorageNodes\":[ \"node0\" ]\n" +
" },\n" +
" \"network\": {\n" +
" \"port\":3345,\n" +
" \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
" }\n" +
"}");
put("node2", "{\n" +
" \"node\": {\n" +
" \"metastorageNodes\":[ \"node0\" ]\n" +
" },\n" +
" \"network\": {\n" +
" \"port\":3346,\n" +
" \"netClusterNodes\":[ \"localhost:3344\", \"localhost:3345\", \"localhost:3346\" ]\n" +
" }\n" +
"}");
}};
/** */
private final List<Ignite> startedNodes = new ArrayList<>();
/** */
@WorkDirectory
private Path workDir;
/** */
@AfterEach
void tearDown() throws Exception {
IgniteUtils.closeAll(Lists.reverse(startedNodes));
}
/**
* Check that Ignition.start() with bootstrap configuration returns Ignite instance.
*/
@Test
void testNodesStartWithBootstrapConfiguration() {
nodesBootstrapCfg.forEach((nodeName, configStr) ->
startedNodes.add(IgnitionManager.start(nodeName, configStr, workDir.resolve(nodeName)))
);
Assertions.assertEquals(3, startedNodes.size());
startedNodes.forEach(Assertions::assertNotNull);
}
/**
* Check that Ignition.start() with bootstrap configuration returns Ignite instance.
*/
@Test
void testNodeStartWithoutBootstrapConfiguration() throws Exception {
startedNodes.add(IgnitionManager.start("node0", null, workDir));
Assertions.assertNotNull(startedNodes.get(0));
}
}