mirror of
https://github.com/googleforgames/open-match.git
synced 2025-03-25 13:24:18 +00:00
Move default evaluator to internal from testing (#1122)
This commit is contained in:
5
Makefile
5
Makefile
@ -196,7 +196,7 @@ ALL_PROTOS = $(GOLANG_PROTOS) $(SWAGGER_JSON_DOCS)
|
||||
CMDS = $(notdir $(wildcard cmd/*))
|
||||
|
||||
# Names of the individual images, ommiting the openmatch prefix.
|
||||
IMAGES = $(CMDS) mmf-go-soloduel mmf-go-pool evaluator-go-simple base-build
|
||||
IMAGES = $(CMDS) mmf-go-soloduel mmf-go-pool base-build
|
||||
|
||||
help:
|
||||
@cat Makefile | grep ^\#\# | grep -v ^\#\#\# |cut -c 4-
|
||||
@ -239,9 +239,6 @@ build-mmf-go-soloduel-image: docker build-base-build-image
|
||||
build-mmf-go-pool-image: docker build-base-build-image
|
||||
docker build -f test/matchfunction/Dockerfile -t $(REGISTRY)/openmatch-mmf-go-pool:$(TAG) -t $(REGISTRY)/openmatch-mmf-go-pool:$(ALTERNATE_TAG) .
|
||||
|
||||
build-evaluator-go-simple-image: docker build-base-build-image
|
||||
docker build -f test/evaluator/Dockerfile -t $(REGISTRY)/openmatch-evaluator-go-simple:$(TAG) -t $(REGISTRY)/openmatch-evaluator-go-simple:$(ALTERNATE_TAG) .
|
||||
|
||||
#######################################
|
||||
## push-images / push-<image name>-image: builds and pushes images to your
|
||||
## container registry.
|
||||
|
@ -14,11 +14,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"open-match.dev/open-match/internal/testing/evaluator"
|
||||
"open-match.dev/open-match/test/evaluator/evaluate"
|
||||
"open-match.dev/open-match/internal/app/evaluator"
|
||||
"open-match.dev/open-match/internal/app/evaluator/defaulteval"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Invoke the harness to setup a GRPC service that handles requests to run the evaluator.
|
||||
evaluator.RunEvaluator(evaluate.Evaluate)
|
||||
evaluator.RunEvaluator(defaulteval.Evaluate)
|
||||
}
|
@ -26,7 +26,7 @@ evaluator:
|
||||
enabled: false
|
||||
replicas: 3
|
||||
portType: ClusterIP
|
||||
image: openmatch-evaluator-go-simple
|
||||
image: openmatch-default-evaluator
|
||||
|
||||
evaluatorConfigs:
|
||||
# We use harness to implement the MMFs. MMF itself only requires one configmap but harness expects two,
|
||||
|
@ -12,7 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package evaluate
|
||||
// Package defaulteval provides a simple score based evaluator.
|
||||
package defaulteval
|
||||
|
||||
import (
|
||||
"math"
|
||||
@ -20,7 +21,7 @@ import (
|
||||
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
"github.com/sirupsen/logrus"
|
||||
"open-match.dev/open-match/internal/testing/evaluator"
|
||||
"open-match.dev/open-match/internal/app/evaluator"
|
||||
"open-match.dev/open-match/pkg/pb"
|
||||
)
|
||||
|
||||
@ -36,8 +37,8 @@ type matchInp struct {
|
||||
inp *pb.DefaultEvaluationCriteria
|
||||
}
|
||||
|
||||
// Evaluate is where your custom evaluation logic lives.
|
||||
// This sample evaluator sorts and deduplicates the input matches.
|
||||
// Evaluate sorts the matches by DefaultEvaluationCriteria.Score (optional),
|
||||
// then returns matches which don't collide with previously returned matches.
|
||||
func Evaluate(p *evaluator.Params) ([]string, error) {
|
||||
matches := make([]*matchInp, 0, len(p.Matches))
|
||||
nilEvlautionInputs := 0
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package evaluate
|
||||
package defaulteval
|
||||
|
||||
import (
|
||||
"testing"
|
||||
@ -21,7 +21,7 @@ import (
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
"github.com/golang/protobuf/ptypes/any"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"open-match.dev/open-match/internal/testing/evaluator"
|
||||
"open-match.dev/open-match/internal/app/evaluator"
|
||||
"open-match.dev/open-match/pkg/pb"
|
||||
)
|
||||
|
@ -21,18 +21,17 @@ import (
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"open-match.dev/open-match/internal/app/evaluator"
|
||||
"open-match.dev/open-match/internal/app/evaluator/defaulteval"
|
||||
"open-match.dev/open-match/internal/app/minimatch"
|
||||
"open-match.dev/open-match/internal/rpc"
|
||||
rpcTesting "open-match.dev/open-match/internal/rpc/testing"
|
||||
statestoreTesting "open-match.dev/open-match/internal/statestore/testing"
|
||||
"open-match.dev/open-match/internal/telemetry"
|
||||
"open-match.dev/open-match/internal/testing/evaluator"
|
||||
internalMmf "open-match.dev/open-match/internal/testing/mmf"
|
||||
"open-match.dev/open-match/internal/util"
|
||||
pb "open-match.dev/open-match/pkg/pb"
|
||||
"open-match.dev/open-match/test/matchfunction/mmf"
|
||||
|
||||
"open-match.dev/open-match/test/evaluator/evaluate"
|
||||
)
|
||||
|
||||
type inmemoryOM struct {
|
||||
@ -174,7 +173,7 @@ func createMatchFunctionForTest(t *testing.T, c *rpcTesting.TestContext) *rpcTes
|
||||
func createEvaluatorForTest(t *testing.T) *rpcTesting.TestContext {
|
||||
tc := rpcTesting.MustServeInsecure(t, func(p *rpc.ServerParams) {
|
||||
cfg := viper.New()
|
||||
assert.Nil(t, evaluator.BindService(p, cfg, evaluate.Evaluate))
|
||||
assert.Nil(t, evaluator.BindService(p, cfg, defaulteval.Evaluate))
|
||||
})
|
||||
|
||||
return tc
|
||||
|
@ -1,24 +0,0 @@
|
||||
# Copyright 2019 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.
|
||||
|
||||
FROM open-match-base-build as builder
|
||||
|
||||
WORKDIR /go/src/open-match.dev/open-match/test/evaluator
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o evaluator .
|
||||
|
||||
FROM gcr.io/distroless/static:nonroot
|
||||
WORKDIR /app/
|
||||
COPY --from=builder --chown=nonroot /go/src/open-match.dev/open-match/test/evaluator/evaluator /app/
|
||||
|
||||
ENTRYPOINT ["/app/evaluator"]
|
Reference in New Issue
Block a user