Skip to content
Draft
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
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ MANIFEST_FILE?=manifest.yml
WIN_MANIFEST_FILE?=manifest.windows.yml

TEST_CMD?=go test
UNIT_TAGS?=unit
COVERAGE?=coverage.out

E2E_PLUGIN_BINARY_PATH=../../$(PLUGIN_BINARY_PATH)
E2E_TAGS?=e2e
E2E_TIMEOUT?=60m
E2E_PARALLEL?=1
E2E_EXTRA_ARGS?=
E2E_RUN_PATTERN?=.*

export E2E_PLUGIN_BINARY_PATH
export E2E_ATLASCLI_BINARY_PATH
Expand Down Expand Up @@ -63,12 +62,12 @@ lint: ## Run linter
.PHONY: unit-test
unit-test: ## Run unit-tests
@echo "==> Running unit tests..."
$(TEST_CMD) --tags="$(UNIT_TAGS)" -race -cover -coverprofile $(COVERAGE) -count=1 ./...
$(TEST_CMD) -race -cover -coverprofile $(COVERAGE) -count=1 ./internal/... ./cmd/...

.PHONY: fuzz-normalizer-test
fuzz-normalizer-test: ## Run fuzz test
@echo "==> Running fuzz test..."
$(TEST_CMD) -fuzz=Fuzz -fuzztime 50s --tags="$(UNIT_TAGS)" -race ./internal/kubernetes/operator/resources
$(TEST_CMD) -fuzz=Fuzz -fuzztime 50s -race ./internal/kubernetes/operator/resources

.PHONY: build-debug
build-debug: ## Generate a binary in ./bin for debugging plugin
Expand All @@ -80,7 +79,7 @@ e2e-test: build-debug ## Run E2E tests
# the target assumes the MCLI_* environment variables are exported
@./scripts/atlas-binary.sh
@echo "==> Running E2E tests..."
GOCOVERDIR=$(GOCOVERDIR) $(TEST_CMD) -race -v -p 1 -parallel $(E2E_PARALLEL) -v -timeout $(E2E_TIMEOUT) -tags="$(E2E_TAGS)" ./test/e2e... $(E2E_EXTRA_ARGS)
GOCOVERDIR=$(GOCOVERDIR) $(TEST_CMD) -race -v -p 1 -parallel $(E2E_PARALLEL) -v -timeout $(E2E_TIMEOUT) -run="$(E2E_RUN_PATTERN)" ./test/e2e... $(E2E_EXTRA_ARGS)

.PHONY: gen-mocks
gen-mocks: ## Generate mocks
Expand Down
16 changes: 8 additions & 8 deletions build/ci/evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ functions:
- MCLI_PUBLIC_API_KEY
- MCLI_SERVICE
- TEST_CMD
- E2E_TAGS
- E2E_RUN_PATTERN
- MCLI_OPS_MANAGER_URL
- OM_VERSION
- LOCAL_KEY
Expand Down Expand Up @@ -262,9 +262,9 @@ tasks:
AZURE_CLIENT_SECRET: ${azure_client_secret}
GOOGLE_PROJECT_ID: ${google_project_id}
GCP_SA_CRED: ${gcp_sa_cred}
E2E_TAGS: atlas,cli
E2E_RUN_PATTERN: TestKubernetesPluginBinary
- name: atlas_kubernetes_generate_e2e
tags: ["e2e","required","kubernetes", "assigned_to_jira_team_cloudp_kubernetes_atlas"]
# tags: ["e2e","required","kubernetes", "assigned_to_jira_team_cloudp_kubernetes_atlas"]
must_have_test_results: true
commands:
- func: "install gotestsum"
Expand All @@ -290,9 +290,9 @@ tasks:
AZURE_CLIENT_SECRET: ${azure_client_secret}
GOOGLE_PROJECT_ID: ${google_project_id}
GCP_SA_CRED: ${gcp_sa_cred}
E2E_TAGS: generate
E2E_RUN_PATTERN: TestExport.*|TestGenerate.*|TestProject.*|TestFederatedAuthTest|TestEmptyProject|TestKubernetesConfigGenerate.*
- name: atlas_kubernetes_apply_e2e
tags: [ "e2e","required","kubernetes", "assigned_to_jira_team_cloudp_kubernetes_atlas" ]
# tags: [ "e2e","required","kubernetes", "assigned_to_jira_team_cloudp_kubernetes_atlas" ]
must_have_test_results: true
commands:
- func: "install gotestsum"
Expand All @@ -318,9 +318,9 @@ tasks:
AZURE_CLIENT_SECRET: ${azure_client_secret}
GOOGLE_PROJECT_ID: ${google_project_id}
GCP_SA_CRED: ${gcp_sa_cred}
E2E_TAGS: apply
E2E_RUN_PATTERN: TestKubernetesConfigApply.*
- name: atlas_kubernetes_install_e2e
tags: [ "e2e","required","kubernetes", "assigned_to_jira_team_cloudp_kubernetes_atlas" ]
# tags: [ "e2e","required","kubernetes", "assigned_to_jira_team_cloudp_kubernetes_atlas" ]
must_have_test_results: true
commands:
- func: "install gotestsum"
Expand All @@ -346,7 +346,7 @@ tasks:
AZURE_CLIENT_SECRET: ${azure_client_secret}
GOOGLE_PROJECT_ID: ${google_project_id}
GCP_SA_CRED: ${gcp_sa_cred}
E2E_TAGS: install
E2E_RUN_PATTERN: TestKubernetesOperatorInstall
buildvariants:
- name: code_health
display_name: "Code Health"
Expand Down
1 change: 0 additions & 1 deletion internal/cli/kubernetes/config/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build unit

package config

Expand Down
1 change: 0 additions & 1 deletion internal/cli/kubernetes/config/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build unit

package config

Expand Down
1 change: 0 additions & 1 deletion internal/cli/kubernetes/operator/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build unit

package operator
1 change: 0 additions & 1 deletion internal/kubernetes/operator/config_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build unit

package operator

Expand Down
1 change: 0 additions & 1 deletion internal/kubernetes/operator/dbusers/dbusers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build unit

package dbusers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build unit

package deployment

Expand Down
1 change: 0 additions & 1 deletion internal/kubernetes/operator/project/containers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build unit

package project

Expand Down
1 change: 0 additions & 1 deletion internal/kubernetes/operator/project/customroles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build unit

//nolint:all
package project
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build unit

package project

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build unit

package project

Expand Down
1 change: 0 additions & 1 deletion internal/kubernetes/operator/project/peerings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build unit

package project

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build unit

package project

Expand Down
9 changes: 4 additions & 5 deletions internal/kubernetes/operator/project/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build unit

package project

Expand Down Expand Up @@ -544,8 +543,8 @@ func TestBuildAtlasProject(t *testing.T) {
},
},
BackupCompliancePolicyRef: &akov2common.ResourceRefNamespaced{
Name: expectedBCP.ObjectMeta.Name,
Namespace: expectedBCP.ObjectMeta.Namespace,
Name: expectedBCP.Name,
Namespace: expectedBCP.Namespace,
},
},
Status: akov2status.AtlasProjectStatus{
Expand Down Expand Up @@ -638,8 +637,8 @@ func TestBuildAtlasProject(t *testing.T) {
},
},
BackupCompliancePolicyRef: &akov2common.ResourceRefNamespaced{
Name: expectedBCP.ObjectMeta.Name,
Namespace: expectedBCP.ObjectMeta.Namespace,
Name: expectedBCP.Name,
Namespace: expectedBCP.Namespace,
},
},
Status: akov2status.AtlasProjectStatus{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build unit

package resources

Expand Down
1 change: 0 additions & 1 deletion internal/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build unit

package store

Expand Down
1 change: 0 additions & 1 deletion internal/validate/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build unit

package validate

Expand Down
14 changes: 6 additions & 8 deletions test/e2e/atlas_e2e_test_generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build e2e || install || generate || apply

package e2e

Expand All @@ -31,15 +30,14 @@ import (
"cloud.google.com/go/compute/apiv1/computepb"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v2"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/aws" //nolint:staticcheck
"github.com/aws/aws-sdk-go/aws/session" //nolint:staticcheck
"github.com/aws/aws-sdk-go/service/ec2" //nolint:staticcheck
"github.com/mongodb/atlas-cli-plugin-kubernetes/internal/pointer"
"github.com/mongodb/atlas-cli-plugin-kubernetes/test"
akov2provider "github.com/mongodb/mongodb-atlas-kubernetes/v2/api/v1/provider"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.mongodb.org/atlas-sdk/v20241113004/admin"
atlasv2 "go.mongodb.org/atlas-sdk/v20241113004/admin"
)

Expand Down Expand Up @@ -642,7 +640,7 @@ func ensureGCPCredentials() error {
return fmt.Errorf("failed to save credentials contents GCP_SA_CRED to %s: %w",
googleSAFilename, err)
}
os.Setenv("GOOGLE_APPLICATION_CREDENTIALS", googleSAFilename)
_ = os.Setenv("GOOGLE_APPLICATION_CREDENTIALS", googleSAFilename)
return nil
}

Expand Down Expand Up @@ -670,7 +668,7 @@ func (g *atlasE2ETestGenerator) deletePeering(id string) {
timeout := 5 * time.Minute
for {
_, _, err := client.NetworkPeeringApi.GetPeeringConnection(ctx, g.projectID, id).Execute()
if admin.IsErrorCode(err, "PEER_NOT_FOUND") {
if atlasv2.IsErrorCode(err, "PEER_NOT_FOUND") {
return
}
if err != nil {
Expand Down Expand Up @@ -756,7 +754,7 @@ func deleteProjectWithRetry(t *testing.T, projectID string) {

func deleteKeys(t *testing.T, toDelete map[string]struct{}) {
t.Helper()
cliPath, err := AtlasCLIBin()
cliPath, _ := AtlasCLIBin()

cmd := exec.Command(cliPath,
orgEntity,
Expand Down
1 change: 0 additions & 1 deletion test/e2e/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build e2e || cli || install || generate || apply

package e2e

Expand Down
1 change: 0 additions & 1 deletion test/e2e/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build e2e || cli

package e2e

Expand Down
7 changes: 3 additions & 4 deletions test/e2e/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// 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.
//go:build e2e || install || generate || apply

package e2e

Expand Down Expand Up @@ -1065,7 +1064,7 @@ func generateTestAtlasStreamInstance(t *testing.T, projectID string, instanceNam

t.Cleanup(func() {
t.Logf("Deleting test Stream Instance: %s", instanceName)
deleteStreamsInstance(t, projectID, instanceName)
_ = deleteStreamsInstance(t, projectID, instanceName)
})

return instanceName
Expand Down Expand Up @@ -1102,7 +1101,7 @@ func generateTestAtlasAdvancedDeployment(t *testing.T, projectID string, cluster

t.Cleanup(func() {
t.Logf("Deleting test Advanced Deployment: %s", clusterName)
deleteClusterForProject(projectID, clusterName)
_ = deleteClusterForProject(projectID, clusterName)
})

return clusterName
Expand Down Expand Up @@ -1141,7 +1140,7 @@ func generateTestAtlasFlexCluster(t *testing.T, projectID string, clusterName st

t.Cleanup(func() {
t.Logf("Deleting test Advanced Deployment: %s", clusterName)
deleteClusterForProject(projectID, clusterName)
_ = deleteClusterForProject(projectID, clusterName)
})

return clusterName
Expand Down
1 change: 0 additions & 1 deletion test/e2e/kubernetes_config_apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build e2e || apply

package e2e

Expand Down
Loading
Loading