Skip to content

Package: EmbeddedDatastore

EmbeddedDatastore

nameinstructionbranchcomplexitylinemethod
EmbeddedDatastore()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
closeNode()
M: 25 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 12 C: 0
0%
M: 1 C: 0
0%
setup()
M: 25 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 11 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2017, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech
12: * Red Hat Inc
13: *******************************************************************************/
14: package org.eclipse.kapua.qa.common.utils;
15:
16: import cucumber.api.java.en.Given;
17: import cucumber.runtime.java.guice.ScenarioScoped;
18: import org.eclipse.kapua.service.elasticsearch.server.embedded.EsEmbeddedEngine;
19: import org.slf4j.Logger;
20: import org.slf4j.LoggerFactory;
21:
22: import java.io.IOException;
23: import java.time.Duration;
24:
25: /**
26: * Singleton for managing datastore creation and deletion inside Gherkin scenarios.
27: */
28: @ScenarioScoped
29: public class EmbeddedDatastore {
30:
31: private static final Logger LOG = LoggerFactory.getLogger(EmbeddedDatastore.class);
32:
33: private static final int EXTRA_STARTUP_DELAY = Integer.getInteger("org.eclipse.kapua.qa.datastore.extraStartupDelay", 0);
34:
35: private static final boolean NO_EMBEDDED_SERVERS = Boolean.getBoolean("org.eclipse.kapua.qa.noEmbeddedServers");
36:
37: private static EsEmbeddedEngine esEmbeddedEngine;
38:
39:
40: @Given("^Start Datastore$")
41: public void setup() {
42:
43:• if (NO_EMBEDDED_SERVERS) {
44: return;
45: }
46:
47: LOG.info("Starting embedded datastore...");
48: esEmbeddedEngine = new EsEmbeddedEngine();
49:
50:• if (EXTRA_STARTUP_DELAY > 0) {
51: try {
52: Thread.sleep(Duration.ofSeconds(EXTRA_STARTUP_DELAY).toMillis());
53: } catch (InterruptedException e) {
54: e.printStackTrace();
55: }
56: }
57:
58: LOG.info("Starting embedded datastore... DONE!");
59: }
60:
61: @Given("^Stop Datastore$")
62: public void closeNode() throws IOException {
63:
64:• if (NO_EMBEDDED_SERVERS) {
65: return;
66: }
67:
68: LOG.info("Stopping embedded datastore...");
69:• if (EXTRA_STARTUP_DELAY > 0) {
70: try {
71: Thread.sleep(Duration.ofSeconds(EXTRA_STARTUP_DELAY).toMillis());
72: } catch (InterruptedException e) {
73: e.printStackTrace();
74: }
75: }
76:
77:• if (esEmbeddedEngine != null) {
78: esEmbeddedEngine.close();
79: }
80:
81: LOG.info("Stopping embedded datastore... DONE!");
82: }
83: }