mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 23:37:01 +00:00
Merge pull request #115155 from adrianreber/2023-01-18-checkpoint-test-result
Extend checkpoint e2e test to check for results
This commit is contained in:
commit
981c4d59fb
@ -17,9 +17,13 @@ limitations under the License.
|
|||||||
package e2enode
|
package e2enode
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"archive/tar"
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -41,6 +45,10 @@ const (
|
|||||||
proxyTimeout = 2 * time.Minute
|
proxyTimeout = 2 * time.Minute
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type checkpointResult struct {
|
||||||
|
Items []string `json:"items"`
|
||||||
|
}
|
||||||
|
|
||||||
// proxyPostRequest performs a post on a node proxy endpoint given the nodename and rest client.
|
// proxyPostRequest performs a post on a node proxy endpoint given the nodename and rest client.
|
||||||
func proxyPostRequest(ctx context.Context, c clientset.Interface, node, endpoint string, port int) (restclient.Result, error) {
|
func proxyPostRequest(ctx context.Context, c clientset.Interface, node, endpoint string, port int) (restclient.Result, error) {
|
||||||
// proxy tends to hang in some cases when Node is not ready. Add an artificial timeout for this call. #22165
|
// proxy tends to hang in some cases when Node is not ready. Add an artificial timeout for this call. #22165
|
||||||
@ -150,10 +158,51 @@ var _ = SIGDescribe("Checkpoint Container [NodeFeature:CheckpointContainer]", fu
|
|||||||
}
|
}
|
||||||
|
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
// TODO: once a container engine implements the Checkpoint CRI API this needs
|
|
||||||
// to be extended to handle it.
|
|
||||||
//
|
|
||||||
// Checkpointing actually worked. Verify that the checkpoint exists and that
|
// Checkpointing actually worked. Verify that the checkpoint exists and that
|
||||||
// it is a checkpoint.
|
// it is a checkpoint.
|
||||||
|
|
||||||
|
raw, err := result.Raw()
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
answer := checkpointResult{}
|
||||||
|
err = json.Unmarshal(raw, &answer)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
|
for _, item := range answer.Items {
|
||||||
|
// Check that the file exists
|
||||||
|
_, err := os.Stat(item)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
// Check the content of the tar file
|
||||||
|
// At least looking for the following files
|
||||||
|
// * spec.dump
|
||||||
|
// * config.dump
|
||||||
|
// * checkpoint/inventory.img
|
||||||
|
// If these files exist in the checkpoint archive it is
|
||||||
|
// probably a complete checkpoint.
|
||||||
|
checkForFiles := map[string]bool{
|
||||||
|
"spec.dump": false,
|
||||||
|
"config.dump": false,
|
||||||
|
"checkpoint/inventory.img": false,
|
||||||
|
}
|
||||||
|
fileReader, err := os.Open(item)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
tr := tar.NewReader(fileReader)
|
||||||
|
for {
|
||||||
|
hdr, err := tr.Next()
|
||||||
|
if err == io.EOF {
|
||||||
|
// End of archive
|
||||||
|
break
|
||||||
|
}
|
||||||
|
framework.ExpectNoError(err)
|
||||||
|
if _, key := checkForFiles[hdr.Name]; key {
|
||||||
|
checkForFiles[hdr.Name] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for fileName := range checkForFiles {
|
||||||
|
framework.ExpectEqual(checkForFiles[fileName], true)
|
||||||
|
}
|
||||||
|
// cleanup checkpoint archive
|
||||||
|
os.RemoveAll(item)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user