Skip to content

Commit a8333fd

Browse files
authored
Add registry init to beforeclass (#2982)
* Add registry init to beforeclass Signed-off-by: Paul Bastide <pbastide@us.ibm.com> * Update to workflow and debug Signed-off-by: Paul Bastide <pbastide@us.ibm.com> * Increase the port range for Wiremock Signed-off-by: Paul Bastide <pbastide@us.ibm.com> * Update for different ports in use Signed-off-by: Paul Bastide <pbastide@us.ibm.com> * Update to remove trace Signed-off-by: Paul Bastide <pbastide@us.ibm.com> * Remove Multithreaded, getting unreliable build times Signed-off-by: Paul Bastide <pbastide@us.ibm.com>
1 parent 167acbd commit a8333fd

5 files changed

Lines changed: 48 additions & 18 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ jobs:
116116
echo "Using profiles ${PROFILES}"
117117
mvn -B org.apache.maven.plugins:maven-dependency-plugin:3.1.2:go-offline -f fhir-parent --no-transfer-progress -DexcludeReactor=true -Dmaven.wagon.http.retryHandler.count=3
118118
mvn -B org.apache.maven.plugins:maven-dependency-plugin:3.1.2:resolve-plugins -f fhir-parent --no-transfer-progress -DexcludeReactor=true -Dmaven.wagon.http.retryHandler.count=3
119-
mvn -B -T2C package --file fhir-parent -P "${PROFILES}" --no-transfer-progress -Dmaven.wagon.httpconnectionManager.ttlSeconds=240 -Dmaven.wagon.http.retryHandler.count=3
119+
mvn -B package --file fhir-parent -P "${PROFILES}" --no-transfer-progress -Dmaven.wagon.httpconnectionManager.ttlSeconds=240 -Dmaven.wagon.http.retryHandler.count=3
120120
e2e-tests:
121121
runs-on: ubuntu-latest
122122
if: "!contains(github.event.pull_request.labels.*.name, 'ci-skip')"

.github/workflows/site.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
pushd $(pwd)
6262
cd fhir/docs/
6363
npm install yarn -g
64-
yarn install -g gatsby-cli
64+
yarn global add gatsby-cli
6565
gatsby telemetry --disable
6666
6767
# Install the packages

cql/fhir-cql-rest/src/test/java/com/ibm/fhir/cql/engine/rest/R4RestFHIRTest.java

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
1313

1414
import java.io.ByteArrayOutputStream;
15+
import java.io.IOException;
16+
import java.net.ServerSocket;
1517
import java.util.ArrayList;
1618
import java.util.List;
1719
import java.util.Properties;
@@ -24,7 +26,6 @@
2426
import com.github.tomakehurst.wiremock.client.MappingBuilder;
2527
import com.github.tomakehurst.wiremock.client.WireMock;
2628
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
27-
2829
import com.ibm.fhir.client.FHIRClient;
2930
import com.ibm.fhir.client.FHIRClientFactory;
3031
import com.ibm.fhir.model.format.Format;
@@ -56,44 +57,57 @@
5657
* to configure that web container to respond to specific URL patterns
5758
* with specific responses. The simplest request mapping is for a client
5859
* to provide a URL and a resource and the container will return that
59-
* resource in response to a request for that URL. More complex
60+
* resource in response to a request for that URL. More complex
6061
* URL-building is possible using the Wiremock MappingBuilder class.
61-
* See Wiremocks documentation for full details.
62+
* See Wiremocks documentation for full details.
6263
*/
6364
public abstract class R4RestFHIRTest {
64-
65+
6566
public static final String HOSTNAME = "localhost";
66-
public static final int PORT = 7070;
67+
public static final int PORT = getPort();
6768

6869
protected static WireMockServer wireMockServer;
6970
protected static WireMock wireMock;
70-
71+
72+
private static int getPort() {
73+
// Finds an available port.
74+
int port = 53900;
75+
while (port < 54000) {
76+
try (ServerSocket ignored = new ServerSocket(port)) {
77+
return port;
78+
} catch (IOException ex) {
79+
port++;
80+
}
81+
}
82+
throw new AssertionError("Unexpected that port range is unavailable");
83+
}
84+
7185
@BeforeClass
72-
public static void setupServer() {
73-
86+
public void setupServer() {
87+
7488
WireMockConfiguration wireMockConfig = WireMockConfiguration.wireMockConfig();
7589
wireMockConfig.port(PORT);
76-
90+
7791
wireMockServer = new WireMockServer(wireMockConfig);
7892
wireMockServer.start();
79-
93+
8094
WireMock.configureFor(HOSTNAME, PORT);
8195
wireMock = new WireMock(HOSTNAME, PORT);
8296
}
83-
97+
8498
@AfterClass
85-
public static void serverShutdown() {
99+
public void serverShutdown() {
86100
wireMockServer.stop();
87101
}
88-
102+
89103
public static String getHttpHost() {
90104
return wireMockServer.baseUrl();
91105
}
92106

93107
public static String getBaseUrl() {
94108
return wireMockServer.baseUrl();
95109
}
96-
110+
97111
@BeforeMethod
98112
public void init() throws InterruptedException {
99113
WireMock.resetToDefault();
@@ -119,9 +133,9 @@ public static int getHttpPort() {
119133
public FHIRClient newClient() throws Exception {
120134
Properties properties = new Properties();
121135
properties.setProperty(FHIRClient.PROPNAME_BASE_URL, getBaseUrl());
122-
properties.setProperty(FHIRClient.PROPNAME_LOGGING_ENABLED, "true");
136+
// Logging should be off in CICD
137+
properties.setProperty(FHIRClient.PROPNAME_LOGGING_ENABLED, "false");
123138
FHIRClient client = FHIRClientFactory.getClient(properties);
124-
125139
return client;
126140
}
127141

fhir-profile/src/test/java/com/ibm/fhir/profile/test/BPConstraintGeneratorTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,21 @@
1212
import java.util.logging.LogRecord;
1313
import java.util.logging.Logger;
1414

15+
import org.testng.annotations.BeforeClass;
16+
1517
import com.ibm.fhir.model.annotation.Constraint;
1618
import com.ibm.fhir.model.resource.StructureDefinition;
1719
import com.ibm.fhir.profile.ConstraintGenerator;
1820
import com.ibm.fhir.profile.ProfileSupport;
21+
import com.ibm.fhir.registry.FHIRRegistry;
1922

2023
public class BPConstraintGeneratorTest {
24+
@BeforeClass
25+
public void before() {
26+
FHIRRegistry.getInstance();
27+
FHIRRegistry.init();
28+
}
29+
2130
public static void main(String[] args) throws Exception {
2231
Logger logger = Logger.getLogger(ConstraintGenerator.class.getName());
2332
logger.setLevel(Level.FINEST);

fhir-profile/src/test/java/com/ibm/fhir/profile/test/ConstraintGeneratorTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import com.ibm.fhir.profile.ConstraintGenerator;
4343
import com.ibm.fhir.profile.ProfileBuilder;
4444
import com.ibm.fhir.profile.ProfileSupport;
45+
import com.ibm.fhir.registry.FHIRRegistry;
4546

4647
public class ConstraintGeneratorTest {
4748
// maintain a strong reference to the logger configured for these unit tests
@@ -52,6 +53,12 @@ public void beforeClass() {
5253
configureLogging();
5354
}
5455

56+
@BeforeClass
57+
public void before() {
58+
FHIRRegistry.getInstance();
59+
FHIRRegistry.init();
60+
}
61+
5562
@Test
5663
public static void testConstraintGenerator1() throws Exception {
5764
StructureDefinition profile = new ProfileBuilder(Organization.class, "http://ibm.com/fhir/StructureDefinition/TestOrganization", "1.0.0")

0 commit comments

Comments
 (0)