Skip to content

Commit

Permalink
fixed linting error
Browse files Browse the repository at this point in the history
fixed lint error

shifted dryrun test to binary

Signed-off-by: Neeraj Nagure <[email protected]>

fixed kwokctl cmd

fixed cluster details

removed space

fixed errors

fixed path

fixed path

fixed path

fixed path

logged path

fixed path

fixed path

fixed get cluster

fixed expected cluster

fixed exec

added binary runtime

fixed cmd

fixed cmd

logged got

set the runtime

set runtime

logged

replaced kwokctl output

removed unnecessary logs

fixed lint

fixed lint error

migrated normal dry run to e2e
  • Loading branch information
NeerajNagure committed Jun 19, 2024
1 parent d0f4dc1 commit 0ac0040
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 104 deletions.
39 changes: 18 additions & 21 deletions test/e2e/dryrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,47 +20,44 @@ import (
"context"
"os"
"os/exec"
"path"
"strings"
"testing"

"sigs.k8s.io/e2e-framework/pkg/envconf"
"sigs.k8s.io/e2e-framework/pkg/features"
)

func getCurrentClusterDetails(clusterName string) (string, error) {
cmd := exec.Command("kwokctl", "get", "cluster", clusterName, "-o", "json")
output, err := cmd.Output()
if err != nil {
return "", err
}
out := string(output[:])
return out, err
}
"sigs.k8s.io/kwok/pkg/utils/path"
)

func loadExpectedClusterDetails(filepath string) (string, error) {
data, err := os.ReadFile(filepath)
if err != nil {
return "", err
}
out := string(data[:])
return out, err
out := string(data)
return out, nil
}

func CaseDryrun(clusterName string) *features.FeatureBuilder {
func CaseDryrun(clusterName string, kwokctlPath string, rootDir string) *features.FeatureBuilder {
f := features.New("Dry run")
f = f.Assess("test cluster dryrun", func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
got, err := getCurrentClusterDetails(clusterName)
if err != nil {
t.Fatal("Could not get cluster details:", err)
}
var expected string
pwd := os.Getenv("PWD")
rootDir := path.Join(pwd, "../../../..")
expected, err = loadExpectedClusterDetails(rootDir + "test/kwokctl/testdata/binary/create_cluster_with_extra.txt")
var err error
expected, err = loadExpectedClusterDetails(path.Join(rootDir, "test/kwokctl/testdata/binary/create_cluster.txt"))
if err != nil {
t.Fatal("Could not get expected cluster details:", err)
}
t.Log("EXPECTED CLUSTER:", expected)
cmd := exec.Command(kwokctlPath, "create", "cluster", "--name", clusterName, "--dry-run", "--runtime=binary", "--kube-authorization=false", "--disable-qps-limits", "--quiet-pull", "--timeout=30m", "--wait=30m")
var output []byte
output, err = cmd.Output()
if err != nil {
t.Fatal("Could not get the output of the command:", err)
}
got := string(output)
got = strings.ReplaceAll(got, clusterName, "<CLUSTER_NAME>")
got = strings.ReplaceAll(got, rootDir, "<ROOT_DIR>")
t.Log("GOT CLUSTER:", got)
if !strings.EqualFold(strings.TrimSpace(got), strings.TrimSpace(expected)) {
t.Fatalf("Expected %s but got %s", expected, got)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package dryrun_test
package binary_test

import (
"testing"
Expand All @@ -23,6 +23,6 @@ import (
)

func TestDryRun(t *testing.T) {
f0 := e2e.CaseDryrun(clusterName).Feature()
f0 := e2e.CaseDryrun(clusterName, kwokctlPath, rootDir).Feature()
testEnv.Test(t, f0)
}
81 changes: 0 additions & 81 deletions test/e2e/kwokctl/dryrun/main_test.go

This file was deleted.

0 comments on commit 0ac0040

Please sign in to comment.