Committed by
Gerrit Code Review
Moving flow rule test to app-samples repo
git clone https://gerrit.onosproject.org/onos-app-samples Change-Id: I786fb5795d732b4bea53f50cfe1d137c2df262b8
Showing
10 changed files
with
0 additions
and
296 deletions
... | @@ -36,7 +36,6 @@ | ... | @@ -36,7 +36,6 @@ |
36 | <module>intent-perf</module> | 36 | <module>intent-perf</module> |
37 | <module>messaging-perf</module> | 37 | <module>messaging-perf</module> |
38 | <module>demo</module> | 38 | <module>demo</module> |
39 | - <module>samples</module> | ||
40 | <module>distributed-primitives</module> | 39 | <module>distributed-primitives</module> |
41 | </modules> | 40 | </modules> |
42 | 41 | ... | ... |
apps/test/samples/pom.xml
deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<!-- | ||
3 | - ~ Copyright 2015 Open Networking Laboratory | ||
4 | - ~ | ||
5 | - ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | - ~ you may not use this file except in compliance with the License. | ||
7 | - ~ You may obtain a copy of the License at | ||
8 | - ~ | ||
9 | - ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | - ~ | ||
11 | - ~ Unless required by applicable law or agreed to in writing, software | ||
12 | - ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | - ~ See the License for the specific language governing permissions and | ||
15 | - ~ limitations under the License. | ||
16 | - --> | ||
17 | -<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
18 | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
19 | - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
20 | - <modelVersion>4.0.0</modelVersion> | ||
21 | - | ||
22 | - <parent> | ||
23 | - <groupId>org.onosproject</groupId> | ||
24 | - <artifactId>onos-apps-test</artifactId> | ||
25 | - <version>1.2.0-SNAPSHOT</version> | ||
26 | - <relativePath>../pom.xml</relativePath> | ||
27 | - </parent> | ||
28 | - | ||
29 | - <artifactId>onos-app-samples</artifactId> | ||
30 | - <packaging>bundle</packaging> | ||
31 | - | ||
32 | - <description>Flow throughput test application</description> | ||
33 | - | ||
34 | - <properties> | ||
35 | - <onos.app.name>org.onosproject.flowrule</onos.app.name> | ||
36 | - </properties> | ||
37 | - | ||
38 | - <dependencies> | ||
39 | - <dependency> | ||
40 | - <groupId>org.osgi</groupId> | ||
41 | - <artifactId>org.osgi.compendium</artifactId> | ||
42 | - </dependency> | ||
43 | - <dependency> | ||
44 | - <groupId>org.apache.karaf.shell</groupId> | ||
45 | - <artifactId>org.apache.karaf.shell.console</artifactId> | ||
46 | - </dependency> | ||
47 | - <!-- Required for javadoc generation --> | ||
48 | - <dependency> | ||
49 | - <groupId>org.osgi</groupId> | ||
50 | - <artifactId>org.osgi.core</artifactId> | ||
51 | - </dependency> | ||
52 | - </dependencies> | ||
53 | - | ||
54 | - | ||
55 | - | ||
56 | -</project> |
apps/test/samples/src/main/java/org/onosproject/flowrule/dispatch/FlowRuleTest.java
deleted
100644 → 0
1 | -package org.onosproject.flowrule.dispatch; | ||
2 | - | ||
3 | -import static org.slf4j.LoggerFactory.getLogger; | ||
4 | - | ||
5 | -import java.io.BufferedReader; | ||
6 | -import java.io.File; | ||
7 | -import java.io.FileReader; | ||
8 | -import java.io.IOException; | ||
9 | - | ||
10 | -import org.onosproject.core.ApplicationId; | ||
11 | -import org.onosproject.net.DeviceId; | ||
12 | -import org.onosproject.net.device.DeviceService; | ||
13 | -import org.onosproject.net.flow.DefaultFlowRule; | ||
14 | -import org.onosproject.net.flow.FlowRule; | ||
15 | -import org.onosproject.net.flow.FlowRuleExtPayLoad; | ||
16 | -import org.onosproject.net.flow.FlowRuleService; | ||
17 | -import org.slf4j.Logger; | ||
18 | - | ||
19 | -/** | ||
20 | - * third party flow rule test code. | ||
21 | - */ | ||
22 | -public class FlowRuleTest { | ||
23 | - | ||
24 | - private final Logger log = getLogger(getClass()); | ||
25 | - protected FlowRuleService flowRuleService; | ||
26 | - protected DeviceService deviceService; | ||
27 | - private ApplicationId appId; | ||
28 | - private FlowRule[] flowSet = new DefaultFlowRule[10]; | ||
29 | - private DeviceId deviceId; | ||
30 | - private static final String FILE_NAME = "/src/main/resource/org/onosproject/flowrule/resource/flowrule.txt"; | ||
31 | - | ||
32 | - /** | ||
33 | - * Creates a flow rule test object. | ||
34 | - * @param flowRuleService service for injecting flow rules into the environment | ||
35 | - * @param deviceService service for interacting with the inventory of infrastructure devices | ||
36 | - * @param appId application identifier | ||
37 | - */ | ||
38 | - public FlowRuleTest(FlowRuleService flowRuleService, | ||
39 | - DeviceService deviceService, ApplicationId appId) { | ||
40 | - this.flowRuleService = flowRuleService; | ||
41 | - this.deviceService = deviceService; | ||
42 | - this.deviceId = deviceService.getAvailableDevices().iterator().next().id(); | ||
43 | - this.appId = appId; | ||
44 | - loadFile(); | ||
45 | - } | ||
46 | - | ||
47 | - private void loadFile() { | ||
48 | - String relativelyPath = System.getProperty("user.dir"); | ||
49 | - File flowFile = new File(relativelyPath + FILE_NAME); | ||
50 | - BufferedReader br = null; | ||
51 | - try { | ||
52 | - FileReader in = new FileReader(flowFile); | ||
53 | - br = new BufferedReader(in); | ||
54 | - FlowRule rule = null; | ||
55 | - int i = 0; | ||
56 | - String flow = ""; | ||
57 | - while ((flow = br.readLine()) != null) { | ||
58 | - rule = buildFlowRule(flow); | ||
59 | - flowSet[i++] = rule; | ||
60 | - } | ||
61 | - } catch (IOException e) { | ||
62 | - log.info("file does not exist."); | ||
63 | - } finally { | ||
64 | - if (br != null) { | ||
65 | - try { | ||
66 | - br.close(); | ||
67 | - } catch (IOException e) { | ||
68 | - log.info("nothing"); | ||
69 | - } | ||
70 | - } | ||
71 | - } | ||
72 | - } | ||
73 | - | ||
74 | - private FlowRule buildFlowRule(String flow) { | ||
75 | - FlowRuleExtPayLoad payLoad = FlowRuleExtPayLoad.flowRuleExtPayLoad(flow | ||
76 | - .getBytes()); | ||
77 | - FlowRule flowRule = new DefaultFlowRule(deviceId, null, null, 0, appId, | ||
78 | - 0, false, payLoad); | ||
79 | - return flowRule; | ||
80 | - } | ||
81 | - | ||
82 | - /** | ||
83 | - * Apply flow rules to specific devices. | ||
84 | - */ | ||
85 | - public void applyFlowRules() { | ||
86 | - flowRuleService.applyFlowRules(flowSet); | ||
87 | - } | ||
88 | - | ||
89 | - /** | ||
90 | - * Remove flow rules from specific devices. | ||
91 | - */ | ||
92 | - public void removeFlowRules() { | ||
93 | - flowRuleService.removeFlowRules(flowSet); | ||
94 | - } | ||
95 | - | ||
96 | -} |
apps/test/samples/src/main/java/org/onosproject/flowrule/dispatch/package-info.java
deleted
100644 → 0
1 | -/* | ||
2 | - * Copyright 2014-2015 Open Networking Laboratory | ||
3 | - * | ||
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | - * you may not use this file except in compliance with the License. | ||
6 | - * You may obtain a copy of the License at | ||
7 | - * | ||
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | - * | ||
10 | - * Unless required by applicable law or agreed to in writing, software | ||
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | - * See the License for the specific language governing permissions and | ||
14 | - * limitations under the License. | ||
15 | - */ | ||
16 | - | ||
17 | -/** | ||
18 | - * Provide for specific functional test script. e.g. flow rule subsystem extension. | ||
19 | - * You can create a new class to test other functions. | ||
20 | - */ | ||
21 | -package org.onosproject.flowrule.dispatch; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
apps/test/samples/src/main/java/org/onosproject/flowrule/impl/AppTestManager.java
deleted
100644 → 0
1 | -package org.onosproject.flowrule.impl; | ||
2 | - | ||
3 | -import static org.slf4j.LoggerFactory.getLogger; | ||
4 | - | ||
5 | -import org.apache.felix.scr.annotations.Activate; | ||
6 | -import org.apache.felix.scr.annotations.Component; | ||
7 | -import org.apache.felix.scr.annotations.Deactivate; | ||
8 | -import org.apache.felix.scr.annotations.Reference; | ||
9 | -import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
10 | -import org.apache.felix.scr.annotations.Service; | ||
11 | -import org.onosproject.core.ApplicationId; | ||
12 | -import org.onosproject.core.CoreService; | ||
13 | -import org.onosproject.flowrule.AppTestService; | ||
14 | -import org.onosproject.flowrule.dispatch.FlowRuleTest; | ||
15 | -import org.onosproject.net.device.DeviceService; | ||
16 | -import org.onosproject.net.flow.FlowRuleService; | ||
17 | -import org.slf4j.Logger; | ||
18 | - | ||
19 | -/** | ||
20 | - * Test for a application. | ||
21 | - */ | ||
22 | -@Component(immediate = true) | ||
23 | -@Service | ||
24 | -public class AppTestManager implements AppTestService { | ||
25 | - | ||
26 | - private static final String APP_TEST = "org.onosproject.apptest"; | ||
27 | - private final Logger log = getLogger(getClass()); | ||
28 | - | ||
29 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
30 | - protected CoreService coreService; | ||
31 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
32 | - protected FlowRuleService flowRuleService; | ||
33 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
34 | - protected DeviceService deviceService; | ||
35 | - private ApplicationId appId; | ||
36 | - FlowRuleTest flowRule; | ||
37 | - | ||
38 | - @Activate | ||
39 | - protected void activate() { | ||
40 | - log.info("APP-TEST started"); | ||
41 | - appId = coreService.registerApplication(APP_TEST); | ||
42 | - flowRule = new FlowRuleTest(flowRuleService, deviceService, appId); | ||
43 | - flowRule.applyFlowRules(); | ||
44 | - } | ||
45 | - | ||
46 | - @Deactivate | ||
47 | - protected void deactivate() { | ||
48 | - flowRule.removeFlowRules(); | ||
49 | - log.info("APP-TEST Stopped"); | ||
50 | - } | ||
51 | -} |
1 | -/* | ||
2 | - * Copyright 2014-2015 Open Networking Laboratory | ||
3 | - * | ||
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | - * you may not use this file except in compliance with the License. | ||
6 | - * You may obtain a copy of the License at | ||
7 | - * | ||
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | - * | ||
10 | - * Unless required by applicable law or agreed to in writing, software | ||
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | - * See the License for the specific language governing permissions and | ||
14 | - * limitations under the License. | ||
15 | - */ | ||
16 | - | ||
17 | -/** | ||
18 | - * Test for flow rule subsystem extension. | ||
19 | - * Also used to test other functions, but it need be extended. | ||
20 | - */ | ||
21 | -package org.onosproject.flowrule.impl; |
1 | -/* | ||
2 | - * Copyright 2014-2015 Open Networking Laboratory | ||
3 | - * | ||
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | - * you may not use this file except in compliance with the License. | ||
6 | - * You may obtain a copy of the License at | ||
7 | - * | ||
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | - * | ||
10 | - * Unless required by applicable law or agreed to in writing, software | ||
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | - * See the License for the specific language governing permissions and | ||
14 | - * limitations under the License. | ||
15 | - */ | ||
16 | - | ||
17 | -/** | ||
18 | - * Test for flow rule subsystem extension. | ||
19 | - * Now it has no APIs, Maybe it can add other methods in future. | ||
20 | - */ | ||
21 | -package org.onosproject.flowrule; |
apps/test/samples/src/main/resource/org/onosproject/flowrule/resource/flowrule.txt
deleted
100644 → 0
1 | -050e009000000000000000000000000000000000000000000701000000000000000000000000000000000000000000020001001080001702010180001902010200040030000000000000001000000006000000000000000000130008001300000019001080001a0101000000000000000002000000000000000000000000000100000000000000010001000003000000 | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
apps/test/samples/src/main/resource/org/onosproject/flowrule/resource/package-info.java
deleted
100644 → 0
1 | -/* | ||
2 | - * Copyright 2014-2015 Open Networking Laboratory | ||
3 | - * | ||
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | - * you may not use this file except in compliance with the License. | ||
6 | - * You may obtain a copy of the License at | ||
7 | - * | ||
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | - * | ||
10 | - * Unless required by applicable law or agreed to in writing, software | ||
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | - * See the License for the specific language governing permissions and | ||
14 | - * limitations under the License. | ||
15 | - */ | ||
16 | - | ||
17 | -/** | ||
18 | - * applications live here. | ||
19 | - */ | ||
20 | -package org.onosproject.flowrule.resource; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment