Skip to content

Commit

Permalink
Merge branch 'master' of github.com:magma/magma
Browse files Browse the repository at this point in the history
* 'master' of github.com:magma/magma:
  chore: Mark nas_converter_test as manual until flakiness is addressed (magma#12130)
  chore(mme): address GH11898 (magma#12129)
  fix(agw): Update DNS resolvers for ec2 instance (magma#12045)
  feat(feg_relay): move session proxy to NH implementation (magma#11080)
  chore: Use per_file_copt for MME unit test flag (magma#12112)
  chore(mme): Remove unused trace defines (magma#12055)
  chore: experiment with only applying ASAN and LSAN to Magma C files (magma#12113)
  Revert "test(mme): Add injection of state loaded in S1AP state manager (magma#11456)" (magma#12121)
  chore: bump ssri (magma#12032)
  feat(dp): Add grant attempt count (magma#12101)
  fix(mme): Fix typing_extensions version dependency on magma_test (magma#12110)
  • Loading branch information
ardzoht committed Mar 15, 2022
2 parents 8213c86 + 863a37d commit c0f9531
Show file tree
Hide file tree
Showing 37 changed files with 363 additions and 348 deletions.
20 changes: 8 additions & 12 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ common:devcontainer --repository_cache=/workspaces/magma/.bazel-cache-repo
build:devcontainer --define=folly_so=1

# TEST CONFIGS
# Bazel test runtime default: PATH=/bin:/usr/bin:/usr/local/bin
# Some python tests require access to /usr/sbin binaries (e.g. route, ifconfig)
# Bazel test runtime default: PATH=/bin:/usr/bin:/usr/local/bin
# Some python tests require access to /usr/sbin binaries (e.g. route, ifconfig)
build --test_env=PATH=/bin:/usr/bin:/usr/local/bin:/usr/sbin
# Use MAGMA_ROOT from the host system in tests.
# Needed by python tests (e.g. freedomfi_one_tests in enodebd)
# Use MAGMA_ROOT from the host system in tests.
# Needed by python tests (e.g. freedomfi_one_tests in enodebd)
build --test_env=MAGMA_ROOT
# For testing compile mme libraries with unit test flag
test --copt=-DMME_UNIT_TEST
# Compile mme libraries with unit test flag
test --per_file_copt=^lte/gateway/c/core/.*$@-DMME_UNIT_TEST

# CODE COVERAGE CONFIGS
build --javacopt="-source 8"
Expand All @@ -53,18 +53,14 @@ build:coverage --combined_report=lcov
build:coverage --instrumentation_filter="//(orc8r|lte)/gateway/(c|python)[/:],-//(orc8r|lte)/protos[/:],-/*/test[/:]"

# ASAN
build:asan --copt=-fsanitize=address
build:asan --copt=-fsanitize=undefined
build:asan --copt=-O0
build:asan --copt=-fno-omit-frame-pointer
build:asan --linkopt=-fsanitize=address
build:asan --linkopt=-fsanitize=undefined
build:asan --action_env=ASAN_OPTIONS=detect_leaks=1:color=always
build:asan --per_file_copt=^.*/gateway/c/.*$@-fsanitize=address,-fsanitize=undefined,-O0,-fno-omit-frame-pointer

# LSAN
build:lsan --copt=-fsanitize=leak
build:lsan --copt=-fno-omit-frame-pointer
build:lsan --linkopt=-fsanitize=leak
build:lsan --per_file_copt=^.*/gateway/c/.*$@-fsanitize=leak,-fno-omit-frame-pointer

# system bazelrc should include config specific to different build envs (--config=vm, --config=devcontainer, etc.)
try-import /etc/bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func (g *grantRequestGenerator) GenerateRequests(cbsd *active_mode.Cbsd) []*Requ
operationParam := chooseSuitableChannel(
cbsd.GetChannels(),
cbsd.GetEirpCapabilities(),
int(cbsd.GetGrantAttempts()),
g.indexProvider,
)
if operationParam == nil {
Expand Down Expand Up @@ -55,8 +56,14 @@ const (
func chooseSuitableChannel(
channels []*active_mode.Channel,
capabilities *active_mode.EirpCapabilities,
attempts int,
indexProvider ranges.IndexProvider,
) *operationParam {
// More sophisticated check will be implemented
// together with frequency preference
if attempts > 0 {
return nil
}
calc := newEirpCalculator(capabilities)
rs := toRanges(channels)
pts := ranges.Decompose(rs, minSASEirp-1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ const mega = 1e6

func TestGrantRequestGenerator(t *testing.T) {
data := []struct {
name string
capabilities *active_mode.EirpCapabilities
channels []*active_mode.Channel
expected []*request
name string
capabilities *active_mode.EirpCapabilities
channels []*active_mode.Channel
grantAttempts int
expected []*request
}{
{
name: "Should generate grant request with default max eirp",
Expand Down Expand Up @@ -81,13 +82,22 @@ func TestGrantRequestGenerator(t *testing.T) {
name: "Should not generate anything if there are no channels",
capabilities: getDefaultCapabilities(),
},
{
name: "Should not generate anything if there are grant attempts",
capabilities: getDefaultCapabilities(),
channels: []*active_mode.Channel{{
FrequencyRange: getDefaultFrequencyRange(),
}},
grantAttempts: 1,
},
}
for _, tt := range data {
t.Run(tt.name, func(t *testing.T) {
cbsd := &active_mode.Cbsd{
Id: "some_cbsd_id",
Channels: tt.channels,
EirpCapabilities: tt.capabilities,
GrantAttempts: int32(tt.grantAttempts),
}
g := sas.NewGrantRequestGenerator(&stubIndexProvider{})
actual := g.GenerateRequests(cbsd)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion dp/cloud/go/services/dp/storage/cbsd_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ func buildDetailedCbsdQuery(builder sq.StatementBuilderType) *db.Query {
return db.NewQuery().
WithBuilder(builder).
From(&DBCbsd{}).
Select(db.NewExcludeMask("network_id", "state_id", "is_deleted", "is_updated")).
Select(db.NewExcludeMask("network_id", "state_id",
"is_deleted", "is_updated", "grant_attempts")).
Join(db.NewQuery().
From(&DBCbsdState{}).
Select(db.NewIncludeMask("name"))).
Expand Down
3 changes: 2 additions & 1 deletion dp/cloud/go/services/dp/storage/cbsd_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func (s *CbsdManagerTestSuite) TestCreateCbsd() {

cbsd := getBaseCbsd()
cbsd.NetworkId = db.MakeString(someNetwork)
cbsd.GrantAttempts = db.MakeInt(0)
cbsd.IsDeleted = db.MakeBool(false)
cbsd.IsUpdated = db.MakeBool(false)
expected := []db.Model{
Expand Down Expand Up @@ -173,7 +174,7 @@ func (s *CbsdManagerTestSuite) TestUpdateCbsd() {
actual, err := db.NewQuery().
WithBuilder(s.resourceManager.GetBuilder()).
From(&storage.DBCbsd{}).
Select(db.NewExcludeMask("id", "state_id", "cbsd_id", "is_deleted")).
Select(db.NewExcludeMask("id", "state_id", "cbsd_id", "grant_attempts", "is_deleted")).
Where(sq.Eq{"id": cbsdId}).
Fetch()
s.Require().NoError(err)
Expand Down
6 changes: 6 additions & 0 deletions dp/cloud/go/services/dp/storage/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ type DBCbsd struct {
FccId sql.NullString
CbsdSerialNumber sql.NullString
LastSeen sql.NullTime
GrantAttempts sql.NullInt64
MinPower sql.NullFloat64
MaxPower sql.NullFloat64
AntennaGain sql.NullFloat64
Expand Down Expand Up @@ -345,6 +346,11 @@ func (c *DBCbsd) Fields() db.FieldMap {
BaseType: db.TimeType{X: &c.LastSeen},
Nullable: true,
},
"grant_attempts": &db.Field{
BaseType: db.IntType{X: &c.GrantAttempts},
HasDefault: true,
DefaultValue: 0,
},
"min_power": &db.Field{
BaseType: db.FloatType{X: &c.MinPower},
Nullable: true,
Expand Down
4 changes: 2 additions & 2 deletions dp/cloud/go/services/dp/storage/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ func TestFields(t *testing.T) {
model: &storage.DBCbsd{},
expected: []string{
"id", "network_id", "state_id", "cbsd_id", "user_id",
"fcc_id", "cbsd_serial_number", "last_seen", "min_power",
"max_power", "antenna_gain", "number_of_ports",
"fcc_id", "cbsd_serial_number", "last_seen", "grant_attempts",
"min_power", "max_power", "antenna_gain", "number_of_ports",
"is_deleted", "is_updated",
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ def process_grant_response(obj: ResponseDBProcessor, response: DBResponse, sessi
Returns:
None
"""
if response.response_code != ResponseCodes.SUCCESS.value:
cbsd = response.request.cbsd
if cbsd:
cbsd.grant_attempts += 1

grant = _get_or_create_grant_from_response(obj, response, session)
if not grant:
Expand Down Expand Up @@ -294,6 +298,8 @@ def _terminate_all_grants_from_response(response: DBResponse, session: Session)
if not cbsd_id:
return
cbsd = session.query(DBCbsd).filter(DBCbsd.cbsd_id == cbsd_id).scalar()
if cbsd:
cbsd.grant_attempts = 0
grant_ids = [
grant.id for grant in session.query(
DBGrant.id,
Expand Down

0 comments on commit c0f9531

Please sign in to comment.