Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into symbolic_import_branch_172
  • Loading branch information
VSuryaprasad-HCL committed Jan 16, 2025
2 parents b8992bd + 9e8e2e2 commit c005550
Show file tree
Hide file tree
Showing 10 changed files with 473 additions and 6 deletions.
43 changes: 37 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ on:
jobs:
build:
name: Bazel Build and Test
# We use Ubuntu 20.04 as it comes with GCC v9.3 by default.
runs-on: ubuntu-20.04

runs-on: ubuntu-22.04
env:
BAZEL_CACHE_USER: github
BAZEL_CACHE_PWD: ${{ secrets.BAZEL_CACHE_PWD }}
BAZEL_CACHE_URL: pins-bazel-cache.onf.dev:9090

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Mount bazel cache
uses: actions/cache@v2
uses: actions/cache/restore@v3
with:
# See https://docs.bazel.build/versions/master/output_directories.html
path: "/tmp/repo-cache"
# See https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows
key: bazel-repo-cache-v1-${{ runner.os }}-${{ hashFiles('**/*_deps.bzl', '.bazelrc', '.bazelversion', 'WORKSPACE.bazel') }}
key: bazel-repo-cache-v3-${{ runner.os }}-${{ hashFiles('**/*_deps.bzl', '.bazelrc', '.bazelversion', 'WORKSPACE.bazel') }}
restore-keys: |
bazel-repo-cache-v1-${{ runner.os }}-
bazel-repo-cache-v3-${{ runner.os }}-
- name: Install system dependencies
run: ./install_dependencies.sh
Expand All @@ -39,6 +39,13 @@ jobs:
https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-${ARCH}
sudo chmod +x /usr/local/bin/bazel
- name: Save start time
uses: josStorer/get-current-time@v2
id: start-time
with:
# Unix timestamp -- seconds since 1970.
format: X

# Authentication is enabled for R/W access for builds on main and branch PRs
# Unauthenticated reads are allowed for PRs from forks
- name: Build and Test
Expand All @@ -51,3 +58,27 @@ jobs:
BAZEL_OPTS+=" --remote_download_minimal"
bazel build ${BAZEL_OPTS} //...
bazel test ${BAZEL_OPTS} //...
- name: Save end time
uses: josStorer/get-current-time@v2
id: end-time
with:
# Unix timestamp -- seconds since 1970.
format: X

- name: Calculate build duration
run: |
START=${{ steps.start-time.outputs.formattedTime }}
END=${{ steps.end-time.outputs.formattedTime }}
DURATION=$(( $END - $START ))
echo "duration=$DURATION" | tee "$GITHUB_ENV"
- name: Save bazel cache
uses: actions/cache/save@v3
# We create a new cache entry if either of the following is true:
# - We are on the master branch.
# - It took more than 5 minutes to build and test.
if: github.ref_name == 'main' || env.duration > 300
with:
path: "/tmp/repo-cache"
key: bazel-repo-cache-v3-${{ runner.os }}-${{ hashFiles('**/*_deps.bzl', '.bazelrc', '.bazelversion', 'WORKSPACE.bazel') }}
16 changes: 16 additions & 0 deletions pins_infra_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ def pins_infra_deps():
"https://github.com/google/boringssl/archive/b8a2bffc598f230484ff48a247526a9820facfc2.tar.gz",
],
)
if not native.existing_rule("com_github_nelhage_rules_boost"):
# This version includes the fix for boost failures due to the xz library issue.
http_archive(
name = "com_github_nelhage_rules_boost",
url = "https://github.com/nelhage/rules_boost/archive/5160325dbdc8c9e499f9d9917d913f35f1785d52.zip",
strip_prefix = "rules_boost-5160325dbdc8c9e499f9d9917d913f35f1785d52",
sha256 = "feb4b1294684c79df7c1e08f1aec5da0da52021e33db59c88edbe86b4d1a017a",
)
if not native.existing_rule("com_github_grpc_grpc"):
http_archive(
name = "com_github_grpc_grpc",
Expand Down Expand Up @@ -188,6 +196,14 @@ def pins_infra_deps():
build_file = "@//:bazel/BUILD.jsoncpp.bazel",
sha256 = "6da6cdc026fe042599d9fce7b06ff2c128e8dd6b8b751fca91eb022bce310880",
)
if not native.existing_rule("com_github_ivmai_cudd"):
http_archive(
name = "com_github_ivmai_cudd",
build_file = "@//:bazel/BUILD.cudd.bazel",
strip_prefix = "cudd-cudd-3.0.0",
sha256 = "5fe145041c594689e6e7cf4cd623d5f2b7c36261708be8c9a72aed72cf67acce",
urls = ["https://github.com/ivmai/cudd/archive/cudd-3.0.0.tar.gz"],
)
if not native.existing_rule("com_gnu_gmp"):
http_archive(
name = "com_gnu_gmp",
Expand Down
62 changes: 62 additions & 0 deletions tests/integration/system/nsf/interfaces/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copyright 2024 Google LLC
#
# 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
#
# https://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.

# This package contains the interfaces, structs, and enums to be used in PINs NSF tests.

package(
default_visibility = ["//visibility:public"],
licenses = ["notice"],
)

cc_library(
name = "flow_programmer",
testonly = True,
hdrs = ["flow_programmer.h"],
deps = [
"//thinkit:generic_testbed",
"@com_google_absl//absl/status",
],
)

cc_library(
name = "traffic_helper",
hdrs = ["traffic_helper.h"],
deps = [
"//thinkit:generic_testbed",
"@com_google_absl//absl/status",
],
)

cc_library(
name = "component_validator",
testonly = True,
hdrs = ["component_validator.h"],
deps = [
"//thinkit:generic_testbed",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings:string_view",
],
)

cc_library(
name = "test_params",
testonly = True,
hdrs = ["test_params.h"],
deps = [
":component_validator",
":flow_programmer",
":traffic_helper",
"//thinkit:generic_testbed_fixture",
],
)
105 changes: 105 additions & 0 deletions tests/integration/system/nsf/interfaces/component_validator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Copyright 2024 Google LLC
//
// 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.

#ifndef PINS_TESTS_INTEGRATION_SYSTEM_NSF_INTERFACES_COMPONENT_VALIDATOR_H_
#define PINS_TESTS_INTEGRATION_SYSTEM_NSF_INTERFACES_COMPONENT_VALIDATOR_H_

#include "absl/status/status.h"
#include "absl/strings/string_view.h"
#include "thinkit/generic_testbed.h"

namespace pins_test {

// Interface to provide a mechanism to implement component-level validations
// during NSF integration tests.
//
// The different methods of this interface are called *after* the corresponding
// operation is performed during the test.
//
// Eg. After every flow programming operation, the `OnFlowProgram` method is
// called.
//
// The given `version` is the image version of the software stack running on the
// SUT at the time the function is called.
//
// The given `testbed` can be used by the implementation to interact with the
// SUT, ControlDevice, TrafficClient, or the test environment.
//
// Typically an implementation of the `ComponentValidator` would grab and store
// some state which is specific to a particular component and/or validate it
// against such a previously stored component-specific state.
//
// Note that it can also be used for other kinds of validations that do not
// necessarily involve grabbing or validating state from the SUT.
//
// Eg. We can use these methods to track performance by calculating the time
// difference between function calls.
class ComponentValidator {
public:
virtual ~ComponentValidator() = default;

// Called before starting every NSF test.
virtual absl::Status OnInit(absl::string_view version,
thinkit::GenericTestbed& testbed) {
return absl::OkStatus();
}

// Called after programming flows on SUT.
virtual absl::Status OnFlowProgram(absl::string_view version,
thinkit::GenericTestbed& testbed) {
return absl::OkStatus();
}

// Called after starting traffic from the Control Device or the Traffic
// Generator in the testbed.
virtual absl::Status OnStartTraffic(absl::string_view version,
thinkit::GenericTestbed& testbed) {
return absl::OkStatus();
}

// Called after an upgrade is performed on the SUT.
virtual absl::Status OnUpgrade(absl::string_view version,
thinkit::GenericTestbed& testbed) {
return absl::OkStatus();
}

// Called after a successful NSF reboot of the SUT.
virtual absl::Status OnNsfReboot(absl::string_view version,
thinkit::GenericTestbed& testbed) {
return absl::OkStatus();
}

// Called after pushing config on the SUT.
virtual absl::Status OnConfigPush(absl::string_view version,
thinkit::GenericTestbed& testbed) {
return absl::OkStatus();
}

// Called after stopping traffic from the Control Device or the Traffic
// Generator in the testbed.
virtual absl::Status OnStopTraffic(absl::string_view version,
thinkit::GenericTestbed& testbed) {
return absl::OkStatus();
}

// Called after clearing up flows from the SUT.
virtual absl::Status OnFlowCleanup(absl::string_view version,
thinkit::GenericTestbed& testbed) {
return absl::OkStatus();
}
};

} // namespace pins_test

#endif // PINS_TESTS_INTEGRATION_SYSTEM_NSF_INTERFACES_COMPONENT_VALIDATOR_H_
43 changes: 43 additions & 0 deletions tests/integration/system/nsf/interfaces/flow_programmer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2024 Google LLC
//
// 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.

#ifndef PINS_TESTS_INTEGRATION_SYSTEM_NSF_INTERFACES_FLOW_PROGRAMMER_H_
#define PINS_TESTS_INTEGRATION_SYSTEM_NSF_INTERFACES_FLOW_PROGRAMMER_H_

#include "absl/status/status.h"
#include "thinkit/generic_testbed.h"

namespace pins_test {

enum class IpVersion { kIpv4, kIpv6 };
enum class Protocol { kTcp, kUdp };

// Interface to program or clear flows on the SUT of the given `testbed` during
// NSF integration tests.
class FlowProgrammer {
public:
virtual ~FlowProgrammer() = default;

// Programs a predefined flow on the SUT based on the given IP version and
// protocol.
virtual absl::Status ProgramFlows(IpVersion ip_version, Protocol protocol,
thinkit::GenericTestbed& testbed) = 0;

// Clears all flows on the SUT.
virtual absl::Status ClearFlows(thinkit::GenericTestbed& testbed) = 0;
};

} // namespace pins_test

#endif // PINS_TESTS_INTEGRATION_SYSTEM_NSF_INTERFACES_FLOW_PROGRAMMER_H_
42 changes: 42 additions & 0 deletions tests/integration/system/nsf/interfaces/test_params.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2024 Google LLC
//
// 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.

#ifndef PINS_TESTS_INTEGRATION_SYSTEM_NSF_INTERFACES_TEST_PARAMS_H_
#define PINS_TESTS_INTEGRATION_SYSTEM_NSF_INTERFACES_TEST_PARAMS_H_

#include <string>
#include <vector>

#include "tests/integration/system/nsf/interfaces/component_validator.h"
#include "tests/integration/system/nsf/interfaces/flow_programmer.h"
#include "tests/integration/system/nsf/interfaces/traffic_helper.h"
#include "thinkit/generic_testbed_fixture.h"

namespace pins_test {

// Struct to hold test parameters to be injected in PINs NSF integration tests.
//
// Note that the `name` is used as the name of the instantiation of the
// parameterized NSF integration test.
struct NsfTestParams {
std::string name;
FlowProgrammer* flow_programmer;
TrafficHelper* traffic_helper;
thinkit::GenericTestbedInterface* testbed_interface;
std::vector<ComponentValidator*> component_validators;
};

} // namespace pins_test

#endif // PINS_TESTS_INTEGRATION_SYSTEM_NSF_INTERFACES_TEST_PARAMS_H_
Loading

0 comments on commit c005550

Please sign in to comment.