Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into fix-data-dir
Browse files Browse the repository at this point in the history
  • Loading branch information
unguiculus committed Nov 28, 2024
2 parents 66c6418 + 0e15269 commit 329d73f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 20 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,17 @@ jobs:
# For upgrade and skew tests, we need to know the branch name this run is based off.
# Since this is predetermined, we can run this step before the docker-go job, saving time.
# For PRs we can use the base_ref (ie the target branch of the PR).
# For pushes to k3s-io/k3s, the branch_name is a valid ref, master or release-x.y.
# For pushes to k3s-io/k3s from dependabot or updatecli, use master
# All other pushes should be a valid ref, master or release-1.XX.
# For pushes to a fork, we need to determine the branch name by finding the parent branch from git show-branch history.
- name: Determine branch name
id: branch_step
run: |
if [ ${{ github.repository }} = "k3s-io/k3s" ]; then
BRANCH_NAME=$(echo ${{ github.base_ref || github.ref_name }})
if [[ $BRANCH_NAME =~ ^(dependabot|updatecli) ]]; then
BRANCH_NAME=master
fi
elif [ -z "${{ github.base_ref }}" ]; then
# We are in a fork, and need some git history to determine the branch name
git fetch origin --depth=100 +refs/heads/*:refs/remotes/origin/*
Expand All @@ -162,7 +166,14 @@ jobs:
fi
echo "Branch Name is $BRANCH_NAME"
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_OUTPUT
# branch name should be either master or release-1.XX
- name: Fail if branch name does not match pattern
run: |
if [[ ! ${{ steps.branch_step.outputs.branch_name }} =~ ^(master|release-[0-9]+\.[0-9]+)$ ]]; then
echo "Branch name ${{ steps.branch_step.outputs.branch_name }} does not match pattern"
exit 1
fi
docker-go:
needs: [build, build-go-tests]
name: Docker Tests In GO
Expand Down Expand Up @@ -193,7 +204,7 @@ jobs:
name: docker-go-tests
path: ./dist/artifacts
- name: Run ${{ matrix.dtest }} Test
# Put the compied test binary back in the same place as the test source
# Put the compiled test binary back in the same place as the test source
run: |
chmod +x ./dist/artifacts/${{ matrix.dtest }}.test
mv ./dist/artifacts/${{ matrix.dtest }}.test ./tests/docker/${{ matrix.dtest }}/
Expand Down
10 changes: 2 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -512,16 +512,10 @@ get_pr_artifact_url() {
fi

# GET request to the GitHub API to retrieve the Build workflow associated with the commit
wf_raw=$(curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" "${github_api_url}/commits/${commit_id}/check-runs")
build_workflow=$(printf "%s" "${wf_raw}" | jq -r '.check_runs[] | select(.name == "build / Build")')

# Extract the Run ID from the build workflow and lookup artifacts associated with the run
run_id=$(echo "${build_workflow}" | jq -r ' .details_url' | awk -F'/' '{print $(NF-2)}' | sort -rn | head -1)
run_id=$(curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" "${github_api_url}/commits/${commit_id}/check-runs?check_name=build%20%2F%20Build" | jq -r '[.check_runs | sort_by(.id) | .[].details_url | split("/")[7]] | last')

# Extract the artifact ID for the "k3s" artifact
artifacts=$(curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" "${github_api_url}/actions/runs/${run_id}/artifacts")
artifacts_url=$(echo "${artifacts}" | jq -r '.artifacts[] | select(.name == "k3s") | .archive_download_url')
GITHUB_PR_URL="${artifacts_url}"
GITHUB_PR_URL=$(curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" "${github_api_url}/actions/runs/${run_id}/artifacts" | jq -r '.artifacts[] | select(.name == "k3s") | .archive_download_url')
}

# --- download binary from github url ---
Expand Down
2 changes: 1 addition & 1 deletion install.sh.sha256sum
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3f41ed73265cee4cb0eb27dd1cdcf0691f5c3e2ccb7a206e2897c88d54293d8c install.sh
f526dac8da6b0c686d17db2d037ebaf6d0f0f772f513295d479ff096058edf03 install.sh
12 changes: 5 additions & 7 deletions tests/docker/etcd/etcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ var _ = Describe("Etcd Tests", Ordered, func() {
Eventually(func() error {
return tester.DeploymentsReady([]string{"coredns", "local-path-provisioner", "metrics-server", "traefik"}, config.KubeconfigFile)
}, "60s", "5s").Should(Succeed())
Eventually(func(g Gomega) {
g.Expect(tester.ParseNodes(config.KubeconfigFile)).To(HaveLen(3))
g.Expect(tester.NodesReady(config.KubeconfigFile)).To(Succeed())
Eventually(func() error {
return tester.NodesReady(config.KubeconfigFile, config.GetNodeNames()...)
}, "60s", "5s").Should(Succeed())
})
It("should destroy the cluster", func() {
Expand All @@ -59,10 +58,9 @@ var _ = Describe("Etcd Tests", Ordered, func() {
Eventually(func() error {
return tester.DeploymentsReady([]string{"coredns", "local-path-provisioner", "metrics-server", "traefik"}, config.KubeconfigFile)
}, "90s", "5s").Should(Succeed())
Eventually(func(g Gomega) {
g.Expect(tester.ParseNodes(config.KubeconfigFile)).To(HaveLen(6))
g.Expect(tester.NodesReady(config.KubeconfigFile)).To(Succeed())
}, "60s", "5s").Should(Succeed())
Eventually(func() error {
return tester.NodesReady(config.KubeconfigFile, config.GetNodeNames()...)
}, "90s", "5s").Should(Succeed())
})
})
})
Expand Down
15 changes: 14 additions & 1 deletion tests/docker/test-helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,16 +463,29 @@ func PodReady(podName, namespace, kubeconfigFile string) (bool, error) {
}

// Checks if all nodes are ready, otherwise returns an error
func NodesReady(kubeconfigFile string) error {
// If nodeNames are provided, make sure those nodes are ready
func NodesReady(kubeconfigFile string, nodeNames ...string) error {
nodes, err := ParseNodes(kubeconfigFile)
if err != nil {
return err
}
nodesFound := make(map[string]bool, len(nodeNames))
for _, nodeName := range nodeNames {
nodesFound[nodeName] = false
}
for _, node := range nodes {
for _, condition := range node.Status.Conditions {
if condition.Type == corev1.NodeReady && condition.Status != corev1.ConditionTrue {
return fmt.Errorf("node %s is not ready", node.Name)
}
if _, ok := nodesFound[node.Name]; ok {
nodesFound[node.Name] = true
}
}
}
for nodeName, found := range nodesFound {
if !found {
return fmt.Errorf("node %s not found", nodeName)
}
}
return nil
Expand Down

0 comments on commit 329d73f

Please sign in to comment.