Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLOUDP-231607: update mdb version to 7.0 #2717

Merged
merged 3 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/cli/atlas/clusters/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestCreateOpts_Run(t *testing.T) {
members: 3,
diskSizeGB: 10,
backup: false,
mdbVersion: "4.4",
mdbVersion: "7.0",
store: mockStore,
}

Expand Down
2 changes: 1 addition & 1 deletion internal/cli/atlas/clusters/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestUpdate_Run(t *testing.T) {
name: "ProjectBar",
tier: atlasM2,
diskSizeGB: 10,
mdbVersion: "4.4",
mdbVersion: "7.0",
store: mockStore,
}

Expand Down
5 changes: 4 additions & 1 deletion test/e2e/atlas/atlas_e2e_test_generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,10 @@ func (g *atlasE2ETestGenerator) generateCluster() {
}

if g.mDBVer == "" {
g.mDBVer = e2eMDBVer
mdbVersion, e := MongoDBMajorVersion()
require.NoError(g.t, e)

g.mDBVer = mdbVersion
}

g.clusterName, g.clusterRegion, err = deployClusterForProject(g.projectID, g.tier, g.mDBVer, g.enableBackup)
Expand Down
7 changes: 5 additions & 2 deletions test/e2e/atlas/backup_export_jobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ func TestExportJobs(t *testing.T) {
fmt.Println(clusterName)
r.NoError(err)

mdbVersion, err := MongoDBMajorVersion()
r.NoError(err)

const cloudProvider = "AWS"
iamRoleID := os.Getenv("E2E_CLOUD_ROLE_ID")
bucketName := os.Getenv("E2E_TEST_BUCKET")
Expand All @@ -56,15 +59,15 @@ func TestExportJobs(t *testing.T) {
"--tier", tierM10,
"--region=US_EAST_1",
"--provider", e2eClusterProvider,
"--mdbVersion", e2eSharedMDBVer,
"--mdbVersion", mdbVersion,
"-o=json")
cmd.Env = os.Environ()
resp, err := cmd.CombinedOutput()
r.NoError(err, string(resp))

var cluster *atlasv2.AdvancedClusterDescription
r.NoError(json.Unmarshal(resp, &cluster))
ensureCluster(t, cluster, clusterName, e2eSharedMDBVer, 10, false)
ensureCluster(t, cluster, clusterName, mdbVersion, 10, false)
})
t.Cleanup(func() {
require.NoError(t, deleteClusterForProject("", clusterName))
Expand Down
7 changes: 5 additions & 2 deletions test/e2e/atlas/backup_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func TestSnapshots(t *testing.T) {
clusterName, err := RandClusterName()
r.NoError(err)

mdbVersion, err := MongoDBMajorVersion()
r.NoError(err)

var snapshotID string

t.Run("Create cluster", func(t *testing.T) {
Expand All @@ -46,15 +49,15 @@ func TestSnapshots(t *testing.T) {
"--tier", tierM10,
"--region=US_EAST_1",
"--provider", e2eClusterProvider,
"--mdbVersion", e2eSharedMDBVer,
"--mdbVersion", mdbVersion,
"-o=json")
cmd.Env = os.Environ()
resp, err := cmd.CombinedOutput()
require.NoError(t, err, string(resp))

var cluster *atlasv2.AdvancedClusterDescription
require.NoError(t, json.Unmarshal(resp, &cluster))
ensureCluster(t, cluster, clusterName, e2eSharedMDBVer, 10, false)
ensureCluster(t, cluster, clusterName, mdbVersion, 10, false)
})
t.Cleanup(func() {
require.NoError(t, deleteClusterForProject("", clusterName))
Expand Down
52 changes: 46 additions & 6 deletions test/e2e/atlas/clusters_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
package atlas_test

import (
"bytes"
"encoding/json"
"fmt"
"os"
"os/exec"
"testing"
"text/template"

"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/config"
"github.com/mongodb/mongodb-atlas-cli/atlascli/test/e2e"
Expand All @@ -40,10 +42,15 @@ func TestClustersFile(t *testing.T) {
clusterFileName, err := RandClusterName()
req.NoError(err)

clusterFile := "create_cluster_test.json"
if service := os.Getenv("MCLI_SERVICE"); service == config.CloudGovService {
clusterFile = "create_cluster_gov_test.json"
}
mdbVersion, err := MongoDBMajorVersion()
req.NoError(err)

clusterFile, err := generateClusterFile(mdbVersion)
req.NoError(err)

t.Cleanup(func() {
os.Remove(clusterFile)
})

t.Run("Create via file", func(t *testing.T) {
cmd := exec.Command(cliPath,
Expand All @@ -60,7 +67,7 @@ func TestClustersFile(t *testing.T) {
var cluster atlasv2.AdvancedClusterDescription
req.NoError(json.Unmarshal(resp, &cluster))

ensureCluster(t, &cluster, clusterFileName, e2eMDBVer, 30, false)
ensureCluster(t, &cluster, clusterFileName, mdbVersion, 30, false)
})

t.Run("Watch", func(t *testing.T) {
Expand Down Expand Up @@ -92,7 +99,7 @@ func TestClustersFile(t *testing.T) {
var cluster atlasv2.AdvancedClusterDescription
req.NoError(json.Unmarshal(resp, &cluster))
t.Logf("%v\n", cluster)
ensureCluster(t, &cluster, clusterFileName, e2eMDBVer, 40, false)
ensureCluster(t, &cluster, clusterFileName, mdbVersion, 40, false)
assert.Empty(t, cluster.GetTags())
})

Expand Down Expand Up @@ -126,3 +133,36 @@ func TestClustersFile(t *testing.T) {
t.Log(string(resp))
})
}

func generateClusterFile(mdbVersion string) (string, error) {
data := struct {
MongoDBMajorVersion string
}{
MongoDBMajorVersion: mdbVersion,
}

templateFile := "create_cluster_test.json"
if service := os.Getenv("MCLI_SERVICE"); service == config.CloudGovService {
templateFile = "create_cluster_gov_test.json"
}

tmpl, err := template.ParseFiles(templateFile)
if err != nil {
return "", err
}

var tempBuffer bytes.Buffer
if err = tmpl.Execute(&tempBuffer, data); err != nil {
return "", err
}

const clusterFile = "create_cluster.json"
file, err := os.Create(clusterFile)
if err != nil {
return "", err
}
defer file.Close()

_, err = tempBuffer.WriteTo(file)
return clusterFile, err
}
25 changes: 21 additions & 4 deletions test/e2e/atlas/clusters_flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ package atlas_test

import (
"encoding/json"
"fmt"
"os"
"os/exec"
"testing"

"github.com/Masterminds/semver/v3"
"github.com/mongodb/mongodb-atlas-cli/atlascli/test/e2e"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -44,6 +46,12 @@ func TestClustersFlags(t *testing.T) {
region, err := g.newAvailableRegion(tier, e2eClusterProvider)
req.NoError(err)

mdbVersion, err := MongoDBMajorVersion()
req.NoError(err)

previousMdbVersion, err := getPreviousMajorVersion(mdbVersion)
req.NoError(err)

t.Run("Create", func(t *testing.T) {
cmd := exec.Command(cliPath,
clustersEntity,
Expand All @@ -53,7 +61,7 @@ func TestClustersFlags(t *testing.T) {
"--members=3",
"--tier", tier,
"--provider", e2eClusterProvider,
"--mdbVersion", e2eMDBVer,
"--mdbVersion", previousMdbVersion,
"--diskSizeGB", diskSizeGB30,
"--enableTerminationProtection",
"--projectId", g.projectID,
Expand All @@ -66,7 +74,7 @@ func TestClustersFlags(t *testing.T) {
var cluster *atlasv2.AdvancedClusterDescription
require.NoError(t, json.Unmarshal(resp, &cluster))

ensureCluster(t, cluster, clusterName, e2eMDBVer, 30, true)
ensureCluster(t, cluster, clusterName, previousMdbVersion, 30, true)
})

t.Run("Load Sample Data", func(t *testing.T) {
Expand Down Expand Up @@ -207,7 +215,7 @@ func TestClustersFlags(t *testing.T) {
"update",
clusterName,
"--diskSizeGB", diskSizeGB40,
"--mdbVersion=5.0",
"--mdbVersion", mdbVersion,
"--disableTerminationProtection",
"--projectId", g.projectID,
"-o=json")
Expand All @@ -218,7 +226,7 @@ func TestClustersFlags(t *testing.T) {
var cluster atlasv2.AdvancedClusterDescription
require.NoError(t, json.Unmarshal(resp, &cluster))

ensureCluster(t, &cluster, clusterName, "5.0", 40, false)
ensureCluster(t, &cluster, clusterName, mdbVersion, 40, false)
})

t.Run("Delete", func(t *testing.T) {
Expand All @@ -231,3 +239,12 @@ func TestClustersFlags(t *testing.T) {
assert.Contains(t, string(resp), expected)
})
}

func getPreviousMajorVersion(version string) (string, error) {
v, err := semver.NewVersion(version)
if err != nil {
return "", err
}

return fmt.Sprintf("%d.%d", v.Major()-1, v.Minor()), nil
}
7 changes: 5 additions & 2 deletions test/e2e/atlas/clusters_sharded_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ func TestShardedCluster(t *testing.T) {
region, err := g.newAvailableRegion(tier, e2eClusterProvider)
req.NoError(err)

mdbVersion, err := MongoDBMajorVersion()
req.NoError(err)

t.Run("Create sharded cluster", func(t *testing.T) {
cmd := exec.Command(cliPath,
clustersEntity,
Expand All @@ -54,7 +57,7 @@ func TestShardedCluster(t *testing.T) {
"--members=3",
"--tier", tier,
"--provider", e2eClusterProvider,
"--mdbVersion", e2eMDBVer,
"--mdbVersion", mdbVersion,
"--diskSizeGB", diskSizeGB30,
"--projectId", g.projectID,
"-o=json")
Expand All @@ -66,7 +69,7 @@ func TestShardedCluster(t *testing.T) {
var cluster atlasv2.AdvancedClusterDescription
req.NoError(json.Unmarshal(resp, &cluster))

ensureCluster(t, &cluster, shardedClusterName, e2eMDBVer, 30, false)
ensureCluster(t, &cluster, shardedClusterName, mdbVersion, 30, false)
})

t.Run("Delete sharded cluster", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/atlas/create_cluster_gov_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"diskSizeGB": 30,
"encryptionAtRestProvider": "NONE",
"groupId": "60e40e9e9e80a53e4f41686e",
"mongoDBMajorVersion": "4.4",
gssbzn marked this conversation as resolved.
Show resolved Hide resolved
"mongoDBMajorVersion": "{{.MongoDBMajorVersion}}",
"name": "Cluster0",
"paused": false,
"pitEnabled": true,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/atlas/create_cluster_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"backupEnabled":false,
"diskSizeGB":30,
"numShards":1,
"mongoDBMajorVersion":"4.4",
"mongoDBMajorVersion":"{{.MongoDBMajorVersion}}",
"providerSettings":{
"providerName":"GCP",
"instanceSizeName":"M10"
Expand Down
2 changes: 0 additions & 2 deletions test/e2e/atlas/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ const (
e2eGovClusterTier = "M20"
e2eSharedClusterTier = "M2"
e2eClusterProvider = "AWS" // e2eClusterProvider preferred provider for e2e testing.
e2eMDBVer = "4.4"
e2eSharedMDBVer = "6.0"
)

// Backup compliance policy constants.
Expand Down