OpenLiberty / liberty-arquillian

Arquillian Liberty Managed and Remote containers
Apache License 2.0
11 stars 29 forks source link

Configuration serverName provided is not valid #98

Closed rslemos closed 3 years ago

rslemos commented 3 years ago

I've been working with openliberty for a while now, using the following configuration:

<project ...>
  ...
  <artifactId>liberty-it</artifactId>
  ...
  <build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
      <plugin>
        <groupId>io.openliberty.tools</groupId>
        <artifactId>liberty-maven-plugin</artifactId>
        <version>3.3.4</version>
        <configuration>
          <serverName>${project.artifactId}</serverName>
        </configuration>
      </plugin>
    </plugins>
  </build>
  ...
</project>

But then I tried to introduce integration tests with arquillian, but it choked with (EchoicChamberIT is my test case):

[ERROR] Errors: 
[ERROR]   EchoicChamberIT » Configuration serverName provided is not valid: 'liberty-it'

The culprit is the validation at: https://github.com/OpenLiberty/liberty-arquillian/blob/61fae809561315919b017fcb53a8120dc28e9b94/liberty-managed/src/main/java/io/openliberty/arquillian/managed/WLPManagedContainerConfiguration.java#L78.

As a workaround I removed the serverName configuration from io.openliberty.tools:liberty-maven-plugin (effectively changing serverName to defaultServer, which complies to the validation above).

cherylking commented 3 years ago

Found the following documentation on the allowed characters for serverName, which clearly shows a - is allowed. The line of code @rslemos referenced should be changed accordingly.

https://openliberty.io/docs/21.0.0.3/reference/command/server-create.html

serverName
A name for the server. If no server is specified, a server called defaultServer is automatically created.

Naming constraints:

Use only Unicode alphanumeric (e.g. 0-9, a-z, A-Z), underscore (_), dash (-), plus (+), and period (.) characters.

Do not begin the with a dash (-) or a period (.).

Be aware that your file system, operating system, or compressed file directory might impose more restrictions.
cherylking commented 3 years ago

I believe this regex properly represents the rules listed above: ^[A-Za-z0-9\+_]+[A-Za-z0-9\+_\.-]*$

rslemos commented 3 years ago

The '+' repetition operator in your regex is redundant. Better remove it to ^[A-Za-z0-9\+_][A-Za-z0-9\+_\.-]*$

cherylking commented 3 years ago

The + was intended to require at least one character from the first group before allowing any characters from the last group. I'll double check the regex and test it some more.