• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / mender / 2281564137

23 Jan 2026 10:59AM UTC coverage: 81.48% (+1.7%) from 79.764%
2281564137

push

gitlab-ci

michalkopczan
fix: Schedule next deployment poll if current one failed early causing no handler to be called

Ticket: MEN-9144
Changelog: Fix a hang when polling for deployment failed early causing no handler of API response
to be called. Added handler call for this case, causing the deployment polling
to continue.

Signed-off-by: Michal Kopczan <michal.kopczan@northern.tech>

1 of 1 new or added line in 1 file covered. (100.0%)

327 existing lines in 44 files now uncovered.

8839 of 10848 relevant lines covered (81.48%)

20226.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.47
/src/artifact/token.hpp
1
// Copyright 2023 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14

15
#ifndef MENDER_ARTIFACT_TOKEN_HPP
16
#define MENDER_ARTIFACT_TOKEN_HPP
17

18
#include <unordered_map>
19
#include <string>
20
#include <regex>
21

22
#include <common/log.hpp>
23
#include <common/expected.hpp>
24

25
namespace mender {
26
namespace artifact {
27
namespace token {
28

29
const std::regex payload_regexp {
30
        "data/[0-9]{4}\\.tar(\\.(gz|xz|zst))?", std::regex_constants::ECMAScript};
31

32
using namespace std;
33

34
namespace tar = mender::tar;
35

36
namespace log = mender::common::log;
37
namespace error = mender::common::error;
38
namespace expected = mender::common::expected;
39

40
enum class Type {
41
        Uninitialized = 0,
42
        EOFToken,
43
        Unrecognized,
44
        Version,
45
        Manifest,
46
        ManifestSignature,
47
        ManifestAugment,
48
        Header,
49
        HeaderAugment,
50
        Payload,
51
};
52

53
const unordered_map<const Type, const string> type_map {
54
        {Type::Uninitialized, "Uninitialized"},
55
        {Type::EOFToken, "EOF"},
56
        {Type::Unrecognized, "Unrecognized"},
57
        {Type::Version, "version"},
58
        {Type::Manifest, "manifest"},
59
        {Type::ManifestSignature, "manifest.sig"},
60
        {Type::ManifestAugment, "manifest-augment"},
61
        {Type::Header, "header"},
62
        {Type::HeaderAugment, "header-augment"},
63
        {Type::Payload, "data"},
64
};
65

66
class Token {
1,250✔
67
public:
68
        Type type;
69
        // Poor mans optional
70
        shared_ptr<tar::Entry> value;
71

72
public:
73
        Token() :
182✔
74
                type {Type::Uninitialized} {
182✔
75
        }
76
        Token(Type t) :
102✔
77
                type {t} {
102✔
78
        }
79
        Token(const string &type_name, tar::Entry &entry) :
707✔
80
                type {StringToType(type_name)},
707✔
81
                value {make_shared<tar::Entry>(entry)} {
707✔
82
        }
707✔
83

84
        const string TypeToString() const {
1✔
85
                return type_map.at(type);
1✔
86
        }
87

88
private:
89
        Type StringToType(const string &type_name) {
707✔
90
                if (type_name == "version") {
707✔
91
                        return Type::Version;
92
                }
93
                if (type_name == "manifest") {
526✔
94
                        return Type::Manifest;
95
                }
96
                if (type_name == "manifest.sig") {
345✔
97
                        return Type::ManifestSignature;
98
                }
99
                if (type_name.find("header.tar") == 0) {
339✔
100
                        return Type::Header;
101
                }
102
                if (regex_match(type_name, payload_regexp)) {
158✔
103
                        return Type::Payload;
104
                }
UNCOV
105
                log::Error("Unrecognized token: " + type_name);
×
UNCOV
106
                return Type::Unrecognized;
×
107
        }
108
};
109
} // namespace token
110
} // namespace artifact
111
} // namespace mender
112

113
#endif // MENDER_ARTIFACT_TOKEN_HPP
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc