You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: topology_test.go
    path of file: ./repos/erda/internal/tools/monitor/apm/topology
    
    the code of the file until where you have to start completion: // Copyright (c) 2021 Terminus, Inc.
//
// 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 topology

import (
	"bytes"
	"context"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"net/url"
	"reflect"
	"regexp"
	"strconv"
	"testing"
	"time"

	"bou.ke/monkey"
	"github.com/gofrs/uuid"
	"github.com/olivere/elastic"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"

	"github.com/erda-project/erda-infra/base/logs"
	"github.com/erda-project/erda-infra/base/servicehub"
	"github.com/erda-project/erda-infra/providers/i18n"
	metricpb "github.com/erda-project/erda-proto-go/core/monitor/metric/pb"
	"github.com/erda-project/erda/internal/tools/monitor/core/metric/query/chartmeta"
	query "github.com/erda-project/erda/internal/tools/monitor/core/metric/query/query/v1"

	"github.com/erda-project/erda/internal/tools/monitor/common/db"
	"github.com/erda-project/erda/internal/tools/monitor/core/metric/model"
	"github.com/erda-project/erda/internal/tools/monitor/core/metric/query/metricq"
	api "github.com/erda-project/erda/pkg/common/httpapi"
)

func TestSpliceIndexByTime(t *testing.T) {
	startTimeMs := 1603148400544 // 2020-10-20 07:00:00
	endTimeMs := 1603753200543   // 2020-10-27 07:00:00

	indices := createTypologyIndices(int64(startTimeMs), int64(endTimeMs))
	for _, index := range indices {
		fmt.Println(index)
	}
}

func TestJsonStrToStruct(t *testing.T) {
	str := `{"name":"application_micro_service","timestamp":1603671150000000000,"tags":{"_meta":"true","_metric_scope":"micro_service","_metric_scope_id":"z341b9c025b914180877ad7dbb9d80d9f","cluster_name":"terminus-dev","host":"node-010000006205","host_ip":"10.0.6.205","org_name":"terminus","source_application_id":"4","source_application_name":"apm-demo","source_org_id":"1","source_project_id":"1","source_project_name":"test","source_runtime_id":"48","source_runtime_name":"feature/simple_with_nacos","source_service_id":"4_feature/simple_with_nacos_apm-demo-dubbo","source_service_instance_id":"fae63126-78f8-4ddd-9756-c9d363211e5f","source_service_name":"apm-demo-dubbo","source_terminus_key":"z341b9c025
    
func TestGetServiceOverview(t *testing.T) {
	service := provider{
		metricq: mockMetricQuery{
			checkStmt: func(stmt string, params map[string]interface{}) {
				wantStmt := make(map[string]byte)
				wantStmt["sum(errors_sum) FROM application_http_service WHERE target_terminus_key=$terminus_key AND target_service_name=$service_name AND target_service_id=$service_id"] = 0
				wantStmt["SELECT service_name::tag,service_instance_id::tag,if(gt(now()-max(timestamp),300000000000),'stopping','running') FROM application_service_node WHERE terminus_key::tag=$terminus_key AND service_name=$service_name AND service_id=$service_id GROUP BY service_instance_id::tag"] = 1
				wantStmt["SELECT sum(errors_sum) FROM application_http_service WHERE target_terminus_key=$terminus_key AND target_service_name=$service_name AND target_service_id=$service_id"] = 1
				wantStmt["SELECT sum(errors_sum) FROM application_rpc_service WHERE target_terminus_key=$terminus_key AND target_service_name=$service_name AND target_service_id=$service_id"] = 1
				wantStmt["SELECT sum(errors_sum) FROM application_cache_service WHERE source_terminus_key=$terminus_key AND source_service_name=$service_name AND source_service_id=$service_id"] = 1
				wantStmt["SELECT sum(errors_sum) FROM application_db_service WHERE source_terminus_key=$terminus_key AND source_service_name=$service_name AND source_service_id=$service_id"] = 1
				wantStmt["SELECT sum(errors_sum) FROM application_mq_service WHERE source_terminus_key=$terminus_key AND source_service_name=$service_name AND source_service_id=$service_id"] = 1
				wantStmt["SELECT sum(count) FROM error_count WHERE terminus_key::tag=$terminus_key AND service_name=$service_name AND service_id=$service_id"] = 1
				wantStmt["SELECT count(alert_id::tag) FROM analyzer_alert WHERE terminus_key::tag=$terminus_key AND service_name=$service_name"] = 1

				if _, ok := wantStmt[stmt]; !ok {
					t.Errorf("stmt should be %v, but is %s", wantStmt, stmt)
					t.Log(stmt)
				}

				want := make(map[string]interface{})
				want["terminus_key"] = ""

				for wantK, wantV := range want {
					require.Equal(t, wantV, params[wantK])
				}
			},
			data: &model.ResultSet{
				Data: &model.Data{
					Rows: [][]interface{}{
						{
							"ServiceName",
							"ServiceInstanceName",
							"InstanceState",
						},
					},
				},
			},
		},
	}
	response, err := service.GetServiceOverview(context.Background(), nil, ServiceParams{})
	require.NoError(t, err)
	require.Equal(t, []map[string]interface{}{
		{
			"alert_count":             "ServiceName",
			"running_instances":       0,
			"service_error_req_count": float64(0),
			"service_exception_count": "ServiceName",
			"stopped_instances":       0,
		},
	}, response)
}