Skip to content

Commit

Permalink
Merge pull request #25205 from dmatej/filelocking
Browse files Browse the repository at this point in the history
Updated domain.xml file management + CI for windows
  • Loading branch information
dmatej authored Nov 6, 2024
2 parents 06b0486 + 5da1bac commit c354344
Show file tree
Hide file tree
Showing 33 changed files with 472 additions and 1,236 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

name: Build on Windows 2022

on:
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: windows-2022

steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Install Maven
run: |
curl.exe -o ./apache-maven-3.9.9-bin.zip https://dlcdn.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.zip
tar -xf ./apache-maven-3.9.9-bin.zip
- name: Build with Maven
# qa skips documentation - we check it on Jenkins CI
# We skip checkstyle too - we check it on Jenkins CI
run: ./apache-maven-3.9.9/bin/mvn -B -e clean install -Pstaging -Pqa '-Dcheckstyle.skip=true'

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
* Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -39,7 +40,7 @@ public class Util {
private static GlassFishRuntime glassfishRuntime;

public static synchronized GlassFish startGlassFish(String serverID, String installRoot,
String instanceRoot, String configFileURI,
String instanceRoot, String configFile,
boolean configFileReadOnly, int httpPort)
throws GlassFishException {
GlassFish glassfish = gfMap.get(serverID);
Expand All @@ -58,12 +59,12 @@ public static synchronized GlassFish startGlassFish(String serverID, String inst
if (instanceRoot != null) {
glassfishProperties.setInstanceRoot(instanceRoot);
}
if (configFileURI != null) {
glassfishProperties.setConfigFileURI(configFileURI);
if (configFile != null) {
glassfishProperties.setConfigFileURI(new File(configFile).toURI().toString());
glassfishProperties.setConfigFileReadOnly(configFileReadOnly);
}

if (instanceRoot==null && configFileURI==null) {
if (instanceRoot == null && configFile == null) {
// only set port if embedded domain.xml is used
if (httpPort != -1) {
glassfishProperties.setPort("http-listener", httpPort);
Expand Down Expand Up @@ -92,7 +93,7 @@ public static void deploy(String app, String serverId, List<String> deployParams
Deployer deployer = glassfish.getDeployer();
final int len = deployParams.size();
if (len > 0) {
deployer.deploy(new File(app).toURI(), deployParams.toArray(new String[len]));
deployer.deploy(new File(app).toURI(), deployParams.toArray(String[]::new));
System.out.println("Deployed [" + app + "] with parameters " + deployParams);
} else {
deployer.deploy(new File(app).toURI());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023 Contributors to the Eclipse Foundation.
* Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation.
* Copyright (c) 2009, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -184,8 +184,9 @@ private Locations createContainer(Map<?, ?> properties, Locations l) throws EJBE
_logger.info("[EJBContainerProviderImpl] Using instance location: " + l.instance_root.getCanonicalPath());
glassFishProperties.setInstanceRoot(l.instance_root.getCanonicalPath());
} else if (l.domain_file != null) {
_logger.info("[EJBContainerProviderImpl] Using config file location: " + l.domain_file.toURI().toString());
glassFishProperties.setConfigFileURI(l.domain_file.toURI().toString());
String cfgFileUri = l.domain_file.toURI().toString();
_logger.info("[EJBContainerProviderImpl] Using config file location: " + cfgFileUri);
glassFishProperties.setConfigFileURI(cfgFileUri);
}
addWebContainerIfRequested(properties, glassFishProperties);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import static org.hamcrest.Matchers.stringContainsInOrder;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;


/**
Expand All @@ -51,12 +52,15 @@ public class OSGiCommandsITest {

@BeforeAll
public static void waitOsgiReady() throws Exception {
for (int i = 0; i < 5; i++) {
long timeout = System.currentTimeMillis() + 10_000L;
while (System.currentTimeMillis() < timeout) {
AsadminResult result = ASADMIN.exec("osgi", "lb");
if (!result.isError()) {
return;
}
Thread.yield();
}
fail("Timeout 10 s when waiting for OSGi to be ready");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.glassfish.main.itest.tools.asadmin.StartServ;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
Expand All @@ -32,6 +33,7 @@
import static org.glassfish.main.itest.tools.asadmin.AsadminResultMatcher.asadminOK;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.condition.OS.WINDOWS;

/**
* @author Ondro Mihalyi
Expand Down Expand Up @@ -65,6 +67,7 @@ public void startServerInForeground(StartServ startServ) {

@ParameterizedTest
@ArgumentsSource(StartServArgumentsProvider.class)
@DisabledOnOs(value = WINDOWS, disabledReason = "startserv.bat is just trivial and doesn't give the error output")
public void reportCorrectErrorIfAlreadyRunning(StartServ startServ) {
try {
AsadminResult result = startServ.withTextToWaitFor("Total startup time including CLI").exec(STARTSERV_DOMAIN_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,33 +43,34 @@

public class ConfigTest {

public static final Logger logger = Logger.getLogger(ConfigTest.class.getName());
private static final Logger LOG = Logger.getLogger(ConfigTest.class.getName());

static GlassFishRuntime runtime;
private static GlassFishRuntime runtime;

@BeforeAll
static void bootStrap() throws GlassFishException {
runtime = GlassFishRuntime.bootstrap();
runtime = GlassFishRuntime.bootstrap();
}


@ParameterizedTest
@ArgumentsSource(ConfigFileArgumentsProvider.class)
void testConfigFile(String configFile) throws GlassFishException, IOException, URISyntaxException {
void testConfigFile(String configFile) throws Exception {
GlassFishProperties gfp = new GlassFishProperties();
gfp.setConfigFileURI(configFile);

GlassFish instance1 = runtime.newGlassFish(gfp);
logger.info(() -> "Instance1 created" + instance1);
LOG.info(() -> "Instance1 created" + instance1);
instance1.start();
logger.info("Instance1 started #1");
LOG.info("Instance1 started #1");

final String domainName = instance1.getService(Domain.class).getName();
assertTrue("myDomain".equals(domainName), "Domain name is " + domainName);

instance1.stop();
logger.info("Instance1 stopped #1");
LOG.info("Instance1 stopped #1");
instance1.dispose();
logger.info("Instance1 disposed");
LOG.info("Instance1 disposed");
checkDisposed();
}

Expand All @@ -91,7 +92,7 @@ private String fileInClassPath() throws URISyntaxException, IOException {
// throws exception if the temp dir is not cleaned out.
private void checkDisposed() {
String instanceRoot = System.getProperty("com.sun.aas.instanceRoot");
logger.info(() -> "Checking whether " + instanceRoot + " is disposed or not");
LOG.info(() -> "Checking whether " + instanceRoot + " is disposed or not");
if (new File(instanceRoot).exists()) {
throw new RuntimeException("Directory " + instanceRoot +
" is not cleaned up after glassfish.dispose()");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation.
* Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -39,9 +40,4 @@ class DasReaderFilter extends ServerReaderFilter {
boolean filterOut() throws XMLStreamException {
return false;
}

@Override
String configWasFound() {
return null;
}
}
Loading

0 comments on commit c354344

Please sign in to comment.