Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CI

on:
push:
branches: master
pull_request:
branches: "*"

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
java: [8]
os: [ubuntu-18.04]

steps:
- uses: actions/checkout@v2

- name: Install bazel
run: |
wget https://github.com/bazelbuild/bazel/releases/download/3.7.0/bazel_3.7.0-linux-x86_64.deb
sudo dpkg -i bazel_3.7.0-linux-x86_64.deb
- name: Install clang8
run: |
echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" | sudo tee -a /etc/apt/sources.list
echo "deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" | sudo tee -a /etc/apt/sources.list
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install clang-8 clang-format-8

- name: Clang format checker
run: |
bash format.sh

- name: Library build
run: |
bazel build //sentinel-core/... && bazel build //sentinel-datasource-extension/...

- name: Sentinel core unit tests
run: |
bazel test --test_filter=*-ParamMetricTest.TestOperateMetric --test_output=errors --strategy=TestRunner=standalone //sentinel-core/...

- name: Sentinel datasource extension tests
run: |
bazel build //sentinel-core/... && bazel build //sentinel-datasource-extension/...

- name: tsan for flow control
run: |
bazel build -c dbg --config=clang-tsan //tests/... && ./bazel-bin/tests/tsan-flow
42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

24 changes: 14 additions & 10 deletions sentinel-core/circuitbreaker/slot_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

#include "sentinel-core/test/mock/statistic/node/mock.h"

#include "sentinel-core/common/string_resource_wrapper.h"
#include "sentinel-core/circuitbreaker/rule_manager.h"
#include "sentinel-core/circuitbreaker/rule.h"
#include "sentinel-core/circuitbreaker/rule_manager.h"
#include "sentinel-core/circuitbreaker/slot.h"
#include "sentinel-core/common/string_resource_wrapper.h"

using testing::_;
using testing::InSequence;
Expand Down Expand Up @@ -38,7 +38,7 @@ TEST(CircuitBreakerSlotTest, CircuitBreakerErrorRatioTest) {
std::make_shared<StringResourceWrapper>(resource_name, EntryType::OUT);
auto entry = std::make_shared<Entry>(resource, context);
entry->set_cur_node(node);

auto entry_error = std::make_shared<Entry>(resource, context);
entry_error->set_cur_node(node);
entry_error->set_error("test_error");
Expand All @@ -50,7 +50,8 @@ TEST(CircuitBreakerSlotTest, CircuitBreakerErrorRatioTest) {

// Test breaker checking when no rule exists.
for (int i = 0; i < 10; i++) {
Entry_And_Exit(slot_checker, slot_complete, entry, resource, node, 1, 0, myParams);
Entry_And_Exit(slot_checker, slot_complete, entry, resource, node, 1, 0,
myParams);
}

Rule rule{resource_name};
Expand All @@ -68,7 +69,8 @@ TEST(CircuitBreakerSlotTest, CircuitBreakerErrorRatioTest) {

// Test breaker checking when error entry happens.
for (int i = 0; i < 10; i++) {
Entry_And_Exit(slot_checker, slot_complete, entry_error, resource, node, 1, 0, myParams);
Entry_And_Exit(slot_checker, slot_complete, entry_error, resource, node, 1,
0, myParams);
}

EXPECT_EQ(cbs[0]->CurrentState(), State::kOpen);
Expand All @@ -89,7 +91,7 @@ TEST(CircuitBreakerSlotTest, CircuitBreakerErrorRatioTest) {
}

TEST(CircuitBreakerSlotTest, CircuitBreakerSlowRatioTest) {
std::string resource_name{"test_resource"};
std::string resource_name{"test_resource"};
EntryContextSharedPtr context =
std::make_shared<EntryContext>("test_context");
Stat::NodeSharedPtr node = std::make_shared<Stat::MockNode>();
Expand All @@ -110,7 +112,8 @@ TEST(CircuitBreakerSlotTest, CircuitBreakerSlowRatioTest) {

// Test breaker checking when no rule exists.
for (int i = 0; i < 10; i++) {
Entry_And_Exit(slot_checker, slot_complete, entry, resource, node, 1, 0, myParams);
Entry_And_Exit(slot_checker, slot_complete, entry, resource, node, 1, 0,
myParams);
}

Rule rule{resource_name};
Expand All @@ -129,7 +132,8 @@ TEST(CircuitBreakerSlotTest, CircuitBreakerSlowRatioTest) {

// Test breaker checking when slow entry happens.
for (int i = 0; i < 10; i++) {
Entry_And_Exit(slot_checker, slot_complete, entry_slow, resource, node, 1, 0, myParams);
Entry_And_Exit(slot_checker, slot_complete, entry_slow, resource, node, 1,
0, myParams);
}

EXPECT_EQ(cbs[0]->CurrentState(), State::kOpen);
Expand All @@ -149,5 +153,5 @@ TEST(CircuitBreakerSlotTest, CircuitBreakerSlowRatioTest) {
m.LoadRules({});
}

}
}
} // namespace CircuitBreaker
} // namespace Sentinel