<commit_before>/*
Copyright 2017 Mirantis

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 e2e

import (
	"context"
	"encoding/json"
	"fmt"
	"math/rand"
	"strings"
	"time"

	. "github.com/onsi/gomega"

	"github.com/Mirantis/virtlet/tests/e2e/framework"
	. "github.com/Mirantis/virtlet/tests/e2e/ginkgo-ext"
)

var _ = Describe("Basic cirros tests", func() {
	var (
		vm    *framework.VMInterface
		vmPod *framework.PodInterface
	)

	BeforeAll(func() {
		vm = controller.VM("cirros-vm")
		vm.Create(VMOptions{}.applyDefaults(), time.Minute*5, nil)
		var err error
		vmPod, err = vm.Pod()
		Expect(err).NotTo(HaveOccurred())
	})

	AfterAll(func() {
		deleteVM(vm)
	})

	Context("VM guest OS", func() {
		var ssh framework.Executor
		scheduleWaitSSH(&vm, &ssh)

		It("Should have default route [Conformance]", func() {
			Expect(framework.ExecSimple(ssh, "ip r")).To(SatisfyAll(
				ContainSubstring("default via"),
				ContainSubstring("src "+vmPod.Pod.Status.PodIP),
			))
		})

		It("Should have internet connectivity [Conformance]", func(done Done) {
			defer close(done)
			Expect(framework.ExecSimple(ssh, "ping -c1 8.8.8.8")).To(ContainSubstring(
				"1 packets transmitted, 1 packets received, 0% packet loss"))
		}, 5)

		Context("With nginx server", func() {
			var nginxPod *framework.PodInterface
<commit_msg>Make e2e ping check compatible with Ubuntu<commit_after>/*
Copyright 2017 Mirantis

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 e2e

import (
	"context"
	"encoding/json"
	"fmt"
	"math/rand"
	"strings"
	"time"

	. "github.com/onsi/gomega"

	"github.com/Mirantis/virtlet/tests/e2e/framework"
	. "github.com/Mirantis/virtlet/tests/e2e/ginkgo-ext"
)

var _ = Describe("Basic cirros tests", func() {
	var (
		vm    *framework.VMInterface
		vmPod *framework.PodInterface
	)

	BeforeAll(func() {
		vm = controller.VM("cirros-vm")
		vm.Create(VMOptions{}.applyDefaults(), time.Minute*5, nil)
		var err error
		vmPod, err = vm.Pod()
		Expect(err).NotTo(HaveOccurred())
	})

	AfterAll(func() {
		deleteVM(vm)
	})

	Context("VM guest OS", func() {
		var ssh framework.Executor
		scheduleWaitSSH(&vm, &ssh)

		It("Should have default route [Conformance]", func() {
			Expect(framework.ExecSimple(ssh, "ip r")).To(SatisfyAll(
				ContainSubstring("default via"),
				ContainSubstring("src "+vmPod.Pod.Status.PodIP),
			))
		})

		It("Should have internet connectivity [Conformance]", func(done Done) {
			defer close(done)
			Expect(framework.ExecSimple(ssh, "ping -c1 8.8.8.8")).To(MatchRegexp(
				"1 .*transmitted, 1 .*received, 0% .*loss"))
		}, 5)

		Context("With nginx server", func() {
			var nginxPod *framework.PodInterface

{'fraction_non_alphanumeric': 0.12655429676706273, 'fraction_numerical': 0.011881735285990605, 'mean_word_length': 4.2086330935251794, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1170409', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1179, 'n_words': 345}