blob: 95252e2e069a691ad754f56ddfe3630bb392e18a [file] [log] [blame]
PUSHP RAJ7c521fa2021-12-06 14:19:03 +00001// SPDX-FileCopyrightText: 2021-present Open Networking Foundation <info@opennetworking.org>
2//
Sean Condon160ec1d2022-02-08 12:58:25 +00003// SPDX-License-Identifier: Apache-2.0
PUSHP RAJ7c521fa2021-12-06 14:19:03 +00004
5package tests
6
7import (
8 "context"
9 "testing"
10 "time"
11
12 "github.com/onosproject/helmit/pkg/helm"
13 "github.com/onosproject/helmit/pkg/input"
14 "github.com/onosproject/helmit/pkg/kubernetes"
15 "github.com/onosproject/helmit/pkg/test"
16 "github.com/onosproject/onos-test/pkg/onostest"
17 "github.com/stretchr/testify/assert"
18)
19
20const aetherCharts = "https://charts.aetherproject.org/"
21
22// ChronosUmbrellaSuite is the chronos-umbrella chart test suite
23type ChronosUmbrellaSuite struct {
24 test.Suite
25 c *input.Context
26}
27
28// SetupTestSuite sets up the chronos umbrella test suite
29func (s *ChronosUmbrellaSuite) SetupTestSuite(c *input.Context) error {
30 s.c = c
31 return nil
32}
33
34func getCredentials() (string, string, error) {
35 kubClient, err := kubernetes.New()
36 if err != nil {
37 return "", "", err
38 }
39 secrets, err := kubClient.CoreV1().Secrets().Get(context.Background(), onostest.SecretsName)
40 if err != nil {
41 return "", "", err
42 }
43 username := string(secrets.Object.Data["sd-ran-username"])
44 password := string(secrets.Object.Data["sd-ran-password"])
45
46 return username, password, nil
47}
48
49// TestInstall tests installing the chronos-umbrella chart
50func (s *ChronosUmbrellaSuite) TestInstall(t *testing.T) {
51 username, password, err := getCredentials()
52 assert.NoError(t, err)
53 registry := s.c.GetArg("registry").String("")
54
55 onos := helm.Chart("chronos-umbrella", aetherCharts).
56 Release("chronos-umbrella").
57 SetUsername(username).
58 SetPassword(password).
59 WithTimeout(15*time.Minute).
60 Set("import.prometheus.chronos.enabled", false).
61 Set("global.image.registry", registry)
62 assert.NoError(t, onos.Install(true))
63}