Skip to content

Commit

Permalink
it: add testing-server module
Browse files Browse the repository at this point in the history
  • Loading branch information
ibodrov committed Nov 8, 2023
1 parent 73d1347 commit ce2f95d
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 0 deletions.
2 changes: 2 additions & 0 deletions it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<module>runtime-v1</module>
<module>runtime-v2</module>
<module>compat</module>

<module>testing-server</module>
</modules>

<properties>
Expand Down
49 changes: 49 additions & 0 deletions it/testing-server/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.walmartlabs.concord.it</groupId>
<artifactId>parent</artifactId>
<version>2.1.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>testing-concord-server</artifactId>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>com.walmartlabs.concord.server</groupId>
<artifactId>concord-server</artifactId>
<exclusions>
<exclusion>
<groupId>com.walmartlabs.concord.server.plugins.ansible</groupId>
<artifactId>concord-ansible-plugin</artifactId>
</exclusion>
<exclusion>
<groupId>com.walmartlabs.concord.server.plugins</groupId>
<artifactId>concord-oneops-plugin</artifactId>
</exclusion>
<exclusion>
<groupId>com.walmartlabs.concord.server.plugins.noderoster</groupId>
<artifactId>concord-noderoster-plugin</artifactId>
</exclusion>
<exclusion>
<groupId>com.walmartlabs.concord.server.plugins</groupId>
<artifactId>pfed-sso</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.walmartlabs.concord.it.testingserver;

/*-
* *****
* Concord
* -----
* Copyright (C) 2017 - 2023 Walmart Inc.
* -----
* Licensed 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.
* =====
*/

import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import com.typesafe.config.ConfigParseOptions;
import com.typesafe.config.ConfigResolveOptions;
import com.walmartlabs.concord.server.ConcordServer;
import com.walmartlabs.concord.server.ConcordServerModule;
import org.testcontainers.containers.PostgreSQLContainer;

import java.util.Map;

public class TestConcordServer {

private PostgreSQLContainer<?> db;
private ConcordServer server;

public TestConcordServer start() throws Exception {
db = new PostgreSQLContainer<>("postgres:15-alpine");
db.start();

server = ConcordServer.withModules(new ConcordServerModule(prepareConfig(db)))
.start();

return this;
}

public void stop() throws Exception {
if (server != null) {
server.stop();
server = null;
}

if (db != null) {
db.stop();
db = null;
}
}

private static Config prepareConfig(PostgreSQLContainer<?> db) {
Config testConfig = ConfigFactory.parseMap(Map.of(
"db.url", db.getJdbcUrl(),
"db.appUsername", db.getUsername(),
"db.appPassword", db.getPassword(),
"db.inventoryUsername", db.getUsername(),
"db.inventoryPassword", db.getPassword(),
"db.changeLogParameters.defaultAdminToken", "foobar",
"secretStore.serverPassword", "bWljYQ==",
"secretStore.secretStoreSalt", "bWljYQ==",
"secretStore.projectSecretSalt", "bWljYQ=="
));

Config defaultConfig = ConfigFactory.load("concord-server.conf", ConfigParseOptions.defaults(), ConfigResolveOptions.defaults().setAllowUnresolved(true))
.getConfig("concord-server");

return testConfig.withFallback(defaultConfig).resolve();
}

public static void main(String[] args) throws Exception {
TestConcordServer server = new TestConcordServer().start();
Thread.sleep(100000);
server.stop();
}
}

0 comments on commit ce2f95d

Please sign in to comment.