Skip to content

Commit

Permalink
Merge pull request #12 from akamai/release/0.2.0
Browse files Browse the repository at this point in the history
Release/0.2.0
  • Loading branch information
rakayada authored May 4, 2023
2 parents b81c1ce + f625d28 commit 9e6529d
Show file tree
Hide file tree
Showing 17 changed files with 195 additions and 311 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@

Test Center is a testing tool that checks the effect of configuration changes on your web property. Use this CLI as part of your testing protocol to increase your confidence in the safety and accuracy of your configuration changes.

> **_Breaking changes_**: Due to the active development of the new Test Center experience, we implemented the following changes to the CLI: <br> 1. In the `clientProfile` object, the `clientType` field is changed to `client` with values `CHROME` and `CURL`. <br> 2. In a test suite object, the `testCaseCount` field changed to `executableTestCaseCount`. This change is caused by the [Variables group](https://techdocs.akamai.com/test-ctr/v3/reference/variables-overview) feature. <br>Impacted operations: <br> - [List test suites](#list-test-suites), <br>- [Add a test case to a test suite](#add-a-test-case-to-a-test-suite),<br> - [Generate a default test suite for a property](#generate-a-default-test-suite-for-a-property),<br> - [Import a test suite](#import-a-test-suite).<br> Implement necessary changes in your objects before running these operations.

## Install Test Center CLI

To install this CLI, you need the [Akamai CLI](https://github.com/akamai/cli) package manager. Once you install the Akamai CLI, run this command:
Expand Down
2 changes: 1 addition & 1 deletion cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
},
"commands": [{
"name": "test-center",
"version": "0.1.1",
"version": "0.2.0",
"description": "Test Center is a testing tool that checks the effect of configuration changes on your web property. Use this tool as part of your testing protocol to increase your confidence in the safety and accuracy of your configuration changes.",
"bin": "https://github.com/akamai/cli-test-center/releases/download/{{.Version}}/akamai-{{.Name}}-{{.Version}}-{{.OS}}{{.Arch}}{{.BinSuffix}}"
}]
Expand Down
11 changes: 9 additions & 2 deletions cmd/command_usage_and_example_constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ const (
TestSuiteRestoreExample = ` $ akamai test-center test-suite restore --name "Test suite name"
$ akamai test-center test-suite restore --id 12345`

TestSuiteViewUse = "view [--id ID | --name NAME] [--group-by test-request | condition | ipversion]"
TestSuiteViewUse = "view [--id ID | --name NAME] [--group-by test-request | condition | ip-version]"
TestSuiteViewExample = ` $ akamai test-center test-suite view --id 1001
$ akamai test-center test-suite view --name 'Example TS' --group-by test-request`
TestSuiteViewCommandAliases = "export"

ConditionTemplateUse = "conditions"
ConditionTemplateExample = " $ akamai test-center conditions"
ConditionTemplateExample = ` $ akamai test-center conditions`
)

// Flag Names
Expand Down Expand Up @@ -120,3 +120,10 @@ const (
FlagSectionDefaultValue = "test-center"
FlagIpVersionDefaultValue = "V4"
)

// Environment variable Constants
const (
DefaultEdgercPathKey = "AKAMAI_EDGERC"
DefaultEdgercSectionKey = "AKAMAI_EDGERC_SECTION"
DefaultJsonOutputKey = "AKAMAI_OUTPUT_JSON"
)
28 changes: 22 additions & 6 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package cmd

import (
"errors"
"os"

"github.com/akamai/AkamaiOPEN-edgegrid-golang/edgegrid"
"github.com/akamai/cli-test-center/internal"
"github.com/fatih/color"
"github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
"os"
"path/filepath"
"strconv"
)

Expand Down Expand Up @@ -71,6 +72,21 @@ func init() {
rootCmd.SilenceErrors = true
rootCmd.SilenceUsage = true

// Setting the default values for the global flags from environment variable.
defaultEdgercPath := os.Getenv(DefaultEdgercPathKey)
defaultEdgercSection := os.Getenv(DefaultEdgercSectionKey)
globalJsonFlag, _ := strconv.ParseBool(os.Getenv(DefaultJsonOutputKey))

if defaultEdgercPath == internal.Empty {
if home, err := homedir.Dir(); err == nil {
defaultEdgercPath = filepath.Join(home, FlagEdgercDefaultValue)
}
}

if defaultEdgercSection == internal.Empty {
defaultEdgercSection = FlagSectionDefaultValue
}

rootCmd.SetFlagErrorFunc(func(cmd *cobra.Command, err error) error {
internal.PrintError(err.Error() + "\n\n")
cmd.Println(cmd.UsageString())
Expand All @@ -80,10 +96,10 @@ func init() {
rootCmd.Short = internal.GetMessageForKey(rootCmd, internal.Short)
rootCmd.Long = internal.GetMessageForKey(rootCmd, internal.Long)

rootCmd.PersistentFlags().StringVar(&edgeRcPath, FlagEdgerc, FlagEdgercDefaultValue, internal.GetMessageForKey(rootCmd, FlagEdgerc))
rootCmd.PersistentFlags().StringVar(&edgeRcSection, FlagSection, FlagSectionDefaultValue, internal.GetMessageForKey(rootCmd, FlagSection))
rootCmd.PersistentFlags().StringVar(&accountSwitchKey, FlagAccountKey, "", internal.GetMessageForKey(rootCmd, FlagAccountKey))
rootCmd.PersistentFlags().BoolVar(&jsonOutput, FlagJson, false, internal.GetMessageForKey(rootCmd, FlagJson))
rootCmd.PersistentFlags().StringVar(&edgeRcPath, FlagEdgerc, defaultEdgercPath, internal.GetMessageForKey(rootCmd, FlagEdgerc))
rootCmd.PersistentFlags().StringVar(&edgeRcSection, FlagSection, defaultEdgercSection, internal.GetMessageForKey(rootCmd, FlagSection))
rootCmd.PersistentFlags().StringVar(&accountSwitchKey, FlagAccountKey, internal.Empty, internal.GetMessageForKey(rootCmd, FlagAccountKey))
rootCmd.PersistentFlags().BoolVar(&jsonOutput, FlagJson, globalJsonFlag, internal.GetMessageForKey(rootCmd, FlagJson))
rootCmd.PersistentFlags().BoolVar(&forceColor, FlagForceColor, false, internal.GetMessageForKey(rootCmd, FlagForceColor))
rootCmd.Flags().BoolP(FlagHelp, FlagHelpShortHand, false, internal.GetMessageForKey(rootCmd, FlagHelp))
rootCmd.Flags().BoolP(FlagVersion, FlagVersionShortHand, false, internal.GetMessageForKey(rootCmd, FlagVersion))
Expand Down
2 changes: 1 addition & 1 deletion cmd/test_suites_add_test_case.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var testSuitesAddTestCaseCmd = &cobra.Command{
//Check if all required flag are present.
validator.AddTestCaseToTestSuiteFlagCheck(testSuiteIdStr, testSuiteName, url, condition, ipVersion, addHeader, modifyHeader)

testSuites := svc.GetTestSuitesByIdOrName(testSuiteIdStr, testSuiteName, internal.Empty, true, false)
testSuites := svc.GetTestSuitesByIdOrName(testSuiteIdStr, testSuiteName, internal.Empty, true, false, true)
svc.AddTestCaseWithTestSuite(testSuites, testSuiteName, url, condition, ipVersion, addHeader, modifyHeader, filterHeader)
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/test_suites_remove_test_case.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var testSuitesRemoveTestCaseCmd = &cobra.Command{
validator.RemoveTestCaseFromTestSuiteFlagCheck(testSuiteIdStr, orderNumber)

testSuiteId, _ := strconv.Atoi(testSuiteIdStr)
testSuite := svc.GetSingleTestSuiteByIdOrName(testSuiteIdStr, "", internal.Empty)
testSuite := svc.GetSingleTestSuiteByIdOrName(testSuiteIdStr, "", internal.Empty, true)
testCases, _ := svc.GetV3AssociatedTestCasesForTestSuite(testSuiteId)
svc.RemoveTestCaseFromTestSuiteUsingOrderNumber(testSuite, testCases, orderNumber)
},
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/fatih/color v1.12.0
github.com/google/uuid v1.3.0 // indirect
github.com/jinzhu/copier v0.3.2
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/oleiade/reflections v1.0.1
github.com/olekukonko/tablewriter v0.0.5
github.com/sirupsen/logrus v1.8.1
Expand Down
5 changes: 3 additions & 2 deletions internal/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net/http"
"net/url"
"strconv"

"github.com/clarketm/json"
log "github.com/sirupsen/logrus"
Expand Down Expand Up @@ -100,9 +101,9 @@ func (api ApiClient) GetTestRunContext(testRunId int) (*TestRunContext, *CliErro
return nil, CliErrorFromPulsarProblemObject(*byt, nil, resp.StatusCode, ApiErrorTestRunContextGetCall)
}

func (api ApiClient) GetTestSuitesV3(propertyName, propVersion, user string) ([]TestSuiteV3, *CliError) {
func (api ApiClient) GetTestSuitesV3(propertyName, propVersion, user string, includeDeleted bool) ([]TestSuiteV3, *CliError) {

v3Path := "/test-management/v3/functional/test-suites?includeRecentlyDeleted=true"
v3Path := "/test-management/v3/functional/test-suites?includeRecentlyDeleted=" + strconv.FormatBool(includeDeleted)
tsV3Url, _ := url.Parse(v3Path)

// add optional query parameters
Expand Down
4 changes: 2 additions & 2 deletions internal/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ const (
Ipv6 = "IPV6"
)

// Browser ClientTypes
// Chrome Client
const (
Browser = "BROWSER"
Chrome = "CHROME"
)

// Environments
Expand Down
4 changes: 2 additions & 2 deletions internal/edge_grid_http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package internal

import (
"bytes"
"io/ioutil"
"io"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -69,8 +69,8 @@ func (h EdgeGridHttpClient) request(method string, path string, payload *[]byte,
os.Exit(ExitStatusCode1)
}
defer resp.Body.Close()
byt, err := io.ReadAll(resp.Body)

byt, err := ioutil.ReadAll(resp.Body)
if err != nil {
AbortWithExitCode(err.Error(), ExitStatusCode1)
}
Expand Down
6 changes: 4 additions & 2 deletions internal/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,9 @@
"externalApiDataError": "At least one property in your account is tied to multiple groups in Control Center. Test Center requires the property to be tied to exactly one group. Contact Akamai technical support to fix this.",
"maxAssociationsExceeded": "The number of test cases in this test suite exceeded the limit of '{{maxLimit}}'. Create a new test suite for test cases exceeding the limit.",
"clientProfileOfExistingAssociatedTestCasesDoNotMatch": "The test suite to which you are trying to add test cases is stateful. It accepts only test cases with the same client profile as test cases already included in the test suite. Change the test cases or add it to a different test suite.",
"testCasesContainsHeterogeneousClientProfiles": "In stateful test suites, test cases need to have the same client profile. Edit the test cases and try again."
"testCasesContainsHeterogeneousClientProfiles": "In stateful test suites, test cases need to have the same client profile. Edit the test cases and try again.",
"requiredFieldMissing": "The '{{requestField}}' is missing.",
"hostnameAccessMissing": "You don't have access to all the hostnames of included test cases. Get the access or edit the hostnames and try again."
},
"subCommand": {
"invalid": {
Expand Down Expand Up @@ -789,7 +791,7 @@
"configVersionIdTestSuiteIdAssociationNotFound": "Some of the property versions and test suites associations could not be found. Verify the associations and try again.",
"testSuiteIdTestCaseIdAssociationNotFound": "Some of the test suites and test cases associations could not be found. Verify the associations and try again."
},
"invalidClientTypeRequestMethodCombination": "Invalid combination of client type and request method. HEAD and POST request methods are allowed only with CURL client Type."
"invalidClientRequestMethodCombination": "Invalid combination of client and request method. HEAD and POST request methods are allowed only with CURL client."
},
"rateLimitExceeded": {
"rateLimitTestRunHostnameExceeded": "The number of test runs for a hostname exceeded the rate limit. Try again later."
Expand Down
Loading

0 comments on commit 9e6529d

Please sign in to comment.