Skip to content

Commit 6c7f128

Browse files
[sdn_tests]: Adding Build support for pins_ondatra (#12658)
1 parent 91f879a commit 6c7f128

21 files changed

+1613
-0
lines changed

sdn_tests/pins_ondatra/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bazel-*
2+
*.pem
3+
*.cnf
4+
*.orig

sdn_tests/pins_ondatra/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
load("@bazel_gazelle//:def.bzl", "gazelle")
2+
3+
# gazelle:prefix github.com/sonic-net/sonic-mgmt/sdn_tests/pins_ondatra
4+
gazelle(name = "gazelle")

sdn_tests/pins_ondatra/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Dependencies:
2+
- Linux (tested on ubuntu)
3+
- Go (https://go.dev/doc/install)
4+
- Bazel-5.4.0+ (https://bazel.build/install)
5+
- Rest of the dependencies should be auto-installed on bazel run.
6+
7+
# Compilation:
8+
```
9+
bazel build ...
10+
```
11+
12+
# Compile and Run Test:
13+
```
14+
bazel run //tests:test_name --test_strategy=exclusive --test_timeout=3600
15+
```
16+
17+
18+
# Debug code:
19+
- Install Delve (https://github.com/go-delve/delve/tree/master/Documentation/installation)
20+
- Compile repo in debug mode:
21+
```
22+
bazel build ... --strip=never --compilation_mode=dbg
23+
```
24+
- Run the test with dlv debugger:
25+
```
26+
dlv --wd=$PWD/tests/ exec bazel-bin/tests/test_name_/test_name -- --testbed=$PWD/testbeds/testbed.textproto
27+
// inside dlv; map path for debugging:
28+
config substitute-path external bazel-pins_ondatra/external
29+
```
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Copyright 2024 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
workspace(name = "com_github_sonic_net_sonic_mgmt_sdn_tests_pins_ondatra")
16+
17+
# -- Load buildifier -----------------------------------------------------------
18+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
19+
20+
# Bazel toolchain to build go-lang.
21+
http_archive(
22+
name = "io_bazel_rules_go",
23+
sha256 = "91585017debb61982f7054c9688857a2ad1fd823fc3f9cb05048b0025c47d023",
24+
urls = [
25+
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.42.0/rules_go-v0.42.0.zip",
26+
"https://github.com/bazelbuild/rules_go/releases/download/v0.42.0/rules_go-v0.42.0.zip",
27+
],
28+
)
29+
30+
# Gazelle to auto generate go-lang BUILD rules.
31+
http_archive(
32+
name = "bazel_gazelle",
33+
sha256 = "b7387f72efb59f876e4daae42f1d3912d0d45563eac7cb23d1de0b094ab588cf",
34+
urls = [
35+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
36+
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.34.0/bazel-gazelle-v0.34.0.tar.gz",
37+
],
38+
)
39+
40+
load("pins_deps.bzl", "pins_deps")
41+
42+
pins_deps()
43+
44+
# -- Load Rules Foreign CC -----------------------------------------------------
45+
46+
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
47+
48+
rules_foreign_cc_dependencies()
49+
50+
# -- Load GoLang Rules -----------------------------------------------------
51+
52+
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
53+
load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
54+
load("//:infra_deps.bzl", "binding_deps")
55+
56+
binding_deps()
57+
58+
go_rules_dependencies()
59+
60+
go_register_toolchains(version = "1.21.1")
61+
62+
gazelle_dependencies(go_repository_default_config = "@//:WORKSPACE.bazel")
63+
64+
# -- Load GRPC -------------------------------------------------------------
65+
66+
load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
67+
68+
switched_rules_by_language(
69+
name = "com_google_googleapis_imports",
70+
cc = True,
71+
go = True,
72+
grpc = True,
73+
)
74+
75+
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
76+
77+
grpc_deps()
78+
79+
load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")
80+
81+
grpc_extra_deps()
82+
83+
# -- Load Protobuf -------------------------------------------------------------
84+
85+
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
86+
87+
protobuf_deps()
88+
89+
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
90+
91+
rules_proto_dependencies()
92+
93+
rules_proto_toolchains()
94+
95+
### Bazel rules for many languages to compile PROTO into gRPC libraries
96+
http_archive(
97+
name = "rules_proto_grpc",
98+
sha256 = "f87d885ebfd6a1bdf02b4c4ba5bf6fb333f90d54561e4d520a8413c8d1fb7beb",
99+
strip_prefix = "rules_proto_grpc-4.5.0",
100+
urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/archive/4.5.0.tar.gz"],
101+
patch_args = ["-p1"],
102+
patches = [
103+
"//:bazel/patches/rules_proto_grpc.patch",
104+
],
105+
)
106+
107+
load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_repos", "rules_proto_grpc_toolchains")
108+
109+
rules_proto_grpc_toolchains()
110+
111+
rules_proto_grpc_repos()
112+
113+
# -- Load P4Runtime ------------------------------------------------------------
114+
115+
load("@com_github_p4lang_p4runtime//:p4runtime_deps.bzl", "p4runtime_deps")
116+
117+
p4runtime_deps()
118+
119+
# -- Load packaging rules ------------------------------------------------------
120+
121+
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
122+
123+
rules_pkg_dependencies()
124+
125+
# == Dependencies needed for testing and formatting only =======================
126+
127+
# -- Load p4c ------------------------------------------------------------------
128+
129+
load("@com_github_p4lang_p4c//:bazel/p4c_deps.bzl", "p4c_deps")
130+
131+
p4c_deps()
132+
133+
load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps")
134+
135+
boost_deps()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/BUILD.bazel b/BUILD.bazel
2+
index 4f4ecec..ee196e8 100644
3+
--- a/BUILD.bazel
4+
+++ b/BUILD.bazel
5+
@@ -6,6 +6,7 @@ go_library(
6+
"fields.go",
7+
"yaml.go",
8+
],
9+
+ deps = ["@in_gopkg_yaml_v2//:yaml_v2"],
10+
importpath = "github.com/ghodss/yaml",
11+
visibility = ["//visibility:public"],
12+
)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
diff --git a/proto/gnmi/BUILD.bazel b/proto/gnmi/BUILD.bazel
2+
index f471488..14a242b 100755
3+
--- a/proto/gnmi/BUILD.bazel
4+
+++ b/proto/gnmi/BUILD.bazel
5+
@@ -22,6 +22,17 @@ package(
6+
licenses = ["notice"],
7+
)
8+
9+
+proto_library(
10+
+ name = "gnmi_internal_proto",
11+
+ srcs = ["gnmi.proto"],
12+
+ deps = [
13+
+ "//proto/gnmi_ext:gnmi_ext_proto",
14+
+ "@com_google_protobuf//:any_proto",
15+
+ "@com_google_protobuf//:descriptor_proto",
16+
+ ],
17+
+ visibility = ["//visibility:private"],
18+
+)
19+
+
20+
proto_library(
21+
name = "gnmi_proto",
22+
srcs = ["gnmi.proto"],
23+
@@ -35,12 +46,12 @@ proto_library(
24+
25+
cc_proto_library(
26+
name = "gnmi_cc_proto",
27+
- deps = [":gnmi_proto"],
28+
+ deps = [":gnmi_internal_proto"],
29+
)
30+
31+
cc_grpc_library(
32+
name = "gnmi_cc_grpc_proto",
33+
- srcs = [":gnmi_proto"],
34+
+ srcs = [":gnmi_internal_proto"],
35+
generate_mocks = True,
36+
grpc_only = True,
37+
deps = [":gnmi_cc_proto"],

0 commit comments

Comments
 (0)