Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIF-1498 - Setup IT project for CIF components #347

Merged
merged 13 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions .circleci/ci/it-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@ try {
// Connect to QP
ci.sh('./qp.sh -v bind --server-hostname localhost --server-port 55555');

// The core components are already installed in the Cloud SDK
let extras = '';
if (process.env.AEM == 'classic') {
extras = '--bundle com.adobe.cq:core.wcm.components.all:2.9.0:zip';
}

// Start CQ
ci.sh(`./qp.sh -v start --id author --runmode author --port 4502 --qs-jar /home/circleci/cq/author/cq-quickstart.jar \
--bundle org.apache.sling:org.apache.sling.junit.core:1.0.23:jar \
--bundle com.adobe.commerce.cif:graphql-client:1.6.0:jar \
--bundle com.adobe.commerce.cif:magento-graphql:6.0.0-magento235:jar \
--bundle com.adobe.cq:core.wcm.components.all:2.9.0:zip \
--bundle com.adobe.commerce.cif:graphql-client:1.6.1:jar \
--bundle com.adobe.commerce.cif:magento-graphql:6.0.0-magento235:jar ${extras} \
--bundle com.adobe.cq:core.wcm.components.examples.ui.apps:2.9.0:zip \
--bundle com.adobe.cq:core.wcm.components.examples.ui.content:2.9.0:zip \
${ci.addQpFileDependency(config.modules['core-cif-components-apps'])} \
Expand All @@ -45,10 +50,36 @@ try {
--vm-options \\\"-Xmx1536m -XX:MaxPermSize=256m -Djava.awt.headless=true -javaagent:${process.env.JACOCO_AGENT}=destfile=crx-quickstart/jacoco-it.exec\\\"`);
});

// Run integration tests
ci.sh(`mvn clean verify -U -B \
-Ptest-all \
-Dsling.it.instance.url.1=http://localhost:4502 \
-Dsling.it.instance.runmode.1=author \
-Dsling.it.instances=1`);

ci.dir(qpPath, () => {
// Stop CQ
ci.sh('./qp.sh -v stop --id author');
});

// Create coverage reports
const createCoverageReport = () => {
// Executing the integration tests runs also executes unit tests and generates a Jacoco report for them. To
// strictly separate unit test from integration test coverage, we explicitly delete the unit test report first.
ci.sh('rm -rf target/site/jacoco');

// Download Jacoco file which is exposed by a webserver running inside the AEM container.
ci.sh('curl -O -f http://localhost:3000/crx-quickstart/jacoco-it.exec');

// Generate new report
ci.sh(`mvn -B org.jacoco:jacoco-maven-plugin:${process.env.JACOCO_VERSION}:report -Djacoco.dataFile=jacoco-it.exec`);

// Upload report to codecov
ci.sh('curl -s https://codecov.io/bash | bash -s -- -c -F integration -f target/site/jacoco/jacoco.xml');
};

ci.dir('bundles/core', createCoverageReport);
ci.dir('examples/bundle', createCoverageReport);

} finally { // Always download logs from AEM container
ci.sh('mkdir logs');
Expand Down
23 changes: 16 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,19 @@ common:
- run:
name: Integration tests
command: node .circleci/ci/it-tests.js
- store_test_results:
path: it/http/target/failsafe-reports
# Save test results as artifacts
- store_artifacts:
path: it/http/target/failsafe-reports
# Save AEM logs as artifacts
- store_artifacts:
path: logs
# Save Jacoco coverage report as artifact
- store_artifacts:
path: bundles/core/target/site/jacoco
- store_artifacts:
path: examples/bundle/target/site/jacoco

docker_auth: &docker_auth
auth:
Expand Down Expand Up @@ -60,13 +71,9 @@ jobs:
- examples/ui.apps/target/*.zip
- examples/ui.content/target/*.zip
- store_test_results:
path: bundles/core/target/surefire-reports
- store_artifacts:
path: bundles/core/target/surefire-reports
- store_test_results:
path: examples/bundle/target/surefire-reports
path: test-results
- store_artifacts:
path: examples/bundle/target/surefire-reports
path: test-results/junit
- codecov/upload:
conf: .circleci/codecov.yml
flags: unittests
Expand Down Expand Up @@ -126,6 +133,8 @@ jobs:
<<: *docker_auth
- image: docker-adobe-cif-release.dr-uw2.adobeitc.com/circleci-aem:6.5.5
<<: *docker_auth
environment:
AEM: classic
resource_class: large
working_directory: /home/circleci/build
<<: *integration_test_steps
Expand Down Expand Up @@ -158,7 +167,7 @@ jobs:
command: |
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> /home/circleci/.npmrc
echo $GPG_PRIVATE_KEY | base64 --decode | gpg --batch --import
mvn -B -s /home/circleci/project/.circleci/settings.xml clean deploy -P release-sign-artifacts,adobe-public
mvn -B -s /home/circleci/project/.circleci/settings.xml clean deploy -P release-sign-artifacts,adobe-public,skip-it
rm -rf /home/circleci/.gnupg
rm -rf /home/circleci/.npmrc

Expand Down
2 changes: 1 addition & 1 deletion examples/ui.apps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
<goal>install</goal>
</goals>
<configuration>
<targetURL>${quickstart.url}/crx/packmgr/service.jsp</targetURL>
<targetURL>${quickstart.publish.url}/crx/packmgr/service.jsp</targetURL>
<failOnError>true</failOnError>
</configuration>
</execution>
Expand Down
2 changes: 1 addition & 1 deletion examples/ui.content/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
<goal>install</goal>
</goals>
<configuration>
<targetURL>${quickstart.url}/crx/packmgr/service.jsp</targetURL>
<targetURL>${quickstart.publish.url}/crx/packmgr/service.jsp</targetURL>
<failOnError>true</failOnError>
</configuration>
</execution>
Expand Down
129 changes: 129 additions & 0 deletions it/http/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright 2019 Adobe. All rights reserved.
This file is licensed to you 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 REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.

-->
<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.adobe.commerce.cif</groupId>
<artifactId>core-cif-components-parent</artifactId>
<version>1.1.3-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>

<artifactId>core-cif-components-it-http</artifactId>
<name>AEM CIF Core Components - Integration Tests</name>
<url>https://github.com/adobe/aem-core-cif-components</url>

<scm>
<connection>scm:git:https://github.com/adobe/aem-core-cif-components</connection>
<developerConnection>scm:git:[email protected]:adobe/aem-core-cif-components.git</developerConnection>
<url>https://github.com/adobe/aem-core-cif-components</url>
<tag>HEAD</tag>
</scm>
<organization>
<name>Adobe</name>
<url>https://www.adobe.com</url>
</organization>
<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<formatter.config>../../eclipse-formatter.xml</formatter.config>
</properties>

<build>
<plugins>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

<profiles>
<!-- Run every available integration test. -->
<profile>
<id>test-all</id>

<activation>
<property>
<name>it</name>
</property>
</activation>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<id>default-integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<includes>
<include>**/*IT.java</include>
</includes>
</configuration>
</execution>
<execution>
<id>default-verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>com.adobe.cq</groupId>
<artifactId>cq-testing-clients-65</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*******************************************************************************
*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you 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 REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*
******************************************************************************/

package com.adobe.cq.commerce.it.http;

import org.apache.sling.testing.clients.ClientException;
import org.apache.sling.testing.clients.SlingHttpResponse;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.junit.Assert;
import org.junit.Test;

public class CommerceTeaserComponentIT extends CommerceTestBase {

// Differentiates between the HTML output of the component itself, and the tab displaying the HTML output
private static final String TEASER_SELECTOR = CMP_EXAMPLES_DEMO_SELECTOR + " .teaser ";

@Test
public void testCommerceTeaserWithSampleData() throws ClientException {
SlingHttpResponse response = adminAuthor.doGet(COMMERCE_LIBRARY_PATH + "/teaser.html", 200);
Document doc = Jsoup.parse(response.getContent());

// Check title
Elements elements = doc.select(TEASER_SELECTOR + ".cmp-teaser__title");
Assert.assertEquals("Get ready for the cold !", elements.first().html());

// Check link
elements = doc.select(TEASER_SELECTOR + ".cmp-teaser__action-link");
Assert.assertEquals("Find out more", elements.first().html());
}
}
Loading