Skip to content

Commit 46bbc96

Browse files
authored
Merge pull request #134 from sdnfv/develop
This PR releases OpenNetVM v19.05
2 parents 4cdb7d2 + 12cbe58 commit 46bbc96

File tree

127 files changed

+11101
-9955
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+11101
-9955
lines changed

.clang-format

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
Language: Cpp
3+
# BasedOnStyle: Google
4+
AccessModifierOffset: -1
5+
AlignAfterOpenBracket: Align
6+
AlignConsecutiveAssignments: false
7+
AlignConsecutiveDeclarations: false
8+
AlignEscapedNewlinesLeft: true
9+
AlignOperands: true
10+
AlignTrailingComments: true
11+
AllowAllParametersOfDeclarationOnNextLine: true
12+
AllowShortBlocksOnASingleLine: false
13+
AllowShortCaseLabelsOnASingleLine: false
14+
AllowShortFunctionsOnASingleLine: false
15+
AllowShortIfStatementsOnASingleLine: false
16+
AllowShortLoopsOnASingleLine: false
17+
AlwaysBreakAfterDefinitionReturnType: None
18+
AlwaysBreakAfterReturnType: All
19+
AlwaysBreakBeforeMultilineStrings: true
20+
AlwaysBreakTemplateDeclarations: true
21+
BinPackArguments: true
22+
BinPackParameters: true
23+
BraceWrapping:
24+
AfterClass: false
25+
AfterControlStatement: false
26+
AfterEnum: false
27+
AfterFunction: false
28+
AfterNamespace: false
29+
AfterObjCDeclaration: false
30+
AfterStruct: false
31+
AfterUnion: false
32+
BeforeCatch: false
33+
BeforeElse: false
34+
IndentBraces: false
35+
BreakBeforeBinaryOperators: None
36+
BreakBeforeBraces: Attach
37+
BreakBeforeTernaryOperators: true
38+
BreakConstructorInitializersBeforeComma: false
39+
BreakAfterJavaFieldAnnotations: false
40+
BreakStringLiterals: true
41+
ColumnLimit: 120
42+
CommentPragmas: '^ IWYU pragma:'
43+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
44+
ConstructorInitializerIndentWidth: 4
45+
ContinuationIndentWidth: 4
46+
Cpp11BracedListStyle: true
47+
DerivePointerAlignment: true
48+
DisableFormat: false
49+
ExperimentalAutoDetectBinPacking: false
50+
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
51+
IncludeCategories:
52+
- Regex: '^<.*\.h>'
53+
Priority: 1
54+
- Regex: '^<.*'
55+
Priority: 2
56+
- Regex: '.*'
57+
Priority: 3
58+
IncludeIsMainRegex: '([-_](test|unittest))?$'
59+
IndentCaseLabels: true
60+
IndentWidth: 8
61+
IndentWrappedFunctionNames: false
62+
JavaScriptQuotes: Leave
63+
JavaScriptWrapImports: true
64+
KeepEmptyLinesAtTheStartOfBlocks: false
65+
MacroBlockBegin: ''
66+
MacroBlockEnd: ''
67+
MaxEmptyLinesToKeep: 1
68+
NamespaceIndentation: None
69+
ObjCBlockIndentWidth: 2
70+
ObjCSpaceAfterProperty: false
71+
ObjCSpaceBeforeProtocolList: false
72+
PenaltyBreakBeforeFirstCallParameter: 1
73+
PenaltyBreakComment: 300
74+
PenaltyBreakFirstLessLess: 120
75+
PenaltyBreakString: 1000
76+
PenaltyExcessCharacter: 1000000
77+
PenaltyReturnTypeOnItsOwnLine: 200
78+
PointerAlignment: Left
79+
ReflowComments: true
80+
SortIncludes: true
81+
SpaceAfterCStyleCast: false
82+
SpaceBeforeAssignmentOperators: true
83+
SpaceBeforeParens: ControlStatements
84+
SpaceInEmptyParentheses: false
85+
SpacesBeforeTrailingComments: 2
86+
SpacesInAngles: false
87+
SpacesInContainerLiterals: true
88+
SpacesInCStyleCastParentheses: false
89+
SpacesInParentheses: false
90+
SpacesInSquareBrackets: false
91+
Standard: Auto
92+
TabWidth: 8
93+
UseTab: Never
94+
...
95+

CPPLINT.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
linelength=100
1+
linelength=120

ci/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
access_log
12
config
3+
webhook-config.json
4+
encrypted_secret.bin
5+
private.pem
6+
public.pem
27
githubcreds
38
mykeyfile
49
repository

ci/README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
### Setting up CI
44
Run a Flask server that listens for new events from github, will get triggered when a new PR is created or when keyword `@onvm` is mentioned.
55
```sh
6-
python3 webhook-receiver.py 0.0.0.0 8080 @onvm
6+
python3 webhook-receiver.py 0.0.0.0 8080 @onvm webhook-config.json
77
```
88

99
To run CI tests manually, requires a config file, the github PR ID, request message and a response message.
1010
```sh
11-
./manager.sh <config file> <pr ID> <request msg>
11+
./manager.sh <config file> <pr ID> <repo name> <request msg>
1212
```
1313

1414
### Usage
@@ -34,15 +34,23 @@ The CI process can be broken into multiple steps:
3434
WORKER_LIST=("WORKER_1_IP WORKER_1_KEY", "WORKER_2_IP WORKER_2_KEY", ...)
3535
GITHUB_CREDS=path_to_creditential_file
3636
REPO_OWNER="OWNER_STRING"
37-
REPO_NAME="NAME_STRING"
3837
```
3938
4039
Config file example:
4140
```
4241
WORKER_LIST=("nimbnode42 nn42_key")
4342
GITHUB_CREDS=githubcreds
4443
REPO_OWNER="sdnfv"
45-
REPO_NAME="openNetVM-dev"
44+
```
45+
46+
Webhook json config example
47+
```
48+
{
49+
"secret-file": "very_special_encrypted_secret_file.bin",
50+
"private-key-file": "private_key.pem",
51+
"log-successful-attempts": true,
52+
"authorized-users": ["puffin", "penguin", "pcoach"]
53+
}
4654
```
4755
4856
GITHUB_CREDS file example:

ci/ci_busy.sh

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,43 +29,45 @@ fi
2929

3030
if [[ -z "$3" ]]
3131
then
32-
echo "ERROR: Missing third argument, Request body!"
32+
echo "ERROR: Missing third argument, Repo name!"
3333
exit 1
3434
else
35-
REQUEST=$3
35+
REPO_NAME=$3
3636
fi
3737

3838
if [[ -z "$4" ]]
3939
then
40-
echo "ERROR: Missing fourth argument, POST_MSG!"
40+
echo "ERROR: Missing fourth argument, Request body!"
4141
exit 1
4242
else
43-
POST_MSG=$4
43+
REQUEST=$4
44+
fi
45+
46+
if [[ -z "$5" ]]
47+
then
48+
echo "ERROR: Missing fifth argument, POST_MSG!"
49+
exit 1
50+
else
51+
POST_MSG=$5
4452
fi
4553

4654
. $1 # source the variables from config file
4755

4856
print_header "Checking Required Variables"
4957

5058

51-
if [[ -z "$GITHUB_CREDS" ]]
59+
if [[ -z "$GITHUB_CREDS" ]]
5260
then
5361
echo "ERROR: GITHUB_CREDS not provided"
5462
exit 1
5563
fi
5664

57-
if [[ -z "$REPO_OWNER" ]]
65+
if [[ -z "$REPO_OWNER" ]]
5866
then
5967
echo "ERROR: REPO_OWNER not provided"
6068
exit 1
6169
fi
6270

63-
if [[ -z "$REPO_NAME" ]]
64-
then
65-
echo "ERROR: REPO_NAME not provided"
66-
exit 1
67-
fi
68-
6971
print_header "Posting Message in Comments on GitHub"
7072
python3 post-msg.py $GITHUB_CREDS "{\"id\": $PR_ID,\"request\":\"$REQUEST\"}" $REPO_OWNER $REPO_NAME "$POST_MSG"
7173
check_exit_code "ERROR: Failed to post results to GitHub"

ci/clone-and-checkout-pr.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,17 @@
4141
cmd = "git clone " + str(repo.clone_url) + " repository"
4242

4343
child = pexpect.spawn(cmd)
44-
child.expect("Username.*")
45-
child.sendline(username + "\n")
46-
child.expect("Password.*")
47-
child.sendline(password + "\n")
44+
45+
if '-dev' in REPO_NAME:
46+
child.expect("Username.*")
47+
child.sendline(username + "\n")
48+
child.expect("Password.*")
49+
child.sendline(password + "\n")
50+
4851
child.interact()
4952

53+
# Get the latest branches for upstream (used for proper linter check)
54+
pexpect.run("git remote add upstream https://github.com/sdnfv/openNetVM.git", cwd="./repository")
55+
pexpect.run("git fetch upstream", cwd="./repository")
56+
5057
print(pexpect.run("git checkout " + branch_name, cwd="./repository"))

ci/helper-functions.sh

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ obtain_core_config() {
8787

8888
# checks if a command has failed (exited with code != 0)
8989
# if it does, print the error message, exit the build, and post to github
90-
check_exit_code(){
90+
check_exit_code() {
9191
if [ $? -ne 0 ]
9292
then
9393
echo $1
@@ -99,7 +99,46 @@ check_exit_code(){
9999

100100
# runs the linter
101101
run_linter() {
102-
for fn in $(git ls-files *.c | grep -v "cJSON" | grep -v "ndpi"); do
103-
python style/gwclint.py --verbose=5 $fn 2>&1 | grep -v "Done" | grep -v "Total errors found: 0" >> $1
102+
for fn in $(git diff --name-only upstream/develop...HEAD -- '*.c' '*.cpp' '*.h' | grep -v "cJSON" | grep -v "ndpi"); do
103+
git_file_diff=$(git diff -U0 upstream/develop...HEAD -- $fn)
104+
file_modifications=()
105+
while read -r diff_line; do
106+
# line number is denoted by @@ -lines_deleted +lines_added @@
107+
# For example: @@ -1257,3 +1175,3 @@ onvm_nflib_cleanup(struct onvm_nf_context *nf_context) {
108+
# We're interested in 1175, 3 as that shows the lines in the final file
109+
if [[ $diff_line == @@* ]]; then
110+
diff_line=$(cut -d ' ' -f 3 <<< "$diff_line")
111+
diff_line=${diff_line:1}
112+
line_start=$(cut -d ',' -f 1 <<< "$diff_line")
113+
line_end=$(cut -d ',' -f 2 <<< "$diff_line")
114+
# Expand the comment on one line diff vs multiline->therefore addition
115+
[[ ! $line_end == $line_start ]] && line_end=$(($line_start + $line_end))
116+
file_modifications[$line_start]=$line_end
117+
# create mapping of start of chunk -> end line
118+
fi
119+
done <<< "$git_file_diff"
120+
121+
# loop through the lines changed in the current file
122+
file_lint=$(python $SCRIPT_LOC/../style/gwclint.py --verbose=4 $fn 2>&1 | grep -v "Done" | grep -v "Total errors found:")
123+
errors_found=0
124+
while read -r line; do
125+
error_line=$(cut -d ':' -f 2 <<< "$line")
126+
# lint error is denoted by *:line:*
127+
for start in "${!file_modifications[@]}"; do
128+
# loop through the git diff line numbers
129+
end=${file_modifications[$start]}
130+
if [[ $error_line -ge $start && $error_line -le $end ]]; then
131+
# git diff and linter output are in range, add to lint file
132+
errors_found=$(($errors_found+1))
133+
echo "$line" >> $1
134+
break
135+
fi
136+
done
137+
done <<< "$file_lint"
138+
# loop through the linter output
139+
if [[ $errors_found -gt 0 ]]; then
140+
# only output to file if we had errors
141+
echo "Total errors found: $errors_found" >> $1
142+
fi
104143
done
105144
}

ci/manager.sh

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,18 @@ fi
3131

3232
if [[ -z "$3" ]]
3333
then
34-
echo "ERROR: Missing third argument, Request body!"
34+
echo "ERROR: Missing third argument, Repo name!"
3535
exit 1
3636
else
37-
REQUEST=$3
37+
REPO_NAME=$3
38+
fi
39+
40+
if [[ -z "$4" ]]
41+
then
42+
echo "ERROR: Missing fourth argument, Request body!"
43+
exit 1
44+
else
45+
REQUEST=$4
3846
fi
3947

4048
. $1 # source the variables from config file
@@ -60,12 +68,6 @@ then
6068
exit 1
6169
fi
6270

63-
if [[ -z "$REPO_NAME" ]]
64-
then
65-
echo "ERROR: REPO_NAME not provided"
66-
exit 1
67-
fi
68-
6971
print_header "Cleaning up Old Results"
7072

7173
sudo rm -f *.txt
@@ -188,13 +190,13 @@ do
188190
worker_key_file="${tuple_arr[1]}"
189191
scp -i $worker_key_file -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null $worker_ip:stats ./$worker_ip.stats
190192
check_exit_code "ERROR: Failed to fetch results from $worker_ip"
191-
echo "[Results from $worker_ip]" >> results_summary.stats
192-
python3 speed-tester-analysis.py ./$worker_ip.stats >> results_summary.stats
193+
# TODO: this will overwrite results if we have more than 1 worker, investigate this case
194+
python3 speed-tester-analysis.py ./$worker_ip.stats $worker_ip results_summary.stats
193195
check_exit_code "ERROR: Failed to analyze results from $worker_ip"
194196
done
195197

196198
print_header "Posting Results in Comment on GitHub"
197-
python3 post-msg.py $GITHUB_CREDS "{\"id\": $PR_ID,\"request\":\"$REQUEST\",\"linter\": 1,\"results\": 1}" $REPO_OWNER $REPO_NAME "Run successful see results:"
199+
python3 post-msg.py $GITHUB_CREDS "{\"id\": $PR_ID,\"request\":\"$REQUEST\",\"linter\": 1,\"results\": 1,\"review\": 1}" $REPO_OWNER $REPO_NAME "Run successful see results:"
198200
check_exit_code "ERROR: Failed to post results to GitHub"
199201

200202
print_header "Finished Executing"

0 commit comments

Comments
 (0)