forked from istio/istio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dispatcher improvements (istio#6034)
- Fix bug around handling of quotas. Mixer wasn't observing the requested quota name and getting quota from all defines instances. It now limits itself to the requested instances and produces an error if the proxy requests quota from an unknown instance, instead of failing open. - Pass CheckResult, QuotaResult, and QuotaMethodArgs by value. This is cleaner, avoids transient allocations, and eliminates some code paths.
- Loading branch information
1 parent
e0664b1
commit 4f93a9d
Showing
19 changed files
with
250 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2017 Istio Authors | ||
// | ||
// 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. | ||
|
||
package adapter | ||
|
||
import ( | ||
"testing" | ||
|
||
"istio.io/istio/mixer/pkg/status" | ||
) | ||
|
||
func TestCheckResult(t *testing.T) { | ||
cr := CheckResult{} | ||
s := cr.String() | ||
if s == "" { | ||
t.Error("Expected valid string") | ||
} | ||
|
||
if !cr.IsDefault() { | ||
t.Error("Expecting IsDefault to return true") | ||
} | ||
|
||
cr.Status = status.WithCancelled("FAIL") | ||
if cr.IsDefault() { | ||
t.Error("Expecting IsDefault to return false") | ||
} | ||
|
||
cr = CheckResult{ValidUseCount: 1} | ||
if cr.IsDefault() { | ||
t.Error("Expecting IsDefault to return false") | ||
} | ||
|
||
cr = CheckResult{ValidDuration: 10} | ||
if cr.IsDefault() { | ||
t.Error("Expecting IsDefault to return false") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2017 Istio Authors | ||
// | ||
// 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. | ||
|
||
package adapter | ||
|
||
import ( | ||
"testing" | ||
|
||
"istio.io/istio/mixer/pkg/status" | ||
) | ||
|
||
func TestQuotaResult(t *testing.T) { | ||
qr := QuotaResult{} | ||
|
||
if !qr.IsDefault() { | ||
t.Error("Expecting IsDefault to return true") | ||
} | ||
|
||
qr.Status = status.WithCancelled("FAIL") | ||
if qr.IsDefault() { | ||
t.Error("Expecting IsDefault to return false") | ||
} | ||
|
||
qr = QuotaResult{Amount: 1} | ||
if qr.IsDefault() { | ||
t.Error("Expecting IsDefault to return false") | ||
} | ||
|
||
qr = QuotaResult{ValidDuration: 10} | ||
if qr.IsDefault() { | ||
t.Error("Expecting IsDefault to return false") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.