You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by iv...@apache.org on 2018/02/15 14:42:15 UTC

[bookkeeper] branch master updated: Integration smoke test

This is an automated email from the ASF dual-hosted git repository.

ivank pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new 204a671  Integration smoke test
204a671 is described below

commit 204a671a5cd8dc9633a4a4be92b0724c59ce4ae4
Author: Ivan Kelly <iv...@apache.org>
AuthorDate: Thu Feb 15 15:42:09 2018 +0100

    Integration smoke test
    
    Most basic integration test we can have.
    - Boots a cluster
    - Writes a ledger
    - Reads back the ledger
    - Shutdown the cluster
    
    If this test fails, something is very wrong.
    
    Author: Ivan Kelly <iv...@apache.org>
    
    Reviewers: Enrico Olivelli <eo...@gmail.com>, Sijie Guo <si...@apache.org>
    
    This closes #1133 from ivankelly/smoke-test
---
 tests/{ => integration}/pom.xml                    | 29 ++-----
 tests/{ => integration/smoke}/pom.xml              | 45 ++++++-----
 .../bookkeeper/tests/integration/TestSmoke.java    | 89 ++++++++++++++++++++++
 .../smoke/src/test/resources/arquillian.xml        | 28 +++++++
 tests/pom.xml                                      |  1 +
 5 files changed, 149 insertions(+), 43 deletions(-)

diff --git a/tests/pom.xml b/tests/integration/pom.xml
similarity index 61%
copy from tests/pom.xml
copy to tests/integration/pom.xml
index f2e1d85..86136ff 100644
--- a/tests/pom.xml
+++ b/tests/integration/pom.xml
@@ -20,32 +20,15 @@
   <packaging>pom</packaging>
   <modelVersion>4.0.0</modelVersion>
   <parent>
-    <groupId>org.apache.bookkeeper</groupId>
-    <artifactId>bookkeeper</artifactId>
+    <groupId>org.apache.bookkeeper.tests</groupId>
+    <artifactId>integration-tests-base</artifactId>
     <version>4.7.0-SNAPSHOT</version>
+    <relativePath>../integration-tests-base</relativePath>
   </parent>
-  <groupId>org.apache.bookkeeper.tests</groupId>
+  <groupId>org.apache.bookkeeper.tests.integration</groupId>
   <artifactId>tests-parent</artifactId>
-  <name>Apache BookKeeper :: Tests</name>
+  <name>Apache BookKeeper :: Tests :: Integration</name>
   <modules>
-    <module>shaded</module>
-    <module>docker-images</module>
-    <module>integration-tests-base</module>
-    <module>integration-tests-base-groovy</module>
-    <module>integration-tests-utils</module>
-    <module>integration-tests-topologies</module>
-    <module>backward-compat</module>
+    <module>smoke</module>
   </modules>
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-deploy-plugin</artifactId>
-        <version>${maven-deploy-plugin.version}</version>
-        <configuration>
-          <skip>true</skip>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
 </project>
diff --git a/tests/pom.xml b/tests/integration/smoke/pom.xml
similarity index 53%
copy from tests/pom.xml
copy to tests/integration/smoke/pom.xml
index f2e1d85..21176f4 100644
--- a/tests/pom.xml
+++ b/tests/integration/smoke/pom.xml
@@ -15,35 +15,40 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 -->
-<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">
-  <packaging>pom</packaging>
+<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>org.apache.bookkeeper</groupId>
-    <artifactId>bookkeeper</artifactId>
+    <groupId>org.apache.bookkeeper.tests.integration</groupId>
+    <artifactId>tests-parent</artifactId>
     <version>4.7.0-SNAPSHOT</version>
   </parent>
-  <groupId>org.apache.bookkeeper.tests</groupId>
-  <artifactId>tests-parent</artifactId>
-  <name>Apache BookKeeper :: Tests</name>
-  <modules>
-    <module>shaded</module>
-    <module>docker-images</module>
-    <module>integration-tests-base</module>
-    <module>integration-tests-base-groovy</module>
-    <module>integration-tests-utils</module>
-    <module>integration-tests-topologies</module>
-    <module>backward-compat</module>
-  </modules>
+
+  <groupId>org.apache.bookkeeper.tests.integration</groupId>
+  <artifactId>smoke</artifactId>
+  <packaging>jar</packaging>
+  <name>Apache BookKeeper :: Tests :: Backward Compatibility :: Smoke test</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.bookkeeper</groupId>
+      <artifactId>bookkeeper-server</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+  </dependencies>
+
   <build>
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-deploy-plugin</artifactId>
-        <version>${maven-deploy-plugin.version}</version>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>${maven-surefire-plugin.version}</version>
         <configuration>
-          <skip>true</skip>
+          <!-- smoke test should never flake //-->
+          <rerunFailingTestsCount>0</rerunFailingTestsCount>
         </configuration>
       </plugin>
     </plugins>
diff --git a/tests/integration/smoke/src/test/java/org/apache/bookkeeper/tests/integration/TestSmoke.java b/tests/integration/smoke/src/test/java/org/apache/bookkeeper/tests/integration/TestSmoke.java
new file mode 100644
index 0000000..6a80c09
--- /dev/null
+++ b/tests/integration/smoke/src/test/java/org/apache/bookkeeper/tests/integration/TestSmoke.java
@@ -0,0 +1,89 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* 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 CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.bookkeeper.tests.integration;
+
+import com.github.dockerjava.api.DockerClient;
+
+import java.util.Enumeration;
+
+import org.apache.bookkeeper.client.BookKeeper;
+import org.apache.bookkeeper.client.LedgerEntry;
+import org.apache.bookkeeper.client.LedgerHandle;
+import org.apache.bookkeeper.tests.BookKeeperClusterUtils;
+
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.arquillian.test.api.ArquillianResource;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RunWith(Arquillian.class)
+public class TestSmoke {
+    private static final Logger LOG = LoggerFactory.getLogger(TestSmoke.class);
+    private static byte[] PASSWD = "foobar".getBytes();
+
+    @ArquillianResource
+    DockerClient docker;
+
+    private String currentVersion = System.getProperty("currentVersion");
+
+    @Before
+    public void before() throws Exception {
+        // First test to run, formats metadata and bookies
+        if (BookKeeperClusterUtils.metadataFormatIfNeeded(docker, currentVersion)) {
+            BookKeeperClusterUtils.formatAllBookies(docker, currentVersion);
+        }
+    }
+
+    @Test
+    public void testBootWriteReadShutdown() throws Exception {
+        Assert.assertTrue(BookKeeperClusterUtils.startAllBookiesWithVersion(docker, currentVersion));
+
+        String zookeeper = BookKeeperClusterUtils.zookeeperConnectString(docker);
+        BookKeeper bk = new BookKeeper(zookeeper);
+        long ledgerId;
+        try (LedgerHandle writelh = bk.createLedger(BookKeeper.DigestType.CRC32, PASSWD)) {
+            ledgerId = writelh.getId();
+            for (int i = 0; i < 100; i++) {
+                writelh.addEntry(("entry-" + i).getBytes());
+            }
+        }
+
+        try (LedgerHandle readlh = bk.openLedger(ledgerId, BookKeeper.DigestType.CRC32, PASSWD)) {
+            long lac = readlh.getLastAddConfirmed();
+            int i = 0;
+            Enumeration<LedgerEntry> entries = readlh.readEntries(0, lac);
+            while (entries.hasMoreElements()) {
+                LedgerEntry e = entries.nextElement();
+                String readBack = new String(e.getEntry());
+                Assert.assertEquals(readBack, "entry-" + i++);
+            }
+            Assert.assertEquals(i, 100);
+        }
+
+        bk.close();
+
+        Assert.assertTrue(BookKeeperClusterUtils.stopAllBookies(docker));
+    }
+
+}
diff --git a/tests/integration/smoke/src/test/resources/arquillian.xml b/tests/integration/smoke/src/test/resources/arquillian.xml
new file mode 100644
index 0000000..f914ff2
--- /dev/null
+++ b/tests/integration/smoke/src/test/resources/arquillian.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file 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 CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xmlns="http://jboss.org/schema/arquillian"
+            xsi:schemaLocation="http://jboss.org/schema/arquillian
+                                http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
+
+  <extension qualifier="docker">
+    <property name="definitionFormat">CUBE</property>
+    <property name="dockerContainersResource">cube-definitions/3-node-all-version-unstarted.yaml</property>
+  </extension>
+
+</arquillian>
diff --git a/tests/pom.xml b/tests/pom.xml
index f2e1d85..fa8484c 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -35,6 +35,7 @@
     <module>integration-tests-utils</module>
     <module>integration-tests-topologies</module>
     <module>backward-compat</module>
+    <module>integration</module>
   </modules>
   <build>
     <plugins>

-- 
To stop receiving notification emails like this one, please contact
ivank@apache.org.