From eb21f30aa4b0c6a7082443fed2e9feb0e9e953c5 Mon Sep 17 00:00:00 2001 From: Takeshi Yoneda Date: Wed, 23 Jun 2021 13:14:40 +0900 Subject: [PATCH] e2e fix and manifest changes (#43) Signed-off-by: Takeshi Yoneda Co-authored-by: Devarajan Ramaswamy --- api/manifest_util_test.go | 45 ++-- cmd/fetch_test.go | 9 +- cmd/gen_ca_test.go | 13 +- cmd/istioctl_test.go | 11 +- cmd/prune_test.go | 3 +- cmd/root.go | 1 - cmd/switch_test.go | 9 +- cmd/upgrade.go | 32 --- cmd/version.go | 11 - .../reference/getmesh_update/_index.md | 27 -- e2e/aws_config.yaml | 35 --- e2e/e2e_test.go | 246 ++++++++---------- e2e/gcp_config.yaml | 33 --- e2e/gen_ca_aws_test.go | 4 +- e2e/gen_ca_gcp_test.go | 4 +- e2e/gen_ca_test.go | 16 +- site/manifest.json | 156 +++++------ src/cacerts/certutils/certificate_test.go | 5 +- src/cacerts/providers/aws_test.go | 7 +- src/cacerts/providers/config/config_test.go | 25 +- src/checkupgrade/check_upgrade_test.go | 47 ++-- src/configvalidator/files_test.go | 5 +- .../kiali_client_wrapper_test.go | 6 +- src/configvalidator/print_test.go | 11 +- src/configvalidator/validation_istio_test.go | 4 +- src/configvalidator/validator_test.go | 14 +- src/getmesh/getmesh.go | 108 -------- src/getmesh/getmesh_test.go | 137 ---------- src/istioctl/istioctl.go | 2 +- src/istioctl/istioctl_test.go | 40 +-- src/manifest/checker_endoflife_test.go | 7 +- src/manifest/checker_security_patch_test.go | 11 +- src/manifest/manifest_test.go | 7 +- src/util/kube_test.go | 8 +- src/util/util_test.go | 7 +- 35 files changed, 318 insertions(+), 788 deletions(-) delete mode 100644 cmd/upgrade.go delete mode 100644 doc/en/getmesh-cli/reference/getmesh_update/_index.md delete mode 100644 e2e/aws_config.yaml delete mode 100644 e2e/gcp_config.yaml delete mode 100644 src/getmesh/getmesh.go delete mode 100644 src/getmesh/getmesh_test.go diff --git a/api/manifest_util_test.go b/api/manifest_util_test.go index bcf89c9..778556b 100644 --- a/api/manifest_util_test.go +++ b/api/manifest_util_test.go @@ -6,7 +6,6 @@ import ( "io/ioutil" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -47,9 +46,9 @@ func Test_parseManifestEOLDate(t *testing.T) { a, err := parseManifestEOLDate(c.in) require.NoError(t, err) y, m, d := a.Date() - assert.Equal(t, c.expYear, y) - assert.Equal(t, c.expMonth, int(m)) - assert.Equal(t, c.expDay, d) + require.Equal(t, c.expYear, y) + require.Equal(t, c.expMonth, int(m)) + require.Equal(t, c.expDay, d) } }) } @@ -84,7 +83,7 @@ func TestIstioDistribution_ToString(t *testing.T) { exp: "1.8.3-istio-v0", }, } { - assert.Equal(t, c.exp, c.in.ToString()) + require.Equal(t, c.exp, c.in.ToString()) } } @@ -124,7 +123,7 @@ func TestIstioDistributionEqual(t *testing.T) { exp: false, }, } { - assert.Equal(t, c.exp, c.in.Equal(operand)) + require.Equal(t, c.exp, c.in.Equal(operand)) } } @@ -154,12 +153,12 @@ func TestIstioDistribution_ExistInManifest(t *testing.T) { ok, err := d.ExistInManifest(ms) require.NoError(t, err) - assert.True(t, ok) + require.True(t, ok) d.FlavorVersion-- ok, err = d.ExistInManifest(ms) require.NoError(t, err) - assert.False(t, ok) + require.False(t, ok) } func TestIstioDistribution_Group(t *testing.T) { @@ -173,14 +172,14 @@ func TestIstioDistribution_Group(t *testing.T) { } { actual, err := c.in.Group() require.NoError(t, err) - assert.Equal(t, c.exp, actual) + require.Equal(t, c.exp, actual) } } func TestIstioDistribution_IsUpstream(t *testing.T) { - assert.True(t, (&IstioDistribution{Flavor: "istio"}).IsUpstream()) - assert.False(t, (&IstioDistribution{Flavor: "tetrate"}).IsUpstream()) - assert.False(t, (&IstioDistribution{Flavor: "tetratefips"}).IsUpstream()) + require.True(t, (&IstioDistribution{Flavor: "istio"}).IsUpstream()) + require.False(t, (&IstioDistribution{Flavor: "tetrate"}).IsUpstream()) + require.False(t, (&IstioDistribution{Flavor: "tetratefips"}).IsUpstream()) } func TestIstioDistribution_GreaterThan(t *testing.T) { @@ -192,7 +191,7 @@ func TestIstioDistribution_GreaterThan(t *testing.T) { } { actual, err := base.GreaterThan(c) require.NoError(t, err) - assert.True(t, actual) + require.True(t, actual) } }) @@ -203,7 +202,7 @@ func TestIstioDistribution_GreaterThan(t *testing.T) { } { actual, err := base.GreaterThan(c) require.NoError(t, err) - assert.False(t, actual) + require.False(t, actual) } }) } @@ -211,7 +210,7 @@ func TestIstioDistribution_GreaterThan(t *testing.T) { func TestIstioDistribution_Equal(t *testing.T) { base := &IstioDistribution{Version: "1.2.3", Flavor: "tetrate", FlavorVersion: 40} t.Run("true", func(t *testing.T) { - assert.True(t, base.Equal(&IstioDistribution{Version: "1.2.3", Flavor: "tetrate", FlavorVersion: 40})) + require.True(t, base.Equal(&IstioDistribution{Version: "1.2.3", Flavor: "tetrate", FlavorVersion: 40})) }) t.Run("false", func(t *testing.T) { @@ -249,7 +248,7 @@ func TestIstioDistributionFromString(t *testing.T) { } { v, err := IstioDistributionFromString(c.in) require.NoError(t, err, c.in, c.in) - assert.Equal(t, c.exp, v) + require.Equal(t, c.exp, v) } }) @@ -260,7 +259,7 @@ func TestIstioDistributionFromString(t *testing.T) { "1.6.7-tetrate-v", "1.7.113-tetrate-", } { _, err := IstioDistributionFromString(in) - assert.Error(t, err, in) + require.Error(t, err, in) } }) } @@ -277,8 +276,8 @@ func Test_parseFlavor(t *testing.T) { } { flavor, flavorVersion, err := parseFlavor(c.in) require.NoError(t, err) - assert.Equal(t, c.flavor, flavor) - assert.Equal(t, c.flavorVersion, flavorVersion) + require.Equal(t, c.flavor, flavor) + require.Equal(t, c.flavorVersion, flavorVersion) } }) @@ -572,13 +571,13 @@ func TestGetLatestDistribution(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { latest, isSecure, err := GetLatestDistribution(test.current, test.maniest) - assert.NoError(t, err) + require.NoError(t, err) if latest == nil { - assert.Equal(t, latest, test.wants) + require.Equal(t, latest, test.wants) } else { - assert.True(t, latest.Equal(test.wants)) + require.True(t, latest.Equal(test.wants)) } - assert.Equal(t, test.wantsSecure, isSecure) + require.Equal(t, test.wantsSecure, isSecure) }) } } diff --git a/cmd/fetch_test.go b/cmd/fetch_test.go index 262df9b..b2a63a2 100644 --- a/cmd/fetch_test.go +++ b/cmd/fetch_test.go @@ -18,8 +18,7 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/assert" - + "github.com/stretchr/testify/require" "github.com/tetratelabs/getmesh/api" ) @@ -139,10 +138,10 @@ func Test_fetchParams(t *testing.T) { t.Run(fmt.Sprintf("%d-th case", i), func(t *testing.T) { actual, err := fetchParams(c.flag, c.mf) if c.exp == nil { - assert.Error(t, err) + require.Error(t, err) } else { - assert.NoError(t, err) - assert.Equal(t, c.exp, actual) + require.NoError(t, err) + require.Equal(t, c.exp, actual) } }) diff --git a/cmd/gen_ca_test.go b/cmd/gen_ca_test.go index e55f4f3..98c83be 100644 --- a/cmd/gen_ca_test.go +++ b/cmd/gen_ca_test.go @@ -24,7 +24,6 @@ import ( "github.com/spf13/pflag" "github.com/stretchr/testify/require" - "gotest.tools/assert" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes/fake" @@ -58,7 +57,7 @@ func TestPreFlightChecks(t *testing.T) { cfg.SetDefaultValues() cfg.DisableSecretCreation = false err := genCAPreFlightChecks(cfg, cs) - assert.ErrorContains(t, err, "namespaces \"istio-system\" not found") + require.Contains(t, err.Error(), "namespaces \"istio-system\" not found") ns := &v1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: "istio-system"}} _, err = cs.CoreV1().Namespaces().Create(context.Background(), ns, metav1.CreateOptions{}) @@ -76,21 +75,21 @@ func TestPreFlightChecks(t *testing.T) { cs := fake.NewSimpleClientset() cfg := &config.Config{} cfg.DisableSecretCreation = true - assert.Equal(t, genCAPreFlightChecks(cfg, cs), nil) + require.Equal(t, genCAPreFlightChecks(cfg, cs), nil) // readonly error ro := filepath.Join(d, "readonly") require.NoError(t, os.Mkdir(ro, 0400)) cfg.CertParameters.SecretFilePath = filepath.Join(ro, "test.yaml") err = genCAPreFlightChecks(cfg, cs) - assert.ErrorContains(t, err, "unable to write on secret file path:") + require.Contains(t, err.Error(), "unable to write on secret file path:") // ok f, err := ioutil.TempFile(d, "") require.NoError(t, err) cfg.CertParameters.SecretFilePath = f.Name() err = genCAPreFlightChecks(cfg, cs) - assert.ErrorContains(t, err, f.Name()+"` already exist, please change the file path before proceeding") + require.Contains(t, err.Error(), f.Name()+"` already exist, please change the file path before proceeding") }) } @@ -115,7 +114,7 @@ func TestFetchParametersError(t *testing.T) { t.Run(c.label, func(t *testing.T) { require.NoError(t, flags.Parse(c.arguments)) _, err := genCAFetchParameters(flags) - assert.ErrorContains(t, err, c.expected) + require.Contains(t, err.Error(), c.expected) }) } } @@ -250,7 +249,7 @@ func TestFetchParametersSucess(t *testing.T) { // so explicit error checks aren't required cfg, err := genCAFetchParameters(flags) require.NoError(t, err) - assert.Equal(t, true, c.checker(cfg)) + require.Equal(t, true, c.checker(cfg)) }) } } diff --git a/cmd/istioctl_test.go b/cmd/istioctl_test.go index 99dd585..7b821d3 100644 --- a/cmd/istioctl_test.go +++ b/cmd/istioctl_test.go @@ -20,7 +20,6 @@ import ( "os" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tetratelabs/getmesh/api" @@ -103,7 +102,7 @@ func TestIstioctl_istioctlArgChecks(t *testing.T) { require.Error(t, err) }) - assert.Contains(t, buf.String(), "Your active istioctl of version 1.7.4-tetratefips-v0 is deprecated.") + require.Contains(t, buf.String(), "Your active istioctl of version 1.7.4-tetratefips-v0 is deprecated.") t.Log(buf.String()) }) } @@ -172,7 +171,7 @@ func TestIstioctl_istioctlParsePreCheckArgs(t *testing.T) { for _, c := range cases { t.Run(c.name, func(t *testing.T) { actual := istioctlParsePreCheckArgs(c.args) - assert.Equal(t, c.exp, actual) + require.Equal(t, c.exp, actual) }) } } @@ -247,7 +246,7 @@ func TestIstioctl_istioctlParseVerifyInstallArgs(t *testing.T) { for _, c := range cases { t.Run(c.name, func(t *testing.T) { actual := istioctlParseVerifyInstallArgs(c.args) - assert.Equal(t, c.exp, actual) + require.Equal(t, c.exp, actual) }) } } @@ -277,7 +276,7 @@ func TestIstioctl_istioctPatchVersionCheck(t *testing.T) { require.Error(t, istioctlPatchVersionCheck(current, m)) }) - assert.Contains(t, buf.String(), "your current patch version 1.7.5 is not the latest version 1.7.6") + require.Contains(t, buf.String(), "your current patch version 1.7.5 is not the latest version 1.7.6") t.Log(buf.String()) }) @@ -379,7 +378,7 @@ func TestIstioctl_istioctlPreProcessArgs(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { actual := istioctlPreProcessArgs(test.args) - assert.Equal(t, test.wants, actual) + require.Equal(t, test.wants, actual) }) } } diff --git a/cmd/prune_test.go b/cmd/prune_test.go index 0b8a984..0e5317e 100644 --- a/cmd/prune_test.go +++ b/cmd/prune_test.go @@ -18,7 +18,6 @@ import ( "strconv" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tetratelabs/getmesh/api" @@ -50,7 +49,7 @@ func Test_pruneCheckFlags(t *testing.T) { } else { require.NoError(t, err) } - assert.Equal(t, c.exp, actual) + require.Equal(t, c.exp, actual) }) } } diff --git a/cmd/root.go b/cmd/root.go index 0243b0f..73a54b6 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -89,7 +89,6 @@ func NewRoot(version, homeDir string) *cobra.Command { cmd.AddCommand(newShowCmd(homeDir)) cmd.AddCommand(newConfigValidateCmd(homeDir)) cmd.AddCommand(newGenCACmd()) - cmd.AddCommand(newUpgradeCmd(version)) cmd.AddCommand(newPruneCmd(homeDir)) cmd.AddCommand(newSetDefaultHubCmd(homeDir)) diff --git a/cmd/switch_test.go b/cmd/switch_test.go index dfdff98..ccb1f90 100644 --- a/cmd/switch_test.go +++ b/cmd/switch_test.go @@ -21,7 +21,6 @@ import ( "strings" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tetratelabs/getmesh/api" @@ -88,21 +87,21 @@ func Test_switchParse(t *testing.T) { distro, err := switchParse(home, flag) require.NoError(t, err) exp := &api.IstioDistribution{Version: "1.7.6", Flavor: "istio", FlavorVersion: 0} - assert.Equal(t, distro, exp) + require.Equal(t, distro, exp) }) t.Run("name", func(t *testing.T) { flag := &switchFlags{name: "1.8.3-istio-v0"} distro, err := switchParse(home, flag) require.NoError(t, err) exp := &api.IstioDistribution{Version: "1.8.3", Flavor: "istio", FlavorVersion: 0} - assert.Equal(t, distro, exp) + require.Equal(t, distro, exp) }) t.Run("group", func(t *testing.T) { flag := &switchFlags{version: "1.7", flavor: "istio", flavorVersion: 0} distro, err := switchParse(home, flag) require.NoError(t, err) exp := &api.IstioDistribution{Version: "1.7.6", Flavor: "istio", FlavorVersion: 0} - assert.Equal(t, distro, exp) + require.Equal(t, distro, exp) }) } @@ -135,6 +134,6 @@ func Test_switchHandleDistro(t *testing.T) { } { v, err := switchHandleDistro(c.curr, c.flags) require.NoError(t, err) - assert.Equal(t, c.exp, v) + require.Equal(t, c.exp, v) } } diff --git a/cmd/upgrade.go b/cmd/upgrade.go deleted file mode 100644 index 1470ba6..0000000 --- a/cmd/upgrade.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2021 Tetrate -// -// 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 cmd - -import ( - "github.com/spf13/cobra" - - "github.com/tetratelabs/getmesh/src/getmesh" -) - -func newUpgradeCmd(version string) *cobra.Command { - return &cobra.Command{ - Use: "update", - Short: "Update getmesh itself to the latest version", - Long: `Update getmesh itself to the latest version`, - RunE: func(cmd *cobra.Command, args []string) error { - return getmesh.Update(version) - }, - } -} diff --git a/cmd/version.go b/cmd/version.go index cec41b4..1ac7175 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -75,17 +75,6 @@ func newVersionCmd(homedir, getmeshVersion string) *cobra.Command { } } - latest, err := getmesh.LatestVersion() - if err != nil { - return fmt.Errorf("failed to check getmesh's latest version: %v", err) - } - - if latest != getmeshVersion { - logger.Infof( - "\nThe latest getmesh of version %s is available. Please run 'getmesh update' to install %s\n", - latest, latest) - } - return nil }, } diff --git a/doc/en/getmesh-cli/reference/getmesh_update/_index.md b/doc/en/getmesh-cli/reference/getmesh_update/_index.md deleted file mode 100644 index 6e9a411..0000000 --- a/doc/en/getmesh-cli/reference/getmesh_update/_index.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -title: "getmesh update" -url: /getmesh-cli/reference/getmesh_update/ ---- - -Update getmesh itself to the latest version - -``` -getmesh update [flags] -``` - -#### Options - -``` - -h, --help help for update -``` - -#### Options inherited from parent commands - -``` - -c, --kubeconfig string Kubernetes configuration file -``` - -#### SEE ALSO - -* [getmesh](/getmesh-cli/reference/getmesh/) - getmesh is an integration and lifecycle management CLI tool that ensures the use of supported and trusted versions of Istio. - diff --git a/e2e/aws_config.yaml b/e2e/aws_config.yaml deleted file mode 100644 index 14ede39..0000000 --- a/e2e/aws_config.yaml +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2021 Tetrate -# -# 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. - -providerName: "aws" -providerConfig: - aws: - creds: "creds" - signingCAArn: "arn:aws:acm-pca:us-west-2:867429062264:certificate-authority/b5bb389e-9a9f-46c4-9410-6cc123805cd9" - templateArn: "arn:aws:acm-pca:::template/SubordinateCACertificate_PathLen0/V1" -certificateParameters: - secretOptions: - istioCANamespace: "istio-system" - caOptions: - keyLength: 2048 - validityDays: 100 - certSigningRequestParams: - subject: - commonname: "Istio CA" - country: - - "US" - locality: - - "Sunnyvale" - organization: - - "Istio" diff --git a/e2e/e2e_test.go b/e2e/e2e_test.go index 9e7adb6..4588e37 100644 --- a/e2e/e2e_test.go +++ b/e2e/e2e_test.go @@ -15,9 +15,7 @@ package e2e import ( - "archive/tar" "bytes" - "compress/gzip" "encoding/json" "fmt" "io/ioutil" @@ -26,14 +24,11 @@ import ( "net/http/httptest" "os" "os/exec" - "os/user" - "path/filepath" "strconv" "strings" "testing" "time" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tetratelabs/getmesh/api" @@ -68,24 +63,21 @@ func TestMain(m *testing.M) { os.Exit(m.Run()) } -func getTestBinaryServer(t *testing.T) *httptest.Server { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - raw, err := ioutil.ReadFile("getmesh") - require.NoError(t, err) - - gz := gzip.NewWriter(w) - defer gz.Close() - - tw := tar.NewWriter(gz) - defer tw.Close() - - hdr := &tar.Header{Name: "getmesh", Mode: 0600, Size: int64(len(raw))} - require.NoError(t, tw.WriteHeader(hdr)) - _, err = tw.Write(raw) - require.NoError(t, err) - })) - return ts -} +// func getTestBinaryServer(t *testing.T) *httptest.Server { +// ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { +// raw, err := ioutil.ReadFile("getmesh") +// require.NoError(t, err) +// gz := gzip.NewWriter(w) +// defer gz.Close() +// tw := tar.NewWriter(gz) +// defer tw.Close() +// hdr := &tar.Header{Name: "getmesh", Mode: 0600, Size: int64(len(raw))} +// require.NoError(t, tw.WriteHeader(hdr)) +// _, err = tw.Write(raw) +// require.NoError(t, err) +// })) +// return ts +// } func Test_E2E(t *testing.T) { t.Run("getmesh_install", getmeshInstall) @@ -98,7 +90,6 @@ func Test_E2E(t *testing.T) { t.Run("switch", switchTest) t.Run("istioctl_install", istioctlInstall) t.Run("unknown", unknown) - t.Run("update", update) t.Run("version", version) t.Run("check-upgrade", checkUpgrade) t.Run("config-validate", configValidate) @@ -132,53 +123,44 @@ func securityPatchChecker(t *testing.T) { cmd.Stderr = os.Stderr cmd.Env = append(os.Environ(), fmt.Sprintf("GETMESH_TEST_MANIFEST_PATH=%s", f.Name())) require.NoError(t, cmd.Run()) - assert.Contains(t, buf.String(), `[WARNING] The locally installed minor version 1.9-tetrate has a latest version 1.9.1000000000000-tetrate-v0 including security patches. We strongly recommend you to download 1.9.1000000000000-tetrate-v0 by "getmesh fetch".`) -} - -func update(t *testing.T) { - ts := getTestBinaryServer(t) - defer ts.Close() - env := append(os.Environ(), fmt.Sprintf("GETMESH_TEST_BINRAY_URL=%s", ts.URL)) - - cmd := exec.Command("./getmesh", "update") - buf := new(bytes.Buffer) - cmd.Stdout = buf - cmd.Stderr = os.Stderr - cmd.Env = env - require.NoError(t, cmd.Run(), buf.String()) - actual := buf.String() - assert.Contains(t, actual, "getmesh successfully updated from dev to 1.0.6!") - t.Log(actual) + require.Contains(t, buf.String(), `[WARNING] The locally installed minor version 1.9-tetrate has a latest version 1.9.1000000000000-tetrate-v0 including security patches. We strongly recommend you to download 1.9.1000000000000-tetrate-v0 by "getmesh fetch".`) } func getmeshInstall(t *testing.T) { - ts := getTestBinaryServer(t) - defer ts.Close() - env := append(os.Environ(), fmt.Sprintf("GETMESH_TEST_BINRAY_URL=%s", ts.URL)) - - cmd := exec.Command("bash", "site/install.sh") - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Env = env - require.NoError(t, cmd.Run()) - - // check directory - u, err := user.Current() - require.NoError(t, err) - gh := filepath.Join(u.HomeDir, ".getmesh") - _, err = os.Stat(filepath.Join(gh, "bin/getmesh")) - require.NoError(t, err) - _, err = os.Stat(filepath.Join(gh, "istio")) - require.NoError(t, err) - - // install again, and check if it does not break anything - cmd = exec.Command("bash", "site/install.sh") + // TODO: revert after the next release + // ts := getTestBinaryServer(t) + // defer ts.Close() + // env := append(os.Environ(), fmt.Sprintf("GETMESH_TEST_BINRAY_URL=%s", ts.URL)) + + // cmd := exec.Command("bash", "site/install.sh") + // cmd.Stdout = os.Stdout + // cmd.Stderr = os.Stderr + // cmd.Env = env + // require.NoError(t, cmd.Run()) + + // // check directory + // u, err := user.Current() + // require.NoError(t, err) + // gh := filepath.Join(u.HomeDir, ".getmesh") + // _, err = os.Stat(filepath.Join(gh, "bin/getmesh")) + // require.NoError(t, err) + // _, err = os.Stat(filepath.Join(gh, "istio")) + // require.NoError(t, err) + + // // install again, and check if it does not break anything + // cmd = exec.Command("bash", "site/install.sh") + // cmd.Stdout = os.Stdout + // cmd.Stderr = os.Stderr + // cmd.Env = env + // require.NoError(t, cmd.Run()) + // _, err = os.Stat(filepath.Join(gh, "bin/getmesh")) + // require.NoError(t, err) + + cmd := exec.Command("./getmesh", "fetch", "--version", "1.9.5", + "--flavor", "tetrate", "--flavor-version", strconv.Itoa(0)) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - cmd.Env = env require.NoError(t, cmd.Run()) - _, err = os.Stat(filepath.Join(gh, "bin/getmesh")) - require.NoError(t, err) } func enfOfLife(t *testing.T) { @@ -191,7 +173,7 @@ func enfOfLife(t *testing.T) { cmd.Stdout = buf cmd.Stderr = os.Stderr require.NoError(t, cmd.Run()) - assert.Contains(t, buf.String(), `Your current active minor version 1.6 is reaching the end of life on 2020-11-21. We strongly recommend you to upgrade to the available higher minor versions`) + require.Contains(t, buf.String(), `Your current active minor version 1.6 is reaching the end of life on 2020-11-21. We strongly recommend you to upgrade to the available higher minor versions`) } func list(t *testing.T) { @@ -202,48 +184,44 @@ func list(t *testing.T) { require.NoError(t, cmd.Run()) exp := `ISTIO VERSION FLAVOR FLAVOR VERSION K8S VERSIONS - *1.9.1 tetrate 0 1.17,1.18,1.19,1.20 - 1.9.1 istio 0 1.17,1.18,1.19,1.20 + *1.9.5 tetrate 0 1.17,1.18,1.19,1.20 + 1.9.5 istio 0 1.17,1.18,1.19,1.20 + 1.9.4 tetrate 0 1.17,1.18,1.19,1.20 + 1.9.4 istio 0 1.17,1.18,1.19,1.20 1.9.0 tetrate 0 1.17,1.18,1.19,1.20 1.9.0 tetratefips 1 1.17,1.18,1.19,1.20 1.9.0 istio 0 1.17,1.18,1.19,1.20 - 1.8.4 tetrate 0 1.16,1.17,1.18,1.19 - 1.8.4 istio 0 1.16,1.17,1.18,1.19 + 1.8.6 tetrate 0 1.16,1.17,1.18,1.19 + 1.8.6 istio 0 1.16,1.17,1.18,1.19 + 1.8.5 tetrate 0 1.16,1.17,1.18,1.19 + 1.8.5 istio 0 1.16,1.17,1.18,1.19 1.8.3 tetrate 0 1.16,1.17,1.18,1.19 1.8.3 tetratefips 1 1.16,1.17,1.18,1.19 1.8.3 istio 0 1.16,1.17,1.18,1.19 - 1.8.2 tetrate 0 1.16,1.17,1.18 - 1.8.1 tetrate 0 1.16,1.17,1.18 - 1.8.0 tetrate 0 1.16,1.17,1.18 1.7.8 tetrate 0 1.16,1.17,1.18 - 1.7.8 istio 0 1.16,1.17,1.18 - 1.7.7 tetrate 0 1.16,1.17,1.18 - 1.7.6 tetrate 0 1.16,1.17,1.18 - 1.7.5 tetrate 0 1.16,1.17,1.18 - 1.7.4 tetrate 0 1.16,1.17,1.18` - assert.Contains(t, buf.String(), exp) - fmt.Println(buf.String()) + 1.7.8 istio 0 1.16,1.17,1.18` + require.Contains(t, buf.String(), exp) } func fetch(t *testing.T) { defer func() { cmd := exec.Command("./getmesh", "switch", - "--version", "1.9.1", "--flavor", "tetrate", "--flavor-version=0", + "--version", "1.9.5", "--flavor", "tetrate", "--flavor-version=0", ) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr require.NoError(t, cmd.Run()) }() - cmd := exec.Command("./getmesh", "fetch", "--version=1.8.1", "--flavor=tetrate", "--flavor-version=0") + cmd := exec.Command("./getmesh", "fetch", "--version=1.8.6", "--flavor=tetrate", "--flavor-version=0") buf := new(bytes.Buffer) cmd.Stdout = buf cmd.Stderr = os.Stderr require.NoError(t, cmd.Run(), buf.String()) - assert.Contains(t, buf.String(), `For more information about 1.8.1-tetrate-v0, please refer to the release notes: -- https://istio.io/latest/news/releases/1.8.x/announcing-1.8.1/ + require.Contains(t, buf.String(), `For more information about 1.8.6-tetrate-v0, please refer to the release notes: +- https://istio.io/latest/news/releases/1.8.x/announcing-1.8.6/ -istioctl switched to 1.8.1-tetrate-v0 now +istioctl switched to 1.8.6-tetrate-v0 now `) // not listed version should be error @@ -263,7 +241,7 @@ istioctl switched to 1.8.1-tetrate-v0 now cmd.Stdout = buf cmd.Stderr = os.Stderr require.NoError(t, cmd.Run()) - assert.Contains(t, buf.String(), `-istio-v0 now`) + require.Contains(t, buf.String(), `-istio-v0 now`) // fetch with single flavor flag cmd = exec.Command("./getmesh", "fetch", "--flavor=istio") @@ -271,10 +249,10 @@ istioctl switched to 1.8.1-tetrate-v0 now cmd.Stdout = buf cmd.Stderr = os.Stderr require.NoError(t, cmd.Run()) - assert.Contains(t, buf.String(), `-istio-v0 now`) + require.Contains(t, buf.String(), `-istio-v0 now`) // fetch another version - cmd = exec.Command("./getmesh", "fetch", "--version=1.7.5") + cmd = exec.Command("./getmesh", "fetch", "--version=1.7.8") cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr require.NoError(t, cmd.Run()) @@ -285,8 +263,7 @@ istioctl switched to 1.8.1-tetrate-v0 now cmd.Stdout = buf cmd.Stderr = os.Stderr require.NoError(t, cmd.Run()) - assert.Contains(t, buf.String(), `1.7.5-tetrate-v0 (Active)`) - fmt.Println(buf.String()) + require.Contains(t, buf.String(), `1.7.8-tetrate-v0 (Active)`) } func prune(t *testing.T) { @@ -298,7 +275,7 @@ func prune(t *testing.T) { t.Run("specific", func(t *testing.T) { target := &api.IstioDistribution{ - Version: "1.7.5", + Version: "1.7.8", Flavor: "tetrate", FlavorVersion: 0, } @@ -329,17 +306,17 @@ func prune(t *testing.T) { t.Run("all", func(t *testing.T) { distros := []*api.IstioDistribution{ { - Version: "1.7.5", + Version: "1.7.8", Flavor: "tetrate", FlavorVersion: 0, }, { - Version: "1.8.1", + Version: "1.8.6", Flavor: "tetrate", FlavorVersion: 0, }, { - Version: "1.9.1", + Version: "1.9.5", Flavor: "tetrate", FlavorVersion: 0, }, @@ -383,16 +360,15 @@ func show(t *testing.T) { cmd.Stdout = buf cmd.Stderr = os.Stderr require.NoError(t, cmd.Run()) - exp := `1.7.5-tetrate-v0 -1.8.1-tetrate-v0 -1.9.1-tetrate-v0 (Active)` - assert.Contains(t, buf.String(), exp) - fmt.Println(buf.String()) + exp := `1.7.8-tetrate-v0 +1.8.6-tetrate-v0 +1.9.5-tetrate-v0 (Active)` + require.Contains(t, buf.String(), exp) } func switchTest(t *testing.T) { t.Run("full", func(t *testing.T) { - for _, v := range []string{"1.8.1", "1.9.1"} { + for _, v := range []string{"1.8.6", "1.9.5"} { { cmd := exec.Command("./getmesh", "switch", "--version", v, "--flavor", "tetrate", "--flavor-version=0", @@ -407,14 +383,13 @@ func switchTest(t *testing.T) { cmd.Stdout = buf cmd.Stderr = os.Stderr require.NoError(t, cmd.Run()) - assert.Contains(t, buf.String(), v) - fmt.Println(buf.String()) + require.Contains(t, buf.String(), v) } } }) t.Run("name", func(t *testing.T) { cmd := exec.Command("./getmesh", "switch", - "--version", "1.8.1", "--flavor", "tetrate", "--flavor-version=0", + "--version", "1.8.6", "--flavor", "tetrate", "--flavor-version=0", ) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr @@ -425,10 +400,10 @@ func switchTest(t *testing.T) { cmd.Stdout = buf cmd.Stderr = os.Stderr require.NoError(t, cmd.Run()) - assert.Contains(t, buf.String(), "1.8.1-tetrate-v0") + require.Contains(t, buf.String(), "1.8.6-tetrate-v0") cmd = exec.Command("./getmesh", "switch", - "--name", "1.9.1-tetrate-v0", + "--name", "1.9.5-tetrate-v0", ) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr @@ -439,12 +414,11 @@ func switchTest(t *testing.T) { cmd.Stdout = buf cmd.Stderr = os.Stderr require.NoError(t, cmd.Run()) - assert.Contains(t, buf.String(), "1.9.1-tetrate-v0") - fmt.Println(buf.String()) + require.Contains(t, buf.String(), "1.9.5-tetrate-v0") }) t.Run("active", func(t *testing.T) { cmd := exec.Command("./getmesh", "fetch", - "--version=1.9.1", "--flavor=istio", "--flavor-version=0", + "--version=1.9.5", "--flavor=istio", "--flavor-version=0", ) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr @@ -455,8 +429,8 @@ func switchTest(t *testing.T) { cmd.Stdout = buf cmd.Stderr = os.Stderr require.NoError(t, cmd.Run()) - assert.Contains(t, buf.String(), "1.9.1") - assert.NotContains(t, buf.String(), "1.9.1-tetrate-v0") + require.Contains(t, buf.String(), "1.9.5") + require.NotContains(t, buf.String(), "1.9.5-tetrate-v0") cmd = exec.Command("./getmesh", "switch", "--flavor=tetrate", @@ -470,8 +444,7 @@ func switchTest(t *testing.T) { cmd.Stdout = buf cmd.Stderr = os.Stderr require.NoError(t, cmd.Run()) - assert.Contains(t, buf.String(), "1.9.1-tetrate-v0") - fmt.Println(buf.String()) + require.Contains(t, buf.String(), "1.9.5-tetrate-v0") }) } @@ -485,10 +458,10 @@ func istioctlInstall(t *testing.T) { actual := buf.String() // istioctl x precheck - assert.Contains(t, actual, "Can initialize the Kubernetes client.") - assert.Contains(t, actual, "Can query the Kubernetes API Server.") - assert.Contains(t, actual, "Istio will be installed in the istio-system namespace.") - assert.Contains(t, actual, "Install Pre-Check passed! The cluster is ready for Istio installation.") + require.Contains(t, actual, "Can initialize the Kubernetes client.") + require.Contains(t, actual, "Can query the Kubernetes API Server.") + require.Contains(t, actual, "Istio will be installed in the istio-system namespace.") + require.Contains(t, actual, "Install Pre-Check passed! The cluster is ready for Istio installation.") } func unknown(t *testing.T) { @@ -518,9 +491,9 @@ func unknown(t *testing.T) { buf := new(bytes.Buffer) c.cmd.Stdout = buf c.cmd.Stderr = os.Stderr - assert.Error(t, c.cmd.Run()) + require.Error(t, c.cmd.Run()) actual := buf.String() - assert.Contains(t, actual, c.wants) + require.Contains(t, actual, c.wants) }) } } @@ -537,12 +510,11 @@ func version(t *testing.T) { cmd.Stderr = os.Stderr require.NoError(t, cmd.Run()) actual := buf.String() - assert.Contains(t, actual, "getmesh version: dev") - assert.Contains(t, actual, "active istioctl") + require.Contains(t, actual, "getmesh version: dev") + require.Contains(t, actual, "active istioctl") // latest version is available - assert.Contains(t, actual, "Please run 'getmesh update' to install") - assert.Contains(t, actual, "control plane version") - assert.Contains(t, actual, "data plane version") + require.Contains(t, actual, "control plane version") + require.Contains(t, actual, "data plane version") fmt.Println(actual) } @@ -554,13 +526,11 @@ func version(t *testing.T) { cmd.Stderr = os.Stderr require.NoError(t, cmd.Run()) actual := buf.String() - assert.Contains(t, actual, "getmesh version: dev") - assert.Contains(t, actual, "active istioctl") + require.Contains(t, actual, "getmesh version: dev") + require.Contains(t, actual, "active istioctl") // latest version is available - assert.Contains(t, actual, "Please run 'getmesh update' to install") - assert.NotContains(t, actual, "control plane version") - assert.NotContains(t, actual, "data plane version") - fmt.Println(actual) + require.NotContains(t, actual, "control plane version") + require.NotContains(t, actual, "data plane version") }) t.Run("unknown cluster", func(t *testing.T) { cmd := exec.Command("./getmesh", "version", "-c", "unknown.yaml") @@ -569,10 +539,9 @@ func version(t *testing.T) { cmd.Stderr = os.Stderr require.NoError(t, cmd.Run()) actual := buf.String() - assert.Contains(t, actual, "getmesh version: dev") - assert.Contains(t, actual, "active istioctl") - assert.Contains(t, actual, "no active Kubernetes clusters found") - fmt.Println(actual) + require.Contains(t, actual, "getmesh version: dev") + require.Contains(t, actual, "active istioctl") + require.Contains(t, actual, "no active Kubernetes clusters found") }) } @@ -583,8 +552,7 @@ func checkUpgrade(t *testing.T) { cmd.Stderr = os.Stderr require.NoError(t, cmd.Run(), buf.String()) actual := buf.String() - assert.Contains(t, actual, "1.9.1-tetrate-v0 is the latest version in 1.9-tetrate") - fmt.Println(actual) + require.Contains(t, actual, "1.9.5-tetrate-v0 is the latest version in 1.9-tetrate") // change image to 1.8.1-tetrate-v0 image := "containers.istio.tetratelabs.com/pilot:1.8.1-tetrate-v0" @@ -606,15 +574,15 @@ func checkUpgrade(t *testing.T) { _ = cmd.Run() actual := buf.String() - fmt.Println(actual) + // - There is the available patch for the minor version 1.8-tetrate which includes **security upgrades**. We strongly recommend upgrading all 1.8-tetrate versions -> 1.8.6-tetrate-v0 if strings.Contains(actual, - "There is the available patch for the minor version 1.8-tetrate. "+ - "We recommend upgrading all 1.8-tetrate versions -> 1.8.4-tetrate-v0") { + "There is the available patch for the minor version 1.8-tetrate which includes **security upgrades**. "+ + "We strongly recommend upgrading all 1.8-tetrate versions -> 1.8.6-tetrate-v0") { break } } - assert.NotEqual(t, 10, i) + require.NotEqual(t, 10, i) } func configValidate(t *testing.T) { diff --git a/e2e/gcp_config.yaml b/e2e/gcp_config.yaml deleted file mode 100644 index fd45077..0000000 --- a/e2e/gcp_config.yaml +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2021 Tetrate -# -# 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. - -providerName: "gcp" -providerConfig: - gcp: - casCAName: "projects/omni-163105/locations/asia-southeast1/certificateAuthorities/InfraCloud-and-TetrateLabs-Root-CA-Google" -certificateParameters: - secretOptions: - istioCANamespace: "istio-system" - caOptions: - validityDays: 100 - certSigningRequestParams: - subject: - commonname: "Istio CA" - country: - - "US" - locality: - - "Sunnyvale" - organization: - - "Istio" - diff --git a/e2e/gen_ca_aws_test.go b/e2e/gen_ca_aws_test.go index 632a5b7..5ee4ea0 100644 --- a/e2e/gen_ca_aws_test.go +++ b/e2e/gen_ca_aws_test.go @@ -40,7 +40,7 @@ func TestAWSProviderValidityDaysExceedC(t *testing.T) { cmd.Stdout = os.Stdout cmd.Run() actual := buf.String() - assert.Contains(t, actual, "unable to issue CA, due to error: unable to issue certificate: unable to issue certificate: ValidationException: The certificate validity specified exceeds the CA validity.") + require.Contains(t, actual, "unable to issue CA, due to error: unable to issue certificate: unable to issue certificate: ValidationException: The certificate validity specified exceeds the CA validity.") } // Positive test for whole workflow. @@ -60,5 +60,5 @@ func TestAWSProvider(t *testing.T) { cmd.Stderr = os.Stderr cmd.Run() actual := buf.String() - assert.Contains(t, actual, "apiVersion: v1\nkind: Secret\nmetadata:\n name: cacerts\n namespace: istio-system\ntype: Opaque\ndata:\n ca-cert.pem: -----BEGIN CERTIFICATE-----\n") + require.Contains(t, actual, "apiVersion: v1\nkind: Secret\nmetadata:\n name: cacerts\n namespace: istio-system\ntype: Opaque\ndata:\n ca-cert.pem: -----BEGIN CERTIFICATE-----\n") } diff --git a/e2e/gen_ca_gcp_test.go b/e2e/gen_ca_gcp_test.go index 9bd4f93..9a47c47 100644 --- a/e2e/gen_ca_gcp_test.go +++ b/e2e/gen_ca_gcp_test.go @@ -43,8 +43,8 @@ func TestGCPProvider(t *testing.T) { cmd.Run() actual := buf.String() - assert.Contains(t, actual, "Kubernetes Secret YAML created successfully in /tmp/gcp-secret.yaml") + require.Contains(t, actual, "Kubernetes Secret YAML created successfully in /tmp/gcp-secret.yaml") _, err := ioutil.ReadFile("/tmp/gcp-secret.yaml") - assert.NoError(t, err) + require.NoError(t, err) } diff --git a/e2e/gen_ca_test.go b/e2e/gen_ca_test.go index 54db988..57024dc 100644 --- a/e2e/gen_ca_test.go +++ b/e2e/gen_ca_test.go @@ -20,7 +20,7 @@ import ( "os/exec" "testing" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestCheckGenCAConfigFileNotExist(t *testing.T) { @@ -30,7 +30,7 @@ func TestCheckGenCAConfigFileNotExist(t *testing.T) { cmd.Stdout = os.Stdout _ = cmd.Run() actual := buf.String() - assert.Contains(t, actual, `unable to open config file path: open /tmp/filenotexist.yaml: no such file or directory`) + require.Contains(t, actual, `unable to open config file path: open /tmp/filenotexist.yaml: no such file or directory`) } func TestCheckGenCAConfigProviderUnavailable(t *testing.T) { @@ -40,7 +40,7 @@ func TestCheckGenCAConfigProviderUnavailable(t *testing.T) { cmd.Stdout = os.Stdout _ = cmd.Run() actual := buf.String() - assert.Contains(t, actual, "`unavailable` provider yet to be implement") + require.Contains(t, actual, "`unavailable` provider yet to be implement") } func TestCheckGenCAConfigSigningCANotProvided1(t *testing.T) { @@ -50,7 +50,7 @@ func TestCheckGenCAConfigSigningCANotProvided1(t *testing.T) { cmd.Stdout = os.Stdout _ = cmd.Run() actual := buf.String() - assert.Contains(t, actual, "found empty AWS Signing CA ARN") + require.Contains(t, actual, "found empty AWS Signing CA ARN") } func TestCheckGenCAConfigSigningCANotProvided2(t *testing.T) { @@ -60,7 +60,7 @@ func TestCheckGenCAConfigSigningCANotProvided2(t *testing.T) { cmd.Stdout = os.Stdout _ = cmd.Run() actual := buf.String() - assert.Contains(t, actual, "found empty AWS Signing CA ARN") + require.Contains(t, actual, "found empty AWS Signing CA ARN") } func TestCheckGenCAConfigWrongRegionProvided(t *testing.T) { @@ -70,7 +70,7 @@ func TestCheckGenCAConfigWrongRegionProvided(t *testing.T) { cmd.Stdout = os.Stdout _ = cmd.Run() actual := buf.String() - assert.Contains(t, actual, "unable to issue CA, due to error: unable to initialize AWS Client: unable to get AWS Region: unable to find region for AWS Signing CA ARN") + require.Contains(t, actual, "unable to issue CA, due to error: unable to initialize AWS Client: unable to get AWS Region: unable to find region for AWS Signing CA ARN") } func TestCheckGenCAConfigWrongInfoProvided(t *testing.T) { @@ -80,7 +80,7 @@ func TestCheckGenCAConfigWrongInfoProvided(t *testing.T) { cmd.Stdout = os.Stdout _ = cmd.Run() actual := buf.String() - assert.Contains(t, actual, "unable to issue CA, due to error: unable to get CACertificateRequest: NoCredentialProviders") + require.Contains(t, actual, "unable to issue CA, due to error: unable to get CACertificateRequest: NoCredentialProviders") } func TestCheckGenCAConfigWrongFlagsProvided(t *testing.T) { @@ -90,5 +90,5 @@ func TestCheckGenCAConfigWrongFlagsProvided(t *testing.T) { cmd.Stdout = os.Stdout _ = cmd.Run() actual := buf.String() - assert.Contains(t, actual, "unknown flag: --testing\n") + require.Contains(t, actual, "unknown flag: --testing\n") } diff --git a/site/manifest.json b/site/manifest.json index 0ddedd9..c52ad86 100644 --- a/site/manifest.json +++ b/site/manifest.json @@ -7,7 +7,7 @@ }, "istio_distributions": [ { - "version": "1.9.1", + "version": "1.9.5", "flavor": "tetrate", "flavor_version": 0, "k8s_versions": [ @@ -17,12 +17,12 @@ "1.20" ], "release_notes": [ - "https://istio.io/latest/news/releases/1.9.x/announcing-1.9.1/" + "https://istio.io/latest/news/releases/1.9.x/announcing-1.9.5/" ], "is_security_patch": true }, { - "version": "1.9.1", + "version": "1.9.5", "flavor": "istio", "flavor_version": 0, "k8s_versions": [ @@ -32,12 +32,12 @@ "1.20" ], "release_notes": [ - "https://istio.io/latest/news/releases/1.9.x/announcing-1.9.1/" + "https://istio.io/latest/news/releases/1.9.x/announcing-1.9.5/" ], "is_security_patch": true }, { - "version": "1.9.0", + "version": "1.9.4", "flavor": "tetrate", "flavor_version": 0, "k8s_versions": [ @@ -47,14 +47,14 @@ "1.20" ], "release_notes": [ - "https://istio.io/latest/news/releases/1.9.x/announcing-1.9/" + "https://istio.io/latest/news/releases/1.9.x/announcing-1.9.4/" ], "is_security_patch": false }, { - "version": "1.9.0", - "flavor": "tetratefips", - "flavor_version": 1, + "version": "1.9.4", + "flavor": "istio", + "flavor_version": 0, "k8s_versions": [ "1.17", "1.18", @@ -62,13 +62,13 @@ "1.20" ], "release_notes": [ - "https://istio.io/latest/news/releases/1.9.x/announcing-1.9/" + "https://istio.io/latest/news/releases/1.9.x/announcing-1.9.4/" ], "is_security_patch": false }, { "version": "1.9.0", - "flavor": "istio", + "flavor": "tetrate", "flavor_version": 0, "k8s_versions": [ "1.17", @@ -82,37 +82,37 @@ "is_security_patch": false }, { - "version": "1.8.4", - "flavor": "tetrate", - "flavor_version": 0, + "version": "1.9.0", + "flavor": "tetratefips", + "flavor_version": 1, "k8s_versions": [ - "1.16", "1.17", "1.18", - "1.19" + "1.19", + "1.20" ], "release_notes": [ - "https://istio.io/latest/news/releases/1.8.x/announcing-1.8.4/" + "https://istio.io/latest/news/releases/1.9.x/announcing-1.9/" ], "is_security_patch": false }, { - "version": "1.8.4", + "version": "1.9.0", "flavor": "istio", "flavor_version": 0, "k8s_versions": [ - "1.16", "1.17", "1.18", - "1.19" + "1.19", + "1.20" ], "release_notes": [ - "https://istio.io/latest/news/releases/1.8.x/announcing-1.8.4/" + "https://istio.io/latest/news/releases/1.9.x/announcing-1.9/" ], "is_security_patch": false }, { - "version": "1.8.3", + "version": "1.8.6", "flavor": "tetrate", "flavor_version": 0, "k8s_versions": [ @@ -122,27 +122,12 @@ "1.19" ], "release_notes": [ - "https://istio.io/latest/news/releases/1.8.x/announcing-1.8.3/" - ], - "is_security_patch": false - }, - { - "version": "1.8.3", - "flavor": "tetratefips", - "flavor_version": 1, - "k8s_versions": [ - "1.16", - "1.17", - "1.18", - "1.19" - ], - "release_notes": [ - "https://istio.io/latest/news/releases/1.8.x/announcing-1.8.3/" + "https://istio.io/latest/news/releases/1.8.x/announcing-1.8.6/" ], - "is_security_patch": false + "is_security_patch": true }, - { - "version": "1.8.3", + { + "version": "1.8.6", "flavor": "istio", "flavor_version": 0, "k8s_versions": [ @@ -152,110 +137,87 @@ "1.19" ], "release_notes": [ - "https://istio.io/latest/news/releases/1.8.x/announcing-1.8.3/" + "https://istio.io/latest/news/releases/1.8.x/announcing-1.8.6/" ], - "is_security_patch": false + "is_security_patch": true }, - { - "version": "1.8.2", + { + "version": "1.8.5", "flavor": "tetrate", "flavor_version": 0, "k8s_versions": [ "1.16", "1.17", - "1.18" + "1.18", + "1.19" ], "release_notes": [ - "https://istio.io/latest/news/releases/1.8.x/announcing-1.8.2/" + "https://istio.io/latest/news/releases/1.8.x/announcing-1.8.5/" ], - "is_security_patch": false + "is_security_patch": true }, { - "version": "1.8.1", - "flavor": "tetrate", + "version": "1.8.5", + "flavor": "istio", "flavor_version": 0, "k8s_versions": [ "1.16", "1.17", - "1.18" + "1.18", + "1.19" ], "release_notes": [ - "https://istio.io/latest/news/releases/1.8.x/announcing-1.8.1/" + "https://istio.io/latest/news/releases/1.8.x/announcing-1.8.5/" ], - "is_security_patch": false + "is_security_patch": true }, { - "version": "1.8.0", + "version": "1.8.3", "flavor": "tetrate", "flavor_version": 0, "k8s_versions": [ "1.16", "1.17", - "1.18" + "1.18", + "1.19" ], "release_notes": [ - "https://istio.io/latest/news/releases/1.8.x/announcing-1.8/" + "https://istio.io/latest/news/releases/1.8.x/announcing-1.8.3/" ], "is_security_patch": false }, { - "version": "1.7.8", - "flavor": "tetrate", - "flavor_version": 0, + "version": "1.8.3", + "flavor": "tetratefips", + "flavor_version": 1, "k8s_versions": [ "1.16", "1.17", - "1.18" + "1.18", + "1.19" ], "release_notes": [ - "https://istio.io/latest/news/releases/1.7.x/announcing-1.7.8/" + "https://istio.io/latest/news/releases/1.8.x/announcing-1.8.3/" ], "is_security_patch": false }, { - "version": "1.7.8", + "version": "1.8.3", "flavor": "istio", "flavor_version": 0, "k8s_versions": [ "1.16", "1.17", - "1.18" - ], - "release_notes": [ - "https://istio.io/latest/news/releases/1.7.x/announcing-1.7.8/" - ], - "is_security_patch": false - }, - { - "version": "1.7.7", - "flavor": "tetrate", - "flavor_version": 0, - "k8s_versions": [ - "1.16", - "1.17", - "1.18" - ], - "release_notes": [ - "https://istio.io/latest/news/releases/1.7.x/announcing-1.7.7/" - ], - "is_security_patch": false - }, - { - "version": "1.7.6", - "flavor": "tetrate", - "flavor_version": 0, - "k8s_versions": [ - "1.16", - "1.17", - "1.18" + "1.18", + "1.19" ], "release_notes": [ - "https://istio.io/latest/news/releases/1.7.x/announcing-1.7.6/" + "https://istio.io/latest/news/releases/1.8.x/announcing-1.8.3/" ], "is_security_patch": false }, { - "version": "1.7.5", + "version": "1.7.8", "flavor": "tetrate", "flavor_version": 0, "k8s_versions": [ @@ -264,13 +226,13 @@ "1.18" ], "release_notes": [ - "https://istio.io/latest/news/releases/1.7.x/announcing-1.7.5/" + "https://istio.io/latest/news/releases/1.7.x/announcing-1.7.8/" ], "is_security_patch": false }, { - "version": "1.7.4", - "flavor": "tetrate", + "version": "1.7.8", + "flavor": "istio", "flavor_version": 0, "k8s_versions": [ "1.16", @@ -278,7 +240,7 @@ "1.18" ], "release_notes": [ - "https://istio.io/latest/news/releases/1.7.x/announcing-1.7.4/" + "https://istio.io/latest/news/releases/1.7.x/announcing-1.7.8/" ], "is_security_patch": false } diff --git a/src/cacerts/certutils/certificate_test.go b/src/cacerts/certutils/certificate_test.go index 38cea7c..3c2b1b7 100644 --- a/src/cacerts/certutils/certificate_test.go +++ b/src/cacerts/certutils/certificate_test.go @@ -20,12 +20,11 @@ import ( "testing" "github.com/stretchr/testify/require" - "gotest.tools/assert" ) func TestCreateCertificateSigningRequest(t *testing.T) { csrBytesEncoded, subordinateCaKey, err := CreateCSR(x509.CertificateRequest{}, 2048) require.NoError(t, err) - assert.Equal(t, strings.HasPrefix(string(csrBytesEncoded), "-----BEGIN CERTIFICATE REQUEST-----"), true) - assert.Equal(t, strings.HasPrefix(subordinateCaKey, "-----BEGIN PRIVATE KEY-----"), true) + require.Equal(t, strings.HasPrefix(string(csrBytesEncoded), "-----BEGIN CERTIFICATE REQUEST-----"), true) + require.Equal(t, strings.HasPrefix(subordinateCaKey, "-----BEGIN PRIVATE KEY-----"), true) } diff --git a/src/cacerts/providers/aws_test.go b/src/cacerts/providers/aws_test.go index 1fe50d4..25600af 100644 --- a/src/cacerts/providers/aws_test.go +++ b/src/cacerts/providers/aws_test.go @@ -25,7 +25,6 @@ import ( "github.com/aws/aws-sdk-go/service/acmpca/acmpcaiface" "github.com/stretchr/testify/require" "github.com/tetratelabs/getmesh/src/cacerts/providers/models" - "gotest.tools/assert" ) const ( @@ -132,7 +131,7 @@ func TestIssueCertificateAuthorityNegative(t *testing.T) { IstioNamespace: "Mock", }, }) - assert.Equal(t, err.Error(), "unable to get CACertificateRequest: mockValidationErrorForGetCertificate") + require.Equal(t, err.Error(), "unable to get CACertificateRequest: mockValidationErrorForGetCertificate") } func TestGetCertificate(t *testing.T) { @@ -158,7 +157,7 @@ func TestGetCertificateNegative(t *testing.T) { _, err := provider.getCert(context.TODO(), models.GetCertOptions{ CertNameIdentifier: "", }) - assert.Equal(t, err.Error(), "unable to get certificate: "+errMockGetCertificate) + require.Equal(t, err.Error(), "unable to get certificate: "+errMockGetCertificate) } func TestIssueCertificate(t *testing.T) { @@ -205,5 +204,5 @@ func TestGetIssueCertificateNegative(t *testing.T) { ValidityType: "DAYS", ValidityValue: 30, }) - assert.Equal(t, err.Error(), "unable to issue certificate: "+errMockIssueCertificate) + require.Equal(t, err.Error(), "unable to issue certificate: "+errMockIssueCertificate) } diff --git a/src/cacerts/providers/config/config_test.go b/src/cacerts/providers/config/config_test.go index c5ce498..e561a4d 100644 --- a/src/cacerts/providers/config/config_test.go +++ b/src/cacerts/providers/config/config_test.go @@ -20,7 +20,6 @@ import ( "testing" "github.com/stretchr/testify/require" - "gotest.tools/assert" ) func TestNewConfigDefault(t *testing.T) { @@ -48,20 +47,20 @@ certificateParameters: require.NoError(t, err) // check modified values - assert.Equal(t, "DUMMYARN", getConfig.ProviderConfig.AWSConfig.SigningCA) - assert.Equal(t, "DUMMY-TEMPLATE_ARN", getConfig.ProviderConfig.AWSConfig.TemplateARN) - assert.Equal(t, "SHA256WITHRSA", getConfig.ProviderConfig.AWSConfig.SigningAlgorithm) - assert.Equal(t, "dummy-istio-ns", getConfig.CertParameters.SecretOptions.IstioNamespace) + require.Equal(t, "DUMMYARN", getConfig.ProviderConfig.AWSConfig.SigningCA) + require.Equal(t, "DUMMY-TEMPLATE_ARN", getConfig.ProviderConfig.AWSConfig.TemplateARN) + require.Equal(t, "SHA256WITHRSA", getConfig.ProviderConfig.AWSConfig.SigningAlgorithm) + require.Equal(t, "dummy-istio-ns", getConfig.CertParameters.SecretOptions.IstioNamespace) // check default values - assert.Equal(t, int64(3650), getConfig.CertParameters.ValidityDays) - assert.Equal(t, 2048, getConfig.CertParameters.KeyLength) - assert.Equal(t, "Istio CA", getConfig.CertParameters.CertRequest.Subject.CommonName) - assert.Equal(t, "California", getConfig.CertParameters.CertRequest.Subject.Province[0]) - assert.Equal(t, "Sunnyvale", getConfig.CertParameters.CertRequest.Subject.Locality[0]) - assert.Equal(t, "Istio", getConfig.CertParameters.CertRequest.Subject.Organization[0]) - assert.Equal(t, "US", getConfig.CertParameters.CertRequest.Subject.Country[0]) - assert.Equal(t, "ca.istio.io", getConfig.CertParameters.CertRequest.DNSNames[0]) + require.Equal(t, int64(3650), getConfig.CertParameters.ValidityDays) + require.Equal(t, 2048, getConfig.CertParameters.KeyLength) + require.Equal(t, "Istio CA", getConfig.CertParameters.CertRequest.Subject.CommonName) + require.Equal(t, "California", getConfig.CertParameters.CertRequest.Subject.Province[0]) + require.Equal(t, "Sunnyvale", getConfig.CertParameters.CertRequest.Subject.Locality[0]) + require.Equal(t, "Istio", getConfig.CertParameters.CertRequest.Subject.Organization[0]) + require.Equal(t, "US", getConfig.CertParameters.CertRequest.Subject.Country[0]) + require.Equal(t, "ca.istio.io", getConfig.CertParameters.CertRequest.DNSNames[0]) } diff --git a/src/checkupgrade/check_upgrade_test.go b/src/checkupgrade/check_upgrade_test.go index 419ac2d..793687b 100644 --- a/src/checkupgrade/check_upgrade_test.go +++ b/src/checkupgrade/check_upgrade_test.go @@ -18,7 +18,6 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" istioversion "istio.io/pkg/version" @@ -68,7 +67,7 @@ func Test_printSummary(t *testing.T) { }) actual := buf.String() - assert.Equal(t, fmt.Sprintf("active istioctl version: %s\n\n", in.ClientVersion.Version), actual) + require.Equal(t, fmt.Sprintf("active istioctl version: %s\n\n", in.ClientVersion.Version), actual) }) t.Run("full", func(t *testing.T) { @@ -92,7 +91,7 @@ func Test_printSummary(t *testing.T) { }) actual := buf.String() - assert.Equal(t, `active istioctl version: 1.7.4-tetrate-v0 + require.Equal(t, `active istioctl version: 1.7.4-tetrate-v0 data plane version: 1.7.4-tetrate-v0 (2 proxies) control plane version: 1.7.4-tetrate-v0 @@ -123,7 +122,7 @@ control plane version: 1.7.4-tetrate-v0 }) actual := buf.String() - assert.Equal(t, `active istioctl version: 1.7.4-tetrate-v0 + require.Equal(t, `active istioctl version: 1.7.4-tetrate-v0 data plane version: 1.7.4-tetrate-v0 (2 proxies), 1.8.4-tetrate-v0 (1 proxies) control plane version: 1.7.4-tetrate-v0, 1.8.1-tetrate-v0 @@ -159,7 +158,7 @@ func Test_printgetmeshCheck(t *testing.T) { } { err := printgetmeshCheck(c, &api.Manifest{ IstioDistributions: []*api.IstioDistribution{{Version: "1.4.aaaa"}}}) - assert.Error(t, err) + require.Error(t, err) t.Log(err) } }) @@ -196,8 +195,8 @@ func Test_printgetmeshCheck(t *testing.T) { }) actual := buf.String() - assert.Contains(t, actual, "Please install distributions with tetrate flavor listed in `getmesh list` command") - assert.Contains(t, actual, "nothing to check") + require.Contains(t, actual, "Please install distributions with tetrate flavor listed in `getmesh list` command") + require.Contains(t, actual, "nothing to check") t.Log(actual) }) } @@ -254,7 +253,7 @@ func Test_printgetmeshCheck(t *testing.T) { }) actual := buf.String() - assert.Contains(t, actual, "running in multiple minor versions") + require.Contains(t, actual, "running in multiple minor versions") t.Log(actual) }) } @@ -350,7 +349,7 @@ func Test_printgetmeshCheck(t *testing.T) { actual := buf.String() for _, e := range c.exp { - assert.Contains(t, actual, e) + require.Contains(t, actual, e) } t.Log(actual) }) @@ -381,8 +380,8 @@ func Test_getLatestPatchInManifestMsg(t *testing.T) { }, &api.Manifest{IstioDistributions: ms}) require.NoError(t, err) require.False(t, ok) - assert.Contains(t, msg, "The minor version 1.0-tetrate is no longer supported by getmesh.") - assert.Contains(t, msg, "getmesh list") + require.Contains(t, msg, "The minor version 1.0-tetrate is no longer supported by getmesh.") + require.Contains(t, msg, "getmesh list") t.Log(msg) msg, ok, err = getLatestPatchInManifestMsg(&api.IstioDistribution{ @@ -390,8 +389,8 @@ func Test_getLatestPatchInManifestMsg(t *testing.T) { }, &api.Manifest{IstioDistributions: ms}) require.NoError(t, err) require.False(t, ok) - assert.Contains(t, msg, "The minor version 1.10-tetratefips is no longer supported by getmesh.") - assert.Contains(t, msg, "getmesh list") + require.Contains(t, msg, "The minor version 1.10-tetratefips is no longer supported by getmesh.") + require.Contains(t, msg, "getmesh list") t.Log(msg) }) @@ -408,7 +407,7 @@ func Test_getLatestPatchInManifestMsg(t *testing.T) { }, &api.Manifest{IstioDistributions: ms}) require.NoError(t, err) require.True(t, ok) - assert.Contains(t, msg, "- 1.8.10-tetrate-v10 is the latest version in 1.8-tetrate") + require.Contains(t, msg, "- 1.8.10-tetrate-v10 is the latest version in 1.8-tetrate") t.Log(msg) msg, ok, err = getLatestPatchInManifestMsg(&api.IstioDistribution{ @@ -417,7 +416,7 @@ func Test_getLatestPatchInManifestMsg(t *testing.T) { }, &api.Manifest{IstioDistributions: ms}) require.NoError(t, err) require.True(t, ok) - assert.Contains(t, msg, "- 1.7.20-tetratefips-v1 is the latest version in 1.7-tetratefips") + require.Contains(t, msg, "- 1.7.20-tetratefips-v1 is the latest version in 1.7-tetratefips") t.Log(msg) }) @@ -440,7 +439,7 @@ func Test_getLatestPatchInManifestMsg(t *testing.T) { actual, ok, err := getLatestPatchInManifestMsg(v, &api.Manifest{IstioDistributions: ms}) require.NoError(t, err) require.False(t, ok) - assert.Contains(t, actual, "all 1.8-tetrate versions -> 1.8.10-tetrate-v10") + require.Contains(t, actual, "all 1.8-tetrate versions -> 1.8.10-tetrate-v10") t.Log(actual) }) @@ -454,7 +453,7 @@ func Test_getLatestPatchInManifestMsg(t *testing.T) { actual, ok, err := getLatestPatchInManifestMsg(v, &api.Manifest{IstioDistributions: ms}) require.NoError(t, err) require.False(t, ok) - assert.Contains(t, actual, "which includes **security upgrades**. We strongly recommend upgrading all 1.7-tetratefips versions -> 1.7.20-tetratefips-v30") + require.Contains(t, actual, "which includes **security upgrades**. We strongly recommend upgrading all 1.7-tetratefips versions -> 1.7.20-tetratefips-v30") t.Log(actual) }) } @@ -476,7 +475,7 @@ func Test_getMultipleMinorVersionRunningMsg(t *testing.T) { exp: "- Your data plane running in multiple minor versions: 1.6-tetrate, 1.7-tetrate, 1.9-tetratefips, 2.1-tetratefips\n", }, } { - assert.Equal(t, c.exp, getMultipleMinorVersionRunningMsg(c.t, c.mvs)) + require.Equal(t, c.exp, getMultipleMinorVersionRunningMsg(c.t, c.mvs)) } } @@ -484,7 +483,7 @@ func Test_getControlPlaneVersions(t *testing.T) { t.Run("nil", func(t *testing.T) { actual, err := getControlPlaneVersions(nil) require.NoError(t, err) - assert.Empty(t, actual) + require.Empty(t, actual) }) t.Run("error", func(t *testing.T) { @@ -505,7 +504,7 @@ func Test_getControlPlaneVersions(t *testing.T) { require.NoError(t, err) }) - assert.Contains(t, buf.String(), "Please install distributions with tetrate flavor listed in") + require.Contains(t, buf.String(), "Please install distributions with tetrate flavor listed in") t.Log(buf.String()) }) @@ -558,7 +557,7 @@ func Test_getControlPlaneVersions(t *testing.T) { t.Run(fmt.Sprintf("%d-th", i), func(t *testing.T) { actual, err := getControlPlaneVersions(&c.in) require.NoError(t, err) - assert.Equal(t, c.exp, actual) + require.Equal(t, c.exp, actual) }) } }) @@ -568,7 +567,7 @@ func Test_getDataPlaneVersions(t *testing.T) { t.Run("nil", func(t *testing.T) { actual, err := getDataPlaneVersions(nil) require.NoError(t, err) - assert.Empty(t, actual) + require.Empty(t, actual) }) t.Run("error", func(t *testing.T) { @@ -584,7 +583,7 @@ func Test_getDataPlaneVersions(t *testing.T) { require.NoError(t, err) }) - assert.Contains(t, buf.String(), "Please install distributions with tetrate flavor listed in") + require.Contains(t, buf.String(), "Please install distributions with tetrate flavor listed in") t.Log(buf.String()) }) @@ -654,7 +653,7 @@ func Test_getDataPlaneVersions(t *testing.T) { t.Run(fmt.Sprintf("%d-th", i), func(t *testing.T) { actual, err := getDataPlaneVersions(&c.in) require.NoError(t, err) - assert.Equal(t, c.exp, actual) + require.Equal(t, c.exp, actual) }) } }) diff --git a/src/configvalidator/files_test.go b/src/configvalidator/files_test.go index a5e6ce8..a63b49a 100644 --- a/src/configvalidator/files_test.go +++ b/src/configvalidator/files_test.go @@ -18,7 +18,6 @@ import ( "io/ioutil" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -48,9 +47,9 @@ func TestExtractYamlFilePaths(t *testing.T) { require.NoError(t, err) for _, e := range exp { - assert.Contains(t, actual, e) + require.Contains(t, actual, e) } - assert.NotContains(t, actual, excluded) + require.NotContains(t, actual, excluded) t.Logf("in: %v, out: %v", in, actual) } diff --git a/src/configvalidator/kiali_client_wrapper_test.go b/src/configvalidator/kiali_client_wrapper_test.go index 9063465..d900f01 100644 --- a/src/configvalidator/kiali_client_wrapper_test.go +++ b/src/configvalidator/kiali_client_wrapper_test.go @@ -18,8 +18,6 @@ import ( "io/ioutil" "testing" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) @@ -117,7 +115,7 @@ spec: break } } - assert.True(t, found) - assert.Contains(t, c.localIstioObjectFilesRef, kialiObjectKey("default", exp, "VirtualService")) + require.True(t, found) + require.Contains(t, c.localIstioObjectFilesRef, kialiObjectKey("default", exp, "VirtualService")) } } diff --git a/src/configvalidator/print_test.go b/src/configvalidator/print_test.go index 8ab7a3e..3724447 100644 --- a/src/configvalidator/print_test.go +++ b/src/configvalidator/print_test.go @@ -17,8 +17,7 @@ package configvalidator import ( "testing" - "github.com/stretchr/testify/assert" - + "github.com/stretchr/testify/require" "github.com/tetratelabs/getmesh/src/util/logger" ) @@ -38,11 +37,11 @@ func TestPrintConfigValidationResultsWithoutNamespace(t *testing.T) { exps := append(tableColumns[1:], res.name, res.errorCode, res.resourceType, res.message, res.severity.Name) for _, c := range exps { - assert.Contains(t, actual, c) + require.Contains(t, actual, c) } - assert.NotContains(t, actual, res.namespace) - assert.NotContains(t, actual, "NAMESPACE") + require.NotContains(t, actual, res.namespace) + require.NotContains(t, actual, "NAMESPACE") t.Log(actual) } @@ -63,7 +62,7 @@ func TestPrintConfigValidationResults(t *testing.T) { actual := buf.String() exps := append(tableColumns, res.namespace, res.name, res.errorCode, res.resourceType, res.message, res.severity.Name) for _, c := range exps { - assert.Contains(t, actual, c) + require.Contains(t, actual, c) } t.Log(actual) diff --git a/src/configvalidator/validation_istio_test.go b/src/configvalidator/validation_istio_test.go index d95e2cb..da6086d 100644 --- a/src/configvalidator/validation_istio_test.go +++ b/src/configvalidator/validation_istio_test.go @@ -18,7 +18,7 @@ import ( "bytes" "testing" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestParseIstioctlAnalyzeResult(t *testing.T) { @@ -63,7 +63,7 @@ func TestParseIstioctlAnalyzeResult(t *testing.T) { }, }, } { - assert.Equal(t, []configValidationResult{c.exp}, + require.Equal(t, []configValidationResult{c.exp}, parseIstioctlAnalyzeResult(bytes.NewBufferString(c.in)), c.in) } } diff --git a/src/configvalidator/validator_test.go b/src/configvalidator/validator_test.go index 0a14d55..3bf5dbe 100644 --- a/src/configvalidator/validator_test.go +++ b/src/configvalidator/validator_test.go @@ -17,7 +17,7 @@ package configvalidator import ( "testing" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestConfigValidator_filterResults(t *testing.T) { @@ -28,7 +28,7 @@ func TestConfigValidator_filterResults(t *testing.T) { } cv := &ConfigValidator{} - assert.Equal(t, in, cv.filterResults(in)) + require.Equal(t, in, cv.filterResults(in)) }) t.Run("single", func(t *testing.T) { @@ -37,7 +37,7 @@ func TestConfigValidator_filterResults(t *testing.T) { } cv := &ConfigValidator{namespace: "kube-system"} - assert.Equal(t, in[1:], cv.filterResults(in)) + require.Equal(t, in[1:], cv.filterResults(in)) }) }) @@ -49,7 +49,7 @@ func TestConfigValidator_filterResults(t *testing.T) { {namespace: "kube-system", severity: SeverityLevelError}, } cv := &ConfigValidator{namespace: "default"} - assert.Equal(t, in[:1], cv.filterResults(in)) + require.Equal(t, in[:1], cv.filterResults(in)) }) t.Run("allnamespaces", func(t *testing.T) { in := []configValidationResult{ @@ -58,12 +58,12 @@ func TestConfigValidator_filterResults(t *testing.T) { {namespace: "default", severity: SeverityLevelInfo}, } cv := &ConfigValidator{} - assert.Equal(t, in[:2], cv.filterResults(in)) + require.Equal(t, in[:2], cv.filterResults(in)) }) }) } func TestConfigValidator_allNamespaces(t *testing.T) { - assert.True(t, (&ConfigValidator{namespace: ""}).allNamespaces()) - assert.False(t, (&ConfigValidator{namespace: "default"}).allNamespaces()) + require.True(t, (&ConfigValidator{namespace: ""}).allNamespaces()) + require.False(t, (&ConfigValidator{namespace: "default"}).allNamespaces()) } diff --git a/src/getmesh/getmesh.go b/src/getmesh/getmesh.go deleted file mode 100644 index 6428167..0000000 --- a/src/getmesh/getmesh.go +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2021 Tetrate -// -// 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 getmesh - -import ( - "bufio" - "bytes" - "fmt" - "io/ioutil" - "net/http" - "os" - "os/exec" - "strings" - - "github.com/tetratelabs/getmesh/src/util/logger" -) - -const ( - downloadShellURL = "https://dl.getistio.io/public/raw/files/download.sh" - downloadShellTestURLEnvKey = "GETMESH_TEST_DOWNLOAD_SHELL_URL" -) - -func getDownloadShellURL() string { - if url := os.Getenv(downloadShellTestURLEnvKey); len(url) != 0 { - return url - } - return downloadShellURL -} - -var latestVersionPrefixes = []string{ - "GETMESH_LATEST_VERSION=\"", - // TODO: delete after the next release. - "GETISTIO_LATEST_VERSION=\"", -} - -func LatestVersion() (string, error) { - url := getDownloadShellURL() - res, err := http.Get(url) - if err != nil { - return "", fmt.Errorf("error fetching donwload.sh: %v", err) - } - - defer res.Body.Close() - raw, err := ioutil.ReadAll(res.Body) - if err != nil { - return "", fmt.Errorf("error reading fetched donwload.sh: %v ", err) - } - - var ret string - r := bufio.NewScanner(bytes.NewReader(raw)) - for r.Scan() && ret == "" { - for _, prefix := range latestVersionPrefixes { - if line := r.Text(); strings.Contains(line, prefix) { - ret = strings.TrimPrefix(line, prefix) - ret = strings.TrimSuffix(ret, "\"") - break - } - } - } - - if len(ret) == 0 { - return "", fmt.Errorf("latest version not found in donwload script. This is a bug in GetMesh") - } - return ret, nil -} - -func Update(currentVersion string) error { - l, err := LatestVersion() - if err != nil { - return fmt.Errorf("failed to get the latest version of getmesh: %w", err) - } - - if l == currentVersion { - logger.Infof("Your getmesh version is up-to-date: %s\n", currentVersion) - return nil - } - - url := getDownloadShellURL() - res, err := http.Get(url) - if err != nil { - return fmt.Errorf("failed to fetch donwload.sh: %w", err) - } - defer res.Body.Close() - - cmd := exec.Command("bash", "-") - cmd.Stdin = res.Body - cmd.Stdout = logger.GetWriter() - cmd.Stderr = os.Stderr - cmd.Env = append(os.Environ(), "FETCH_LATEST_ISTIOCTL=false") - if err := cmd.Run(); err != nil { - return fmt.Errorf("installation failed: %w", err) - } - - logger.Infof("\ngetmesh successfully updated from %s to %s!\n", currentVersion, l) - return nil -} diff --git a/src/getmesh/getmesh_test.go b/src/getmesh/getmesh_test.go deleted file mode 100644 index 3148ef8..0000000 --- a/src/getmesh/getmesh_test.go +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright 2021 Tetrate -// -// 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 getmesh - -import ( - "fmt" - "net/http" - "net/http/httptest" - "os" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - - "github.com/tetratelabs/getmesh/src/util/logger" -) - -func TestLatestVersion(t *testing.T) { - t.Run("ok", func(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - _, _ = w.Write([]byte(` -aaa=aa -1+1 -echo "hello world" -GETMESH_LATEST_VERSION="1.1.1" -`)) - })) - defer ts.Close() - - require.NoError(t, os.Setenv(downloadShellTestURLEnvKey, ts.URL)) - - actual, err := LatestVersion() - require.NoError(t, err) - assert.Equal(t, "1.1.1", actual) - }) - - t.Run("error", func(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - _, _ = w.Write([]byte(` -aaa=aa -1+1 -`)) - })) - defer ts.Close() - require.NoError(t, os.Setenv(downloadShellTestURLEnvKey, ts.URL)) - _, err := LatestVersion() - require.Error(t, err) - }) -} - -func TestUpdate(t *testing.T) { - t.Run("up-to-date with getistio prefix", func(t *testing.T) { - v := "1.1.1" - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - _, _ = w.Write([]byte(fmt.Sprintf(`GETISTIO_LATEST_VERSION="%s"`, v))) - })) - defer ts.Close() - require.NoError(t, os.Setenv(downloadShellTestURLEnvKey, ts.URL)) - - buf := logger.ExecuteWithLock(func() { - require.NoError(t, Update(v)) - }) - - actual := buf.String() - assert.Contains(t, actual, fmt.Sprintf("Your getmesh version is up-to-date: %s", v)) - t.Log(actual) - }) - - t.Run("up-to-date with getmesh prefix", func(t *testing.T) { - v := "1.1.1" - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - _, _ = w.Write([]byte(fmt.Sprintf(`GETMESH_LATEST_VERSION="%s"`, v))) - })) - defer ts.Close() - require.NoError(t, os.Setenv(downloadShellTestURLEnvKey, ts.URL)) - - buf := logger.ExecuteWithLock(func() { - require.NoError(t, Update(v)) - }) - - actual := buf.String() - assert.Contains(t, actual, fmt.Sprintf("Your getmesh version is up-to-date: %s", v)) - t.Log(actual) - }) - - t.Run("download with getistio prefix", func(t *testing.T) { - msg := "download script executed" - current, latest := "0.0.0", "0.0.1" - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - _, _ = w.Write([]byte(fmt.Sprintf(`GETISTIO_LATEST_VERSION="%s" -echo "%s"`, latest, msg))) - })) - defer ts.Close() - require.NoError(t, os.Setenv(downloadShellTestURLEnvKey, ts.URL)) - - buf := logger.ExecuteWithLock(func() { - require.NoError(t, Update(current)) - }) - - actual := buf.String() - assert.Contains(t, actual, msg) - assert.Contains(t, actual, fmt.Sprintf("getmesh successfully updated from %s to %s!", current, latest)) - t.Log(actual) - }) - - t.Run("download with getmesh prefix", func(t *testing.T) { - msg := "download script executed" - current, latest := "0.0.0", "0.0.1" - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - _, _ = w.Write([]byte(fmt.Sprintf(`GETMESH_LATEST_VERSION="%s" -echo "%s"`, latest, msg))) - })) - defer ts.Close() - require.NoError(t, os.Setenv(downloadShellTestURLEnvKey, ts.URL)) - - buf := logger.ExecuteWithLock(func() { - require.NoError(t, Update(current)) - }) - - actual := buf.String() - assert.Contains(t, actual, msg) - assert.Contains(t, actual, fmt.Sprintf("getmesh successfully updated from %s to %s!", current, latest)) - t.Log(actual) - }) -} diff --git a/src/istioctl/istioctl.go b/src/istioctl/istioctl.go index d314362..629d01b 100644 --- a/src/istioctl/istioctl.go +++ b/src/istioctl/istioctl.go @@ -85,7 +85,7 @@ func PrintFetchedVersions(homeDir string) error { } name := dist.Name() - if strings.Contains(name, curr.ToString()) { + if curr != nil && strings.Contains(name, curr.ToString()) { logger.Infof(name + " (Active)\n") } else { logger.Infof(name + "\n") diff --git a/src/istioctl/istioctl_test.go b/src/istioctl/istioctl_test.go index bbc196a..068d403 100644 --- a/src/istioctl/istioctl_test.go +++ b/src/istioctl/istioctl_test.go @@ -23,7 +23,6 @@ import ( "strings" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tetratelabs/getmesh/api" @@ -102,7 +101,7 @@ func TestPrintFetchedVersions(t *testing.T) { 1.7.3-tetrate-v0 (Active) 20.1.1-tetrate-v0 ` - assert.Equal(t, exp, buf.String()) + require.Equal(t, exp, buf.String()) }) } @@ -121,7 +120,7 @@ func TestGetCurrentExecutable(t *testing.T) { defer os.RemoveAll(dir) require.NoError(t, getmesh.SetIstioVersion(dir, d)) _, err = GetCurrentExecutable(dir) - assert.Error(t, err) + require.Error(t, err) }) t.Run("ok", func(t *testing.T) { @@ -147,8 +146,8 @@ func TestGetCurrentExecutable(t *testing.T) { defer f.Close() actual, err := GetCurrentExecutable(dir) - assert.NoError(t, err) - assert.Equal(t, "1.7.3-tetrate-v0", actual.ToString()) + require.NoError(t, err) + require.Equal(t, "1.7.3-tetrate-v0", actual.ToString()) }) } @@ -158,7 +157,7 @@ func Test_getmeshctlPath(t *testing.T) { Flavor: api.IstioDistributionFlavorTetrate, FlavorVersion: 0, } - assert.Equal(t, "tmpdir/istio/1.7.3-tetrate-v0/bin/istioctl", + require.Equal(t, "tmpdir/istio/1.7.3-tetrate-v0/bin/istioctl", GetIstioctlPath("tmpdir", d)) } @@ -229,7 +228,7 @@ func TestRemove(t *testing.T) { err := Remove(dir, d, nil) require.Error(t, err) - assert.Equal(t, "we skip removing 1.7.3-non-exist-v1 since it does not exist in your system", err.Error()) + require.Equal(t, "we skip removing 1.7.3-non-exist-v1 since it does not exist in your system", err.Error()) }) t.Run("specific", func(t *testing.T) { @@ -281,11 +280,11 @@ func Test_checkExists(t *testing.T) { f, err := os.Create(ctlPath) require.NoError(t, err) f.Close() - assert.NoError(t, checkExist(dir, d)) + require.NoError(t, checkExist(dir, d)) }) t.Run("non exist", func(t *testing.T) { - assert.Error(t, checkExist(dir, &api.IstioDistribution{ + require.Error(t, checkExist(dir, &api.IstioDistribution{ Version: "1.7.3", Flavor: "non-exist", FlavorVersion: 0, @@ -322,17 +321,17 @@ func TestSwitch(t *testing.T) { d.Version = "1.7.3" require.NoError(t, getmesh.SetIstioVersion(dir, d)) d.Version = "20.1.1" - assert.NoError(t, Switch(dir, d)) - assert.Equal(t, d, getmesh.GetActiveConfig().IstioDistribution) + require.NoError(t, Switch(dir, d)) + require.Equal(t, d, getmesh.GetActiveConfig().IstioDistribution) }) t.Run("non-exist", func(t *testing.T) { - assert.Error(t, Switch(dir, &api.IstioDistribution{ + require.Error(t, Switch(dir, &api.IstioDistribution{ Version: "0.1.1", Flavor: api.IstioDistributionFlavorTetrate, FlavorVersion: 0, })) - assert.Error(t, Switch(dir, &api.IstioDistribution{ + require.Error(t, Switch(dir, &api.IstioDistribution{ Version: "1.7.3", Flavor: "non-exist", FlavorVersion: 0, @@ -370,7 +369,7 @@ func TestExec(t *testing.T) { buf := new(bytes.Buffer) require.NoError(t, ExecWithWriters(dir, []string{"."}, buf, nil)) - assert.Equal(t, buf.String(), "istioctl") + require.Equal(t, buf.String(), "istioctl") } func TestFetch(t *testing.T) { @@ -475,10 +474,13 @@ func Test_fetchIstioctl(t *testing.T) { defer os.RemoveAll(dir) for _, d := range m.IstioDistributions { - require.NoError(t, fetchIstioctl(dir, d)) - ctlPath := GetIstioctlPath(dir, d) - _, err = os.Stat(ctlPath) - require.NoError(t, err) - t.Log(ctlPath) + d := d + t.Run(d.String(), func(t *testing.T) { + require.NoError(t, fetchIstioctl(dir, d)) + ctlPath := GetIstioctlPath(dir, d) + _, err = os.Stat(ctlPath) + require.NoError(t, err) + t.Log(ctlPath) + }) } } diff --git a/src/manifest/checker_endoflife_test.go b/src/manifest/checker_endoflife_test.go index 61210c3..2a06ba1 100644 --- a/src/manifest/checker_endoflife_test.go +++ b/src/manifest/checker_endoflife_test.go @@ -22,7 +22,6 @@ import ( "testing" "time" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tetratelabs/getmesh/api" @@ -67,7 +66,7 @@ func Test_endOfLifeChecker(t *testing.T) { require.NoError(t, endOfLifeCheckerImpl(m, time.Now())) }) - assert.Equal(t, "", buf.String()) + require.Equal(t, "", buf.String()) }) t.Run("ok time", func(t *testing.T) { @@ -77,7 +76,7 @@ func Test_endOfLifeChecker(t *testing.T) { require.NoError(t, endOfLifeCheckerImpl(m, now)) }) - assert.Equal(t, "", buf.String()) + require.Equal(t, "", buf.String()) }) t.Run("warn", func(t *testing.T) { @@ -92,7 +91,7 @@ func Test_endOfLifeChecker(t *testing.T) { require.NoError(t, endOfLifeCheckerImpl(m, now)) }) - assert.Contains(t, buf.String(), fmt.Sprintf(exp, c.minorVersion)) + require.Contains(t, buf.String(), fmt.Sprintf(exp, c.minorVersion)) t.Log(buf.String()) }) diff --git a/src/manifest/checker_security_patch_test.go b/src/manifest/checker_security_patch_test.go index ade11a3..d044d11 100644 --- a/src/manifest/checker_security_patch_test.go +++ b/src/manifest/checker_security_patch_test.go @@ -20,7 +20,6 @@ import ( "strings" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tetratelabs/getmesh/api" @@ -77,11 +76,11 @@ func Test_securityPatchCheckerImpl(t *testing.T) { `[WARNING] The locally installed minor version 1.2-tetrate is no longer supported by getmesh. We recommend you use the higher minor versions in "getmesh list" or remove with "getmesh prune"`, `[WARNING] The locally installed minor version 1.7-tetrate has a latest version 1.7.6-tetrate-v2 including security patches. We strongly recommend you to download 1.7.6-tetrate-v2 by "getmesh fetch".`, } { - assert.Contains(t, msg, exp) + require.Contains(t, msg, exp) } for _, nexp := range []string{"1.10", "1.8.2"} { - assert.NotContains(t, msg, nexp) + require.NotContains(t, msg, nexp) } t.Log(msg) @@ -122,7 +121,7 @@ func Test_constructLatestVersionsMap(t *testing.T) { } { actual, err := constructLatestVersionsMap(c.in) require.NoError(t, err) - assert.Equal(t, c.exp, actual) + require.Equal(t, c.exp, actual) } } @@ -164,7 +163,7 @@ func Test_findSecurityPatchUpgrade(t *testing.T) { require.NoError(t, err) actual, includeSP, err := findSecurityPatchUpgrade(c.base, g, remotes) require.NoError(t, err) - assert.Equal(t, c.exp, actual) - assert.Equal(t, c.expIncludeSecurityPatch, includeSP) + require.Equal(t, c.exp, actual) + require.Equal(t, c.expIncludeSecurityPatch, includeSP) } } diff --git a/src/manifest/manifest_test.go b/src/manifest/manifest_test.go index ad8244d..3bf62ef 100644 --- a/src/manifest/manifest_test.go +++ b/src/manifest/manifest_test.go @@ -20,7 +20,6 @@ import ( "net/http/httptest" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/tetratelabs/getmesh/api" @@ -74,7 +73,7 @@ func TestFetchManifest(t *testing.T) { for _, a := range actual.IstioDistributions { delete(expIstioVersions, a.ToString()) } - assert.Equal(t, map[string]struct{}{}, expIstioVersions) + require.Equal(t, map[string]struct{}{}, expIstioVersions) } func TestPrintManifest(t *testing.T) { @@ -99,7 +98,7 @@ func TestPrintManifest(t *testing.T) { buf := logger.ExecuteWithLock(func() { require.NoError(t, PrintManifest(manifest, nil)) }) - assert.Equal(t, `ISTIO VERSION FLAVOR FLAVOR VERSION K8S VERSIONS + require.Equal(t, `ISTIO VERSION FLAVOR FLAVOR VERSION K8S VERSIONS 1.7.6 tetrate 0 1.16 1.7.5 tetrate 0 1.16 `, @@ -140,7 +139,7 @@ func TestPrintManifest(t *testing.T) { require.NoError(t, PrintManifest(manifest, current)) }) - assert.Equal(t, `ISTIO VERSION FLAVOR FLAVOR VERSION K8S VERSIONS + require.Equal(t, `ISTIO VERSION FLAVOR FLAVOR VERSION K8S VERSIONS 1.8.3 istio 0 1.18 *1.7.6 tetratefips 0 1.16 1.7.5 tetrate 0 1.16 diff --git a/src/util/kube_test.go b/src/util/kube_test.go index a33c109..772c1e5 100644 --- a/src/util/kube_test.go +++ b/src/util/kube_test.go @@ -18,7 +18,7 @@ import ( "os" "testing" - "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "k8s.io/client-go/tools/clientcmd" ) @@ -29,7 +29,7 @@ func TestGetKubeConfigLocation(t *testing.T) { defer os.Setenv("KUBECONFIG", original) config := GetKubeConfigLocation() - assert.Equal(t, config, clientcmd.RecommendedHomeFile) + require.Equal(t, config, clientcmd.RecommendedHomeFile) }) t.Run("KUBECONFIG", func(t *testing.T) { @@ -39,7 +39,7 @@ func TestGetKubeConfigLocation(t *testing.T) { defer os.Setenv("KUBECONFIG", original) config := GetKubeConfigLocation() - assert.Equal(t, config, actual) + require.Equal(t, config, actual) }) t.Run("local", func(t *testing.T) { actual := "./testconfig" @@ -49,7 +49,7 @@ func TestGetKubeConfigLocation(t *testing.T) { KubeConfig = actual config := GetKubeConfigLocation() - assert.Equal(t, config, actual) + require.Equal(t, config, actual) KubeConfig = "" //cleanup }) } diff --git a/src/util/util_test.go b/src/util/util_test.go index 8f724cd..7b3ee30 100644 --- a/src/util/util_test.go +++ b/src/util/util_test.go @@ -20,7 +20,6 @@ import ( "path/filepath" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -32,7 +31,7 @@ func TestGetIstioHomeDir(t *testing.T) { actual, err := getmeshHomeDir(dir) require.NoError(t, err) - assert.Equal(t, filepath.Join(dir, getmeshDirname), actual) + require.Equal(t, filepath.Join(dir, getmeshDirname), actual) }) t.Run("created", func(t *testing.T) { @@ -53,11 +52,11 @@ func TestGetIstioHomeDir(t *testing.T) { actual, err := getmeshHomeDir(dir) require.NoError(t, err) - assert.Equal(t, home, actual) + require.Equal(t, home, actual) // verify the existing directory left intact b, err := ioutil.ReadFile(filePath) require.NoError(t, err) - assert.Equal(t, expBytes, b) + require.Equal(t, expBytes, b) }) }