NVIDIA GPU loadable plugin
Source
ctx context.Context, metricParams map[string]string, extraParams ...string,
/*
** Zabbix
** Copyright (C) 2001-2024 Zabbix SIA
**
** 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 plugin
import (
"context"
stdlog "log"
"os"
"testing"
"github.com/google/go-cmp/cmp"
"golang.zabbix.com/plugin/nvidia/pkg/nvml"
nvmlmock "golang.zabbix.com/plugin/nvidia/pkg/nvml-mock"
"golang.zabbix.com/sdk/errs"
"golang.zabbix.com/sdk/log"
"golang.zabbix.com/sdk/metric"
"golang.zabbix.com/sdk/plugin"
)
type MockCtxProvider struct {
plugin.ContextProvider
timeout int
}
func (m *MockCtxProvider) Timeout() int {
return m.timeout
}
func TestMain(m *testing.M) {
log.DefaultLogger = stdlog.New(os.Stdout, "", stdlog.LstdFlags)
exitVal := m.Run()
os.Exit(exitVal)
}
func Test_nvmlPlugin_Export(t *testing.T) {
t.Parallel()
testParams := []*metric.Param{
metric.NewConnParam("session", "Test session.").WithSession(),
metric.NewConnParam("conn", "Test Conn."),
metric.NewConnParam("default", "Test default.").WithDefault("default"),
}
type fields struct {
returnErr bool
}
type args struct {