]> source.dussan.org Git - vaadin-framework.git/commitdiff
Test for pushing for an extended period of time (24h)
authorArtur Signell <artur@vaadin.com>
Fri, 29 Nov 2013 17:10:19 +0000 (19:10 +0200)
committerVaadin Code Review <review@vaadin.com>
Mon, 2 Dec 2013 09:25:14 +0000 (09:25 +0000)
Change-Id: I8e47ba926f41fdc103cfa72ba85ca2f9edbc57d0

uitest/src/com/vaadin/tests/push/ExtremelyLongPushTime.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeStreaming.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeStreamingTest.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeTest.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeWebsocket.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeWebsocketTest.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/push/PushLargeData.java

diff --git a/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTime.java b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTime.java
new file mode 100644 (file)
index 0000000..d90394d
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ * 
+ * Licensed 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 com.vaadin.tests.push;
+
+import com.vaadin.server.VaadinRequest;
+
+public abstract class ExtremelyLongPushTime extends PushLargeData {
+
+    private static final int DURATION_MS = 48 * 60 * 60 * 1000; // 48 H
+    private static int INTERVAL_MS = 60 * 1000; // 1 minute
+    private static int PAYLOAD_SIZE = 100 * 1024; // 100 KB
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
+     * VaadinRequest)
+     */
+    @Override
+    protected void setup(VaadinRequest request) {
+        super.setup(request);
+        duration.setConvertedValue(DURATION_MS);
+        interval.setConvertedValue(INTERVAL_MS);
+        dataSize.setConvertedValue(PAYLOAD_SIZE);
+    }
+
+    @Override
+    protected String getTestDescription() {
+        return "Test which pushes data every minute for 48 hours";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return null;
+    }
+
+}
diff --git a/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeStreaming.java b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeStreaming.java
new file mode 100644 (file)
index 0000000..3e95827
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ * 
+ * Licensed 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 com.vaadin.tests.push;
+
+import com.vaadin.annotations.Push;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.ui.Transport;
+import com.vaadin.shared.ui.ui.UIState.PushConfigurationState;
+
+@Push(transport = Transport.STREAMING)
+public class ExtremelyLongPushTimeStreaming extends ExtremelyLongPushTime {
+
+    @Override
+    public void init(VaadinRequest request) {
+        super.init(request);
+        // Don't use fallback so we can easier detect failures
+        getPushConfiguration().setParameter(
+                PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none");
+    }
+}
diff --git a/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeStreamingTest.java b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeStreamingTest.java
new file mode 100644 (file)
index 0000000..17837cb
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ * 
+ * Licensed 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 com.vaadin.tests.push;
+
+public class ExtremelyLongPushTimeStreamingTest extends
+        ExtremelyLongPushTimeTest {
+
+}
diff --git a/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeTest.java b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeTest.java
new file mode 100644 (file)
index 0000000..56eb8b6
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ * 
+ * Licensed 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 com.vaadin.tests.push;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+
+import com.vaadin.tests.tb3.ExcludeFromSuite;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+@ExcludeFromSuite
+public abstract class ExtremelyLongPushTimeTest extends MultiBrowserTest {
+
+    private static final int ONE_HOUR_IN_MS = 20 * 1000;
+
+    @Test
+    public void test24HourPush() {
+        openTestURL();
+
+        // Without this there is a large chance that we will wait for all pushes
+        // to complete before moving on
+        testBench(driver).disableWaitForVaadin();
+
+        // Wait for startButton to be present
+        waitForElementToBePresent(vaadinLocatorById("startButton"));
+
+        String logRow0Id = "Log_row_0";
+        By logRow0 = vaadinLocatorById(logRow0Id);
+
+        // Start the test
+        vaadinElementById("startButton").click();
+
+        // Wait for push to start. Should take 60s
+        waitUntil(ExpectedConditions.textToBePresentInElement(logRow0,
+                "Package "), 120);
+
+        // Check every hour that push is still going on
+        for (int i = 0; i < 24; i++) {
+            sleep(ONE_HOUR_IN_MS);
+            ensureStillPushing(logRow0);
+        }
+
+    }
+
+    private void ensureStillPushing(By logRow0) {
+        String logValue = getDriver().findElement(logRow0).getText();
+        // Wait for the log value to change. Should take max 60s
+        waitUntilNot(
+                ExpectedConditions.textToBePresentInElement(logRow0, logValue),
+                120);
+    }
+
+}
diff --git a/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeWebsocket.java b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeWebsocket.java
new file mode 100644 (file)
index 0000000..8346d49
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ * 
+ * Licensed 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 com.vaadin.tests.push;
+
+import com.vaadin.annotations.Push;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.ui.Transport;
+import com.vaadin.shared.ui.ui.UIState.PushConfigurationState;
+
+@Push(transport = Transport.WEBSOCKET)
+public class ExtremelyLongPushTimeWebsocket extends ExtremelyLongPushTime {
+
+    @Override
+    public void init(VaadinRequest request) {
+        super.init(request);
+        // Don't use fallback so we can easier detect if websocket fails
+        getPushConfiguration().setParameter(
+                PushConfigurationState.FALLBACK_TRANSPORT_PARAM, "none");
+    }
+
+}
diff --git a/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeWebsocketTest.java b/uitest/src/com/vaadin/tests/push/ExtremelyLongPushTimeWebsocketTest.java
new file mode 100644 (file)
index 0000000..23d773c
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ * 
+ * Licensed 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 com.vaadin.tests.push;
+
+import java.util.List;
+
+import org.openqa.selenium.remote.DesiredCapabilities;
+
+import com.vaadin.tests.tb3.WebsocketTest;
+
+public class ExtremelyLongPushTimeWebsocketTest extends
+        ExtremelyLongPushTimeTest {
+
+    @Override
+    public List<DesiredCapabilities> getBrowsersToTest() {
+        return WebsocketTest.getWebsocketBrowsers();
+    }
+}
index 3b72424b3215b01f9e30de784ec1fdfab28c5376..83f573ed2c4adff2b44cdd86de8c28e37f738201 100644 (file)
@@ -51,14 +51,20 @@ public abstract class PushLargeData extends AbstractTestUIWithLog {
     private final ExecutorService executor = Executors
             .newSingleThreadExecutor();
 
+    protected TextField dataSize;
+
+    protected TextField interval;
+
+    protected TextField duration;
+
     @Override
     protected void setup(VaadinRequest request) {
         dataLabel.setSizeUndefined();
-        final TextField dataSize = new TextField("Data size");
+        dataSize = new TextField("Data size");
         dataSize.setConverter(Integer.class);
-        final TextField interval = new TextField("Interval (ms)");
+        interval = new TextField("Interval (ms)");
         interval.setConverter(Integer.class);
-        final TextField duration = new TextField("Duration (ms)");
+        duration = new TextField("Duration (ms)");
         duration.setConverter(Integer.class);
 
         dataSize.setValue(DEFAULT_SIZE_BYTES + "");