Модульный тест WSO2 на Дженкинсе - PullRequest
0 голосов
/ 28 января 2020

Итак, я пытаюсь выкинуть sh этот CD / CI для WSO2 на конвейере Jenkins с файлом jenkinsfile. У меня есть проект Multi Maven. Этот проект имеет простой модульный тест.

Когда я запускаю «mvn clean install» в папке проекта, он прекрасно работает, но когда jenkins делает это, он не может найти файл.

I изучил код подключения и не мог понять, откуда берется путь, который он пытается использовать. Тем не менее, путь действителен, поэтому я предполагаю, что контекст, из которого он запускается, отключен, и, поскольку я не знаю, откуда этот путь идет, я не могу принудительно указать полный путь.

Кто-нибудь сталкивался с этой проблемой раньше или есть идеи, как ее исправить?

Ниже я приведу несколько ссылок, дайте мне знать, что еще вам нужно.

Команда использовала оба в приглашении cmd и jenkinsfile

mvn -e -X clean install -DtestServerType=local -DtestServerPort=9008 -DtestServerPath=C:\\IntegrationStudio\\runtime\\microesb\\bin\\micro-integrator.bat"

журнал Maven запускает приглашение cmd

[INFO] --- synapse-unit-test-maven-plugin:5.2.10:synapse-unit-test (synapse-unit-test) @ HelloWorld ---
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=57600, ConflictMarker.markTime=33000, ConflictMarker.nodeCount=24, ConflictIdSorter.graphTime=119400, ConflictIdSorter.topsortTime=16200, ConflictIdSorter.conflictIdCount=21, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=325500, ConflictResolver.conflictItemCount=24, DefaultDependencyCollector.collectTime=149066200, DefaultDependencyCollector.transformTime=572800}
[DEBUG] org.wso2.maven:synapse-unit-test-maven-plugin:jar:5.2.10
[DEBUG]    org.apache.maven:maven-plugin-api:jar:3.0:compile
[DEBUG]       org.apache.maven:maven-model:jar:3.0:compile
[DEBUG]          org.codehaus.plexus:plexus-utils:jar:2.0.4:compile
[DEBUG]       org.apache.maven:maven-artifact:jar:3.0:compile
[DEBUG]       org.sonatype.sisu:sisu-inject-plexus:jar:1.4.2:compile
[DEBUG]          org.codehaus.plexus:plexus-component-annotations:jar:1.5.4:compile
[DEBUG]          org.codehaus.plexus:plexus-classworlds:jar:2.2.3:compile
[DEBUG]          org.sonatype.sisu:sisu-inject-bean:jar:1.4.2:compile
[DEBUG]             org.sonatype.sisu:sisu-guice:jar:noaop:2.1.7:compile
[DEBUG]    commons-io:commons-io:jar:2.4:compile
[DEBUG]    org.apache.ws.commons.axiom:axiom-impl:jar:1.2.20:compile
[DEBUG]       org.apache.ws.commons.axiom:axiom-api:jar:1.2.20:compile
[DEBUG]          org.apache.geronimo.specs:geronimo-activation_1.1_spec:jar:1.1:compile
[DEBUG]          jaxen:jaxen:jar:1.1.6:compile
[DEBUG]          org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0.1:compile
[DEBUG]          org.apache.james:apache-mime4j-core:jar:0.7.2:compile
[DEBUG]       org.codehaus.woodstox:woodstox-core-asl:jar:4.2.0:compile
[DEBUG]          org.codehaus.woodstox:stax2-api:jar:3.1.1:compile
[DEBUG]       commons-logging:commons-logging:jar:1.2:compile
[DEBUG]    com.google.code.gson:gson:jar:2.8.2:compile
[DEBUG] Created new class realm plugin>org.wso2.maven:synapse-unit-test-maven-plugin:5.2.10
[DEBUG] Importing foreign packages into class realm plugin>org.wso2.maven:synapse-unit-test-maven-plugin:5.2.10
[DEBUG]   Imported:  < project>com.example.HelloWorld:HelloWorld:1.0.0
[DEBUG] Populating class realm plugin>org.wso2.maven:synapse-unit-test-maven-plugin:5.2.10
[DEBUG]   Included: org.wso2.maven:synapse-unit-test-maven-plugin:jar:5.2.10
[DEBUG]   Included: org.codehaus.plexus:plexus-utils:jar:2.0.4
[DEBUG]   Included: org.codehaus.plexus:plexus-component-annotations:jar:1.5.4
[DEBUG]   Included: org.sonatype.sisu:sisu-inject-bean:jar:1.4.2
[DEBUG]   Included: org.sonatype.sisu:sisu-guice:jar:noaop:2.1.7
[DEBUG]   Included: commons-io:commons-io:jar:2.4
[DEBUG]   Included: org.apache.ws.commons.axiom:axiom-impl:jar:1.2.20
[DEBUG]   Included: org.apache.ws.commons.axiom:axiom-api:jar:1.2.20
[DEBUG]   Included: org.apache.geronimo.specs:geronimo-activation_1.1_spec:jar:1.1
[DEBUG]   Included: jaxen:jaxen:jar:1.1.6
[DEBUG]   Included: org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0.1
[DEBUG]   Included: org.apache.james:apache-mime4j-core:jar:0.7.2
[DEBUG]   Included: org.codehaus.woodstox:woodstox-core-asl:jar:4.2.0
[DEBUG]   Included: org.codehaus.woodstox:stax2-api:jar:3.1.1
[DEBUG]   Included: commons-logging:commons-logging:jar:1.2
[DEBUG]   Included: com.google.code.gson:gson:jar:2.8.2
[DEBUG] Configuring mojo org.wso2.maven:synapse-unit-test-maven-plugin:5.2.10:synapse-unit-test from plugin realm ClassRealm[plugin>org.wso2.maven:synapse-unit-test-maven-plugin:5.2.10, parent: sun.misc.Launcher$AppClassLoader@4e25154f]
[DEBUG] Configuring mojo 'org.wso2.maven:synapse-unit-test-maven-plugin:5.2.10:synapse-unit-test' with basic configurator -->
[DEBUG]   (f) mavenTestSkip = false
[DEBUG]   (f) testServerType = local
[DEBUG]   (f) testServerPort = 9008
[DEBUG]   (f) testServerPath = C:\IntegrationStudio\runtime\microesb\bin\micro-integrator.bat
[DEBUG]   (f) server = org.wso2.synapse.unittest.SynapseServer@2160e52a
[DEBUG]   (f) testCasesFilePath = C:\Users\mpires\IntegrationStudio\workspace\HelloWorldMaster\HelloWorld\test\${testFile}
[DEBUG] -- end configuration --
[INFO] ------------------------------------------------------------------------
[INFO] U N I T - T E S T S
[INFO] ------------------------------------------------------------------------
[INFO] Detect 1 Synapse test case files to execute
[INFO]
[INFO] Starting unit testing agent of path - C:\IntegrationStudio\runtime\microesb\bin\micro-integrator.bat
[INFO] Waiting for testing agent initialization
[INFO]
[DEBUG] [2020-01-28 10:35:25,603]  INFO {org.apache.synapse.core.axis2.Axis2SynapseEnvironment} - Synapse unit testing server enabled
[DEBUG] [2020-01-28 10:35:25,616]  INFO {org.apache.synapse.unittest.UnitTestingExecutor} - Unit testing agent started
[DEBUG] [2020-01-28 10:35:25,618]  INFO {org.apache.synapse.unittest.UnitTestingExecutor} - Synapse unit testing agent has been established on port 9008
[INFO] SynapseTestCaseFile C:\Users\mpires\IntegrationStudio\workspace\HelloWorldMaster\HelloWorld\test\helloWorldTest.xml tested successfully

журнал Maven от Jenkins

[INFO] --- synapse-unit-test-maven-plugin:5.2.10:synapse-unit-test (synapse-unit-test) @ HelloWorld ---
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=24700, ConflictMarker.markTime=18500, ConflictMarker.nodeCount=24, ConflictIdSorter.graphTime=9500, ConflictIdSorter.topsortTime=17000, ConflictIdSorter.conflictIdCount=21, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=335600, ConflictResolver.conflictItemCount=24, DefaultDependencyCollector.collectTime=112537900, DefaultDependencyCollector.transformTime=427600}
[DEBUG] org.wso2.maven:synapse-unit-test-maven-plugin:jar:5.2.10
[DEBUG]    org.apache.maven:maven-plugin-api:jar:3.0:compile
[DEBUG]       org.apache.maven:maven-model:jar:3.0:compile
[DEBUG]          org.codehaus.plexus:plexus-utils:jar:2.0.4:compile
[DEBUG]       org.apache.maven:maven-artifact:jar:3.0:compile
[DEBUG]       org.sonatype.sisu:sisu-inject-plexus:jar:1.4.2:compile
[DEBUG]          org.codehaus.plexus:plexus-component-annotations:jar:1.5.4:compile
[DEBUG]          org.codehaus.plexus:plexus-classworlds:jar:2.2.3:compile
[DEBUG]          org.sonatype.sisu:sisu-inject-bean:jar:1.4.2:compile
[DEBUG]             org.sonatype.sisu:sisu-guice:jar:noaop:2.1.7:compile
[DEBUG]    commons-io:commons-io:jar:2.4:compile
[DEBUG]    org.apache.ws.commons.axiom:axiom-impl:jar:1.2.20:compile
[DEBUG]       org.apache.ws.commons.axiom:axiom-api:jar:1.2.20:compile
[DEBUG]          org.apache.geronimo.specs:geronimo-activation_1.1_spec:jar:1.1:compile
[DEBUG]          jaxen:jaxen:jar:1.1.6:compile
[DEBUG]          org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0.1:compile
[DEBUG]          org.apache.james:apache-mime4j-core:jar:0.7.2:compile
[DEBUG]       org.codehaus.woodstox:woodstox-core-asl:jar:4.2.0:compile
[DEBUG]          org.codehaus.woodstox:stax2-api:jar:3.1.1:compile
[DEBUG]       commons-logging:commons-logging:jar:1.2:compile
[DEBUG]    com.google.code.gson:gson:jar:2.8.2:compile
[DEBUG] Created new class realm plugin>org.wso2.maven:synapse-unit-test-maven-plugin:5.2.10
[DEBUG] Importing foreign packages into class realm plugin>org.wso2.maven:synapse-unit-test-maven-plugin:5.2.10
[DEBUG]   Imported:  < project>com.example.HelloWorld:HelloWorld:1.0.0
[DEBUG] Populating class realm plugin>org.wso2.maven:synapse-unit-test-maven-plugin:5.2.10
[DEBUG]   Included: org.wso2.maven:synapse-unit-test-maven-plugin:jar:5.2.10
[DEBUG]   Included: org.codehaus.plexus:plexus-utils:jar:2.0.4
[DEBUG]   Included: org.codehaus.plexus:plexus-component-annotations:jar:1.5.4
[DEBUG]   Included: org.sonatype.sisu:sisu-inject-bean:jar:1.4.2
[DEBUG]   Included: org.sonatype.sisu:sisu-guice:jar:noaop:2.1.7
[DEBUG]   Included: commons-io:commons-io:jar:2.4
[DEBUG]   Included: org.apache.ws.commons.axiom:axiom-impl:jar:1.2.20
[DEBUG]   Included: org.apache.ws.commons.axiom:axiom-api:jar:1.2.20
[DEBUG]   Included: org.apache.geronimo.specs:geronimo-activation_1.1_spec:jar:1.1
[DEBUG]   Included: jaxen:jaxen:jar:1.1.6
[DEBUG]   Included: org.apache.geronimo.specs:geronimo-stax-api_1.0_spec:jar:1.0.1
[DEBUG]   Included: org.apache.james:apache-mime4j-core:jar:0.7.2
[DEBUG]   Included: org.codehaus.woodstox:woodstox-core-asl:jar:4.2.0
[DEBUG]   Included: org.codehaus.woodstox:stax2-api:jar:3.1.1
[DEBUG]   Included: commons-logging:commons-logging:jar:1.2
[DEBUG]   Included: com.google.code.gson:gson:jar:2.8.2
[DEBUG] Configuring mojo org.wso2.maven:synapse-unit-test-maven-plugin:5.2.10:synapse-unit-test from plugin realm ClassRealm[plugin>org.wso2.maven:synapse-unit-test-maven-plugin:5.2.10, parent: sun.misc.Launcher$AppClassLoader@4e25154f]
[DEBUG] Configuring mojo 'org.wso2.maven:synapse-unit-test-maven-plugin:5.2.10:synapse-unit-test' with basic configurator -->
[DEBUG]   (f) mavenTestSkip = false
[DEBUG]   (f) testServerType = local
[DEBUG]   (f) testServerPort = 9008
[DEBUG]   (f) testServerPath = C:\IntegrationStudio\runtime\microesb\bin\micro-integrator.bat
[DEBUG]   (f) server = org.wso2.synapse.unittest.SynapseServer@1460c81d
[DEBUG]   (f) testCasesFilePath = C:\Jenkins\workspace\WSO2HelloWorldPipeline\HelloWorld\test\${testFile}
[DEBUG] -- end configuration --
[INFO] ------------------------------------------------------------------------
[INFO] U N I T - T E S T S
[INFO] ------------------------------------------------------------------------
[INFO] Detect 1 Synapse test case files to execute
[INFO] 
[INFO] Starting unit testing agent of path - C:\IntegrationStudio\runtime\microesb\bin\micro-integrator.bat
[INFO] Waiting for testing agent initialization
[INFO] 
[DEBUG] [2020-01-28 10:22:20,457]  INFO {org.apache.synapse.core.axis2.Axis2SynapseEnvironment} - Synapse unit testing server enabled
[DEBUG] [2020-01-28 10:22:20,498]  INFO {org.apache.synapse.unittest.UnitTestingExecutor} - Unit testing agent started
[DEBUG] [2020-01-28 10:22:20,499]  INFO {org.apache.synapse.unittest.UnitTestingExecutor} - Synapse unit testing agent has been established on port 9008
[error] Artifact data reading failed 

java.io.FileNotFoundException: File '..\HelloWorld\src\main\synapse-config\api\helloWorld.xml' does not exist
    at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:299)
    at org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:1711)
    at org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:1748)
    at org.wso2.synapse.unittest.SynapseTestCaseFileReader.processTestArtifactData(SynapseTestCaseFileReader.java:126)
    at org.wso2.synapse.unittest.SynapseTestCaseFileReader.processArtifactData(SynapseTestCaseFileReader.java:82)
    at org.wso2.synapse.unittest.UnitTestClient.executeTests(UnitTestClient.java:50)
    at org.wso2.synapse.unittest.UnitTestCasesMojo.testCaseRunner(UnitTestCasesMojo.java:143)
    at org.wso2.synapse.unittest.UnitTestCasesMojo.execute(UnitTestCasesMojo.java:78)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)

[error] Error in creating deployable message
[INFO] No test cases found in C:\Jenkins\workspace\WSO2HelloWorldPipeline\HelloWorld\test\helloWorldTest.xml unit test suite

HelloWorld POM

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example.HelloWorld</groupId>
  <artifactId>HelloWorld</artifactId>
  <version>1.0.0</version>
  <packaging>pom</packaging>
  <name>HelloWorld</name>
  <description>HelloWorld</description>
  <parent>
        <groupId>com.example</groupId>
        <artifactId>HelloWorldProject</artifactId>
        <version>1.0.0</version>
   </parent>
  <properties>
    <CApp.type>bpel/workflow=zip,lib/registry/filter=jar,webapp/jaxws=war,lib/library/bundle=jar,service/dataservice=dbs,synapse/local-entry=xml,synapse/proxy-service=xml,carbon/application=car,registry/resource=zip,lib/dataservice/validator=jar,synapse/endpoint=xml,web/application=war,lib/carbon/ui=jar,service/axis2=aar,synapse/sequence=xml,synapse/configuration=xml,wso2/gadget=dar,lib/registry/handlers=jar,lib/synapse/mediator=jar,synapse/task=xml,synapse/api=xml,synapse/template=xml,synapse/message-store=xml,synapse/message-processors=xml,synapse/inbound-endpoint=xml</CApp.type>
    <maven.test.skip>false</maven.test.skip>
  </properties>

  <repositories>
    <repository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>daily</updatePolicy>
        <checksumPolicy>ignore</checksumPolicy>
      </releases>
      <id>wso2-nexus</id>
      <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>daily</updatePolicy>
        <checksumPolicy>ignore</checksumPolicy>
      </releases>
      <id>wso2-nexus</id>
      <url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
    </pluginRepository>
  </pluginRepositories>
  <build>
    <directory>target/capp</directory>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.4.0</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>package</id>
            <phase>package</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>mvn</executable>
              <workingDirectory>${project.build.directory}</workingDirectory>
              <arguments>
                <argument>clean</argument>
                <argument>package</argument>
                <argument>-Dmaven.test.skip=${maven.test.skip}</argument>
              </arguments>
            </configuration>
          </execution>
          <execution>
            <id>install</id>
            <phase>install</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>mvn</executable>
              <workingDirectory>${project.build.directory}</workingDirectory>
              <arguments>
                <argument>clean</argument>
                <argument>install</argument>
                <argument>-Dmaven.test.skip=${maven.test.skip}</argument>
              </arguments>
            </configuration>
          </execution>
          <execution>
            <id>deploy</id>
            <phase>deploy</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>mvn</executable>
              <workingDirectory>${project.build.directory}</workingDirectory>
              <arguments>
                <argument>deploy</argument>
                <argument>-Dmaven.test.skip=${maven.test.skip}</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
        <configuration />
      </plugin>
      <plugin>
        <artifactId>maven-eclipse-plugin</artifactId>
        <version>2.9</version>
        <configuration>
          <buildcommands />
          <projectnatures>
            <projectnature>org.wso2.developerstudio.eclipse.esb.project.nature</projectnature>
          </projectnatures>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.wso2.maven</groupId>
        <artifactId>synapse-unit-test-maven-plugin</artifactId>
        <version>5.2.10</version>
        <executions>
          <execution>
            <id>synapse-unit-test</id>
            <phase>test</phase>
            <goals>
              <goal>synapse-unit-test</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <server>
            <testServerType>${testServerType}</testServerType>
            <testServerHost>${testServerHost}</testServerHost>
            <testServerPort>${testServerPort}</testServerPort>
            <testServerPath>${testServerPath}</testServerPath>
          </server>
          <testCasesFilePath>${project.basedir}\test\${testFile}</testCasesFilePath>
          <mavenTestSkip>${maven.test.skip}</mavenTestSkip>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.wso2.maven</groupId>
        <artifactId>wso2-esb-api-plugin</artifactId>
        <version>2.1.0</version>
        <extensions>true</extensions>
        <executions>
          <execution>
            <id>api</id>
            <phase>process-resources</phase>
            <goals>
              <goal>pom-gen</goal>
            </goals>
            <configuration>
              <artifactLocation>.</artifactLocation>
              <typeList>${artifact.types}</typeList>
            </configuration>
          </execution>
        </executions>
        <configuration />
      </plugin>
    </plugins>
  </build>
</project>

1 Ответ

0 голосов
/ 29 января 2020

Итак, как я и подозревал, проблема вызвана теми надоедливыми ..\, которые приводят к тому, что путь становится недействительным, и, насколько я знаю, это ошибка в коде подключения, потому что нет причин для этого.

Код работал, когда я работал на консоли, потому что я был внутри HelloWorld, когда я пытался запустить его с того же root, что и jenkins, я столкнулся с теми же проблемами.

Я открыл билет по номеру https://github.com/wso2/maven-tools/issues/51 и в качестве обходного пути я разделил свою команду maven между тестовым прогоном и установкой без теста и выполнил тест изнутри в испорченном каталоге.

Недостаток Этот обходной путь заключается в том, что если у вас есть более одного xml файла, который необходимо протестировать, он, скорее всего, сломается.

код обходного пути:

dir(APP_NAME){

                    bat "mvn -e clean test -DtestServerType=local -DtestServerPort=9008 -DtestServerPath=C:\\IntegrationStudio\\runtime\\microesb\\bin\\micro-integrator.bat" //-Dmaven.test.skip=true" 
                }

                bat "mvn -e clean install -Dmaven.test.skip=true"
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...