<commit_before>package gqt_test

import (
	"io/ioutil"
	"os/exec"

	"code.cloudfoundry.org/garden"
	"code.cloudfoundry.org/guardian/gqt/containerdrunner"
	"code.cloudfoundry.org/guardian/gqt/runner"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
	"github.com/onsi/gomega/gexec"
)

var _ = Describe("Containerd", func() {

	var (
		client            *runner.RunningGarden
		containerdSession *gexec.Session
	)

	BeforeEach(func() {
		runDir, err := ioutil.TempDir("", "")
		Expect(err).NotTo(HaveOccurred())
		containerdConfig := containerdrunner.ContainerdConfig(runDir)
		containerdSession = containerdrunner.NewSession(runDir, containerdBinaries, containerdConfig)

		config.ContainerdSocket = containerdConfig.GRPC.Address
		client = runner.Start(config)
	})

	AfterEach(func() {
		Expect(containerdSession.Terminate().Wait()).To(gexec.Exit(0))
	})

	Describe("creating containers", func() {
		It("creates a containerd container with running init task", func() {
			container, err := client.Create(garden.ContainerSpec{})
			Expect(err).NotTo(HaveOccurred())

			lookupCommand := exec.Command(containerdBinaries.Ctr, "--address", config.ContainerdSocket, "--namespace", "garden", "tasks", "ps", container.Handle())

			session, err := gexec.Start(lookupCommand, GinkgoWriter, GinkgoWriter)
			Expect(err).NotTo(HaveOccurred())
			Eventually(session).Should(gbytes.Say(container.Handle()))
			Eventually(session).Should(gexec.Exit(0))
		})
<commit_msg>Add cleanup to containerd tests<commit_after>package gqt_test

import (
	"io/ioutil"
	"os/exec"

	"code.cloudfoundry.org/garden"
	"code.cloudfoundry.org/guardian/gqt/containerdrunner"
	"code.cloudfoundry.org/guardian/gqt/runner"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/onsi/gomega/gbytes"
	"github.com/onsi/gomega/gexec"
)

var _ = Describe("Containerd", func() {

	var (
		client            *runner.RunningGarden
		containerdSession *gexec.Session
	)

	BeforeEach(func() {
		runDir, err := ioutil.TempDir("", "")
		Expect(err).NotTo(HaveOccurred())
		containerdConfig := containerdrunner.ContainerdConfig(runDir)
		containerdSession = containerdrunner.NewSession(runDir, containerdBinaries, containerdConfig)

		config.ContainerdSocket = containerdConfig.GRPC.Address
		client = runner.Start(config)
	})

	AfterEach(func() {
		Expect(containerdSession.Terminate().Wait()).To(gexec.Exit(0))
		Expect(client.DestroyAndStop()).To(Succeed())
	})

	Describe("creating containers", func() {
		It("creates a containerd container with running init task", func() {
			container, err := client.Create(garden.ContainerSpec{})
			Expect(err).NotTo(HaveOccurred())

			lookupCommand := exec.Command(containerdBinaries.Ctr, "--address", config.ContainerdSocket, "--namespace", "garden", "tasks", "ps", container.Handle())

			session, err := gexec.Start(lookupCommand, GinkgoWriter, GinkgoWriter)
			Expect(err).NotTo(HaveOccurred())
			Eventually(session).Should(gbytes.Say(container.Handle()))
			Eventually(session).Should(gexec.Exit(0))
		})

{'fraction_non_alphanumeric': 0.15238718116415959, 'fraction_numerical': 0.0013080444735120995, 'mean_word_length': 5.294238683127572, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '2845093', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1041, 'n_words': 145}