You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by ha...@apache.org on 2018/01/10 08:36:35 UTC

[incubator-skywalking-ui] branch feature/5.0.0 updated: Reactor mock

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

hanahmily pushed a commit to branch feature/5.0.0
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking-ui.git


The following commit(s) were added to refs/heads/feature/5.0.0 by this push:
     new 13406fd  Reactor mock
13406fd is described below

commit 13406fda1ad9579dec6fd04e6cdd7bb03abbb6c8
Author: hanahmily <ha...@gmail.com>
AuthorDate: Wed Jan 10 16:28:14 2018 +0800

    Reactor mock
---
 src/main/frontend/.roadhogrc.mock.js  | 82 +++++------------------------------
 src/main/frontend/mock/alarm.js       | 13 ++++++
 src/main/frontend/mock/application.js | 14 ++++++
 src/main/frontend/mock/dashboard.js   | 27 ++++++++++++
 src/main/frontend/mock/server.js      | 32 ++++++++++++++
 src/main/frontend/mock/service.js     | 22 ++++++++++
 6 files changed, 120 insertions(+), 70 deletions(-)

diff --git a/src/main/frontend/.roadhogrc.mock.js b/src/main/frontend/.roadhogrc.mock.js
index 8097007..bb1a4e9 100644
--- a/src/main/frontend/.roadhogrc.mock.js
+++ b/src/main/frontend/.roadhogrc.mock.js
@@ -3,81 +3,23 @@ import { getRule, postRule } from './mock/rule';
 import { imgMap } from './mock/utils';
 import { getNotices } from './mock/notices';
 import { delay } from 'roadhog-api-doc';
+import { getDashboard } from './mock/dashboard'
+import { getApplication } from './mock/application'
+import { getServer } from './mock/server'
+import { getService } from './mock/service'
+import { getAlarm } from './mock/alarm'
 
 // 是否禁用代理
 const noProxy = process.env.NO_PROXY === 'true';
 
 // 代码中会兼容本地 service mock 以及部署站点的静态数据
-const proxy = mockjs.mock({
+const proxy = {
   // 支持值为 Object 和 Array
-  'POST /api/dashboard': {
-    data: {
-      getClusterBrief: {
-        'numOfApplication|1-100': 1,
-        'numOfService|1-100': 1,
-        'numOfDatabase|1-100': 1,
-        'numOfCache|1-100': 1,
-        'numOfMQ|1-100': 1,
-      },
-      getAlarmTrend: {
-        'numOfAlarmRate|15': ['@natural(0, 99)'],
-      },
-      getConjecturalApps: {
-        'apps|3-5': [{'name|1':['Oracle', 'MySQL', 'ActiveMQ', 'Redis', 'Memcache', 'SQLServer'], 'num':'@natural(1, 20)'}],
-      },
-      'getTopNSlowService|10': [{'key|+1': 1, 'name': '@name', 'avgResponseTime|200-1000': 1}],
-      'getTopNServerThroughput|10': [{'key|+1': 1, 'name': '@name', 'tps|100-10000': 1}],
-    }
-  },
-  'POST /api/application': {
-    data: {
-      'getSlowService|10': [{'key|+1': 1, 'name': '@name', 'avgResponseTime|200-1000': 1}],
-      'getServerThroughput|10': [{'key|+1': 1, 'name': '@name', 'tps|100-10000': 1}],
-    }
-  },
-  'POST /api/server': {
-    data: {
-      'searchServer|5': [{}],
-      getServerResponseTimeTrend: {
-        'trendList|15': ['@natural(100, 1000)'],
-      },
-      getServerTPSTrend: {
-        'trendList|15': ['@natural(500, 10000)'],
-      },
-      getCPUTrend: {
-        'cost|15': ['@natural(0, 99)'],
-      },
-      getMemoryTrend: {
-        'heap|15': ['@natural(500, 900)'],
-        'maxHeap|15': ['@natural(900, 2000)'],
-        'noheap|15': ['@natural(100, 200)'],
-        'maxNoheap|15': ['@natural(200, 300)'],
-      },
-      getGCTrend: {
-        'youngGC|15': ['@natural(200, 300)'],
-        'oldGC|15': ['@natural(10,100)'],
-      },
-    }
-  },
-  'POST /api/service': {
-    data: {
-      'searchService|5': [{}],
-      getServiceResponseTimeTrend: {
-        'trendList|15': ['@natural(100, 1000)'],
-      },
-      getServiceTPSTrend: {
-        'trendList|15': ['@natural(500, 10000)'],
-      },
-      getServiceSLATrend: {
-        'trendList|15': ['@natural(80, 100)'],
-      },
-    }
-  },
-  'POST /api/alert': {
-    data: {
-      'loadAlertList|100': [{'key|+1': 1, 'content':'@string(20)', 'startTime': '@datetime("yyyy-MM-dd HH:mm:ss")', 'alertType|1': ['APPLICATION', 'SERVER', 'SERVICE']}],
-    }
-  },
-});
+  'POST /api/dashboard': getDashboard,
+  'POST /api/application': getApplication,
+  'POST /api/server': getServer,
+  'POST /api/service': getService,
+  'POST /api/alert': getAlarm,
+};
 
 export default noProxy ? {} : delay(proxy, 1000);
diff --git a/src/main/frontend/mock/alarm.js b/src/main/frontend/mock/alarm.js
new file mode 100644
index 0000000..1667e75
--- /dev/null
+++ b/src/main/frontend/mock/alarm.js
@@ -0,0 +1,13 @@
+import mockjs from 'mockjs';
+
+export default {
+  getAlarm(req, res) {
+    res.json(mockjs.mock(
+      {
+        data: {
+          'loadAlertList|100': [{ 'key|+1': 1, content: '@string(20)', startTime: '@datetime("yyyy-MM-dd HH:mm:ss")', 'alertType|1': ['APPLICATION', 'SERVER', 'SERVICE'] }],
+        },
+      }
+    ));
+  },
+};
diff --git a/src/main/frontend/mock/application.js b/src/main/frontend/mock/application.js
new file mode 100644
index 0000000..fdb8826
--- /dev/null
+++ b/src/main/frontend/mock/application.js
@@ -0,0 +1,14 @@
+import mockjs from 'mockjs';
+
+export default {
+  getApplication(req, res) {
+    res.json(mockjs.mock(
+      {
+        data: {
+          'getSlowService|10': [{ 'key|+1': 1, name: '@name', 'avgResponseTime|200-1000': 1 }],
+          'getServerThroughput|10': [{ 'key|+1': 1, name: '@name', 'tps|100-10000': 1 }],
+        },
+      }
+    ));
+  },
+};
diff --git a/src/main/frontend/mock/dashboard.js b/src/main/frontend/mock/dashboard.js
new file mode 100644
index 0000000..c97c655
--- /dev/null
+++ b/src/main/frontend/mock/dashboard.js
@@ -0,0 +1,27 @@
+import mockjs from 'mockjs';
+
+export default {
+  getDashboard(req, res) {
+    res.json(mockjs.mock(
+      {
+        data: {
+          getClusterBrief: {
+            'numOfApplication|1-100': 1,
+            'numOfService|1-100': 1,
+            'numOfDatabase|1-100': 1,
+            'numOfCache|1-100': 1,
+            'numOfMQ|1-100': 1,
+          },
+          getAlarmTrend: {
+            'numOfAlarmRate|15': ['@natural(0, 99)'],
+          },
+          getConjecturalApps: {
+            'apps|3-5': [{ 'name|1': ['Oracle', 'MySQL', 'ActiveMQ', 'Redis', 'Memcache', 'SQLServer'], num: '@natural(1, 20)' }],
+          },
+          'getTopNSlowService|10': [{ 'key|+1': 1, name: '@name', 'avgResponseTime|200-1000': 1 }],
+          'getTopNServerThroughput|10': [{ 'key|+1': 1, name: '@name', 'tps|100-10000': 1 }],
+        },
+      }
+    ));
+  },
+};
diff --git a/src/main/frontend/mock/server.js b/src/main/frontend/mock/server.js
new file mode 100644
index 0000000..db490e7
--- /dev/null
+++ b/src/main/frontend/mock/server.js
@@ -0,0 +1,32 @@
+import mockjs from 'mockjs';
+
+export default {
+  getServer(req, res) {
+    res.json(mockjs.mock(
+      {
+        data: {
+          'searchServer|5': [{}],
+          getServerResponseTimeTrend: {
+            'trendList|15': ['@natural(100, 1000)'],
+          },
+          getServerTPSTrend: {
+            'trendList|15': ['@natural(500, 10000)'],
+          },
+          getCPUTrend: {
+            'cost|15': ['@natural(0, 99)'],
+          },
+          getMemoryTrend: {
+            'heap|15': ['@natural(500, 900)'],
+            'maxHeap|15': ['@natural(900, 2000)'],
+            'noheap|15': ['@natural(100, 200)'],
+            'maxNoheap|15': ['@natural(200, 300)'],
+          },
+          getGCTrend: {
+            'youngGC|15': ['@natural(200, 300)'],
+            'oldGC|15': ['@natural(10,100)'],
+          },
+        },
+      }
+    ));
+  },
+};
diff --git a/src/main/frontend/mock/service.js b/src/main/frontend/mock/service.js
new file mode 100644
index 0000000..d8997fb
--- /dev/null
+++ b/src/main/frontend/mock/service.js
@@ -0,0 +1,22 @@
+import mockjs from 'mockjs';
+
+export default {
+  getService(req, res) {
+    res.json(mockjs.mock(
+      {
+        data: {
+          'searchService|5': [{}],
+          getServiceResponseTimeTrend: {
+            'trendList|15': ['@natural(100, 1000)'],
+          },
+          getServiceTPSTrend: {
+            'trendList|15': ['@natural(500, 10000)'],
+          },
+          getServiceSLATrend: {
+            'trendList|15': ['@natural(80, 100)'],
+          },
+        },
+      }
+    ));
+  },
+};

-- 
To stop receiving notification emails like this one, please contact
['"commits@skywalking.apache.org" <co...@skywalking.apache.org>'].