performance tracker moved
authorYaroslav Lepenkin <yaroslav.lepenkin@jetbrains.com>
Tue, 24 Oct 2017 17:28:06 +0000 (20:28 +0300)
committerYaroslav Lepenkin <yaroslav.lepenkin@jetbrains.com>
Tue, 24 Oct 2017 17:30:08 +0000 (20:30 +0300)
plugins/stats-collector/src/com/intellij/completion/enhancer/ContributorsTimeStatistics.kt
plugins/stats-collector/src/com/intellij/performance/IntervalCounter.kt [moved from plugins/stats-collector/src/com/intellij/stats/tracking/IntervalCounter.kt with 97% similarity]
plugins/stats-collector/src/com/intellij/plugin/Settings.kt
plugins/stats-collector/src/com/intellij/stats/completion/SenderComponent.kt [deleted file]
plugins/stats-collector/test/com/intellij/performance/IntervalCounterTrackingTest.kt [moved from plugins/stats-collector/test/com/intellij/stats/tracking/IntervalCounterTrackingTest.kt with 97% similarity]
plugins/stats-collector/test/com/intellij/stats/experiment/StatusInfoProviderTest.kt [new file with mode: 0644]

index 26426b0993735d06bbe5ef780e7c78e3d61fe3b9..4cc598342ea747832d88ba125ddfd83452f0bbc1 100644 (file)
@@ -21,7 +21,7 @@ import com.intellij.openapi.components.PersistentStateComponent
 import com.intellij.openapi.components.State
 import com.intellij.openapi.components.Storage
 import com.intellij.openapi.components.service
-import com.intellij.stats.tracking.IntervalCounter
+import com.intellij.performance.IntervalCounter
 
 @State(name = "CompletionTimeStatistics", storages=arrayOf(Storage("completion.time.statistics")))
 class ContributorsTimeStatistics : PersistentStateComponent<CompletionTimeStats> {
similarity index 97%
rename from plugins/stats-collector/src/com/intellij/stats/tracking/IntervalCounter.kt
rename to plugins/stats-collector/src/com/intellij/performance/IntervalCounter.kt
index 8526b27e35dc0fb02fd37cef0bc1dd752b77f19b..104aaa2894b94bcfdbb13d33cfa64bcdbda396b3 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.intellij.stats.tracking
+package com.intellij.performance
 
 data class IntervalData(val intervalStart: Double, val intervalEnd: Double, val count: Int)
 
index f15ac35aea599d4a927c8a94855bdb5b1b8093cc..3f56c6fdf456ef03dfdac340144a55e9ce84d7df 100644 (file)
@@ -24,7 +24,7 @@ import com.intellij.openapi.options.Configurable
 import com.intellij.openapi.options.ConfigurableProvider
 import com.intellij.sorting.SortingTimeStatistics
 import com.intellij.stats.experiment.WebServiceStatus
-import com.intellij.stats.tracking.IntervalCounter
+import com.intellij.performance.IntervalCounter
 import com.intellij.ui.IdeBorderFactory
 import com.intellij.ui.components.JBCheckBox
 import com.intellij.ui.components.JBLabel
diff --git a/plugins/stats-collector/src/com/intellij/stats/completion/SenderComponent.kt b/plugins/stats-collector/src/com/intellij/stats/completion/SenderComponent.kt
deleted file mode 100644 (file)
index e070951..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright 2000-2017 JetBrains s.r.o.
- *
- * 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.intellij.stats.completion
-
-
similarity index 97%
rename from plugins/stats-collector/test/com/intellij/stats/tracking/IntervalCounterTrackingTest.kt
rename to plugins/stats-collector/test/com/intellij/performance/IntervalCounterTrackingTest.kt
index 189ea553ff41fc10bebdc1a16d133b6d52ddb73e..4edcfd67209bcdcf108a818fa2c3ae1a5083e0ba 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package com.intellij.stats.tracking
+package com.intellij.performance
 
 import org.junit.Test
 import org.assertj.core.api.Assertions.assertThat
diff --git a/plugins/stats-collector/test/com/intellij/stats/experiment/StatusInfoProviderTest.kt b/plugins/stats-collector/test/com/intellij/stats/experiment/StatusInfoProviderTest.kt
new file mode 100644 (file)
index 0000000..0294636
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2000-2017 JetBrains s.r.o.
+ *
+ * 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.intellij.stats.experiment
+
+import com.intellij.stats.network.service.RequestService
+import com.intellij.stats.network.service.ResponseData
+import com.intellij.testFramework.LightIdeaTestCase
+import org.assertj.core.api.Assertions.assertThat
+import org.mockito.Matchers
+import org.mockito.Mockito.`when`
+import org.mockito.Mockito.mock
+
+class StatusInfoProviderTest : LightIdeaTestCase() {
+
+
+    fun newResponse(status: String, salt: String, version: String, url: String) = """
+{
+  "status" : "$status",
+  "salt" : "$salt",
+  "experimentVersion" : $version,
+  "urlForZipBase64Content": "$url"  
+}
+"""
+    
+    fun `test experiment info is fetched`() {
+        val response = newResponse("ok", "sdfs", "2", "http://test.jetstat-resty.aws.intellij.net/uploadstats")
+        val infoProvider = getProvider(response)
+
+        infoProvider.updateStatus()
+
+        assertThat(infoProvider.dataServerUrl()).isEqualTo("http://test.jetstat-resty.aws.intellij.net/uploadstats")
+        assertThat(infoProvider.isServerOk()).isEqualTo(true)
+        assertThat(infoProvider.experimentVersion()).isEqualTo(2)
+    }
+
+    fun `test server is not ok`() {
+        val response = newResponse("maintance", "sdfs", "2", "http://xxx.xxx")
+        val infoProvider = getProvider(response)
+
+        infoProvider.updateStatus()
+
+        assertThat(infoProvider.isServerOk()).isEqualTo(false)
+        assertThat(infoProvider.experimentVersion()).isEqualTo(2)
+        assertThat(infoProvider.dataServerUrl()).isEqualTo("http://xxx.xxx")
+    }
+
+    fun `test round to Int`() {
+        var response = newResponse("maintance", "sdfs", "2.9", "http://xxx.xxx")
+        var infoProvider = getProvider(response)
+        infoProvider.updateStatus()
+        assertThat(infoProvider.experimentVersion()).isEqualTo(2)
+        
+        response = newResponse("maintance", "sdfs", "2.1", "http://xxx.xxx")
+        infoProvider = getProvider(response)
+        infoProvider.updateStatus()
+        assertThat(infoProvider.experimentVersion()).isEqualTo(2)
+    }
+
+
+    private fun getProvider(response: String): WebServiceStatus {
+        val requestSender = mock(RequestService::class.java).apply {
+            `when`(get(Matchers.anyString())).thenReturn(ResponseData(200, response))
+        }
+        val decision = mock(ExperimentDecision::class.java)
+        return WebServiceStatusProvider(requestSender, decision)
+    }
+
+}
\ No newline at end of file